annotate src/ex_docmd.c @ 22555:7d25264c246c v8.2.1826

patch 8.2.1826: Vim9: cannot use a {} block at script level Commit: https://github.com/vim/vim/commit/9becdf2b98e56d5eb193f3413d706ea433269216 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Oct 10 21:33:48 2020 +0200 patch 8.2.1826: Vim9: cannot use a {} block at script level Problem: Vim9: cannot use a {} block at script level. Solution: Recognize a {} block.
author Bram Moolenaar <Bram@vim.org>
date Sat, 10 Oct 2020 21:45:06 +0200
parents 1722ed01c729
children 715e8f14f314
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 * Do ":help uganda" in Vim to read copying and usage conditions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 * Do ":help credits" in Vim to see a list of people who contributed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 * See README.txt for an overview of the Vim source code.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 * ex_docmd.c: functions for executing an Ex command line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 #include "vim.h"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 static int quitmore = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 static int ex_pressedreturn = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 #ifndef FEAT_PRINTER
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 # define ex_hardcopy ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 #ifdef FEAT_EVAL
21885
72525eabfe61 patch 8.2.1492: build failures
Bram Moolenaar <Bram@vim.org>
parents: 21883
diff changeset
23 static char_u *do_one_cmd(char_u **, int, cstack_T *, char_u *(*fgetline)(int, void *, int, getline_opt_T), void *cookie);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 #else
21885
72525eabfe61 patch 8.2.1492: build failures
Bram Moolenaar <Bram@vim.org>
parents: 21883
diff changeset
25 static char_u *do_one_cmd(char_u **, int, char_u *(*fgetline)(int, void *, int, getline_opt_T), void *cookie);
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
26 static int if_level = 0; // depth in :if
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 #endif
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
28 static void append_command(char_u *cmd);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
29
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 #ifndef FEAT_MENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 # define ex_emenu ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 # define ex_menu ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 # define ex_menutranslate ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 #endif
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
35 static void ex_autocmd(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
36 static void ex_doautocmd(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
37 static void ex_bunload(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
38 static void ex_buffer(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
39 static void ex_bmodified(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
40 static void ex_bnext(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
41 static void ex_bprevious(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
42 static void ex_brewind(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
43 static void ex_blast(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
44 static char_u *getargcmd(char_u **);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
45 static int getargopt(exarg_T *eap);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 #ifndef FEAT_QUICKFIX
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 # define ex_make ex_ni
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 40
diff changeset
48 # define ex_cbuffer ex_ni
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 # define ex_cc ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 # define ex_cnext ex_ni
16505
28e3ba82d8c8 patch 8.1.1256: cannot navigate through errors relative to the cursor
Bram Moolenaar <Bram@vim.org>
parents: 16479
diff changeset
51 # define ex_cbelow ex_ni
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 # define ex_cfile ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 # define qf_list ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 # define qf_age ex_ni
9538
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9536
diff changeset
55 # define qf_history ex_ni
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 # define ex_helpgrep ex_ni
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 40
diff changeset
57 # define ex_vimgrep ex_ni
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 #endif
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
59 #if !defined(FEAT_QUICKFIX)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 # define ex_cclose ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 # define ex_copen ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 # define ex_cwindow ex_ni
9432
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9284
diff changeset
63 # define ex_cbottom ex_ni
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 #endif
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
65 #if !defined(FEAT_QUICKFIX) || !defined(FEAT_EVAL)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
66 # define ex_cexpr ex_ni
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
67 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68
21939
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
69 static linenr_T default_address(exarg_T *eap);
16475
854fb0ad4be6 patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents: 16451
diff changeset
70 static linenr_T get_address(exarg_T *, char_u **, cmd_addr_T addr_type, int skip, int silent, int to_other_file, int address_count);
21939
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
71 static void address_default_all(exarg_T *eap);
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
72 static void get_flags(exarg_T *eap);
2333
aee7e1e5e0ce Build problem when using all interfaces except Lua.
Bram Moolenaar <bram@vim.org>
parents: 2330
diff changeset
73 #if !defined(FEAT_PERL) \
aee7e1e5e0ce Build problem when using all interfaces except Lua.
Bram Moolenaar <bram@vim.org>
parents: 2330
diff changeset
74 || !defined(FEAT_PYTHON) || !defined(FEAT_PYTHON3) \
aee7e1e5e0ce Build problem when using all interfaces except Lua.
Bram Moolenaar <bram@vim.org>
parents: 2330
diff changeset
75 || !defined(FEAT_TCL) \
aee7e1e5e0ce Build problem when using all interfaces except Lua.
Bram Moolenaar <bram@vim.org>
parents: 2330
diff changeset
76 || !defined(FEAT_RUBY) \
aee7e1e5e0ce Build problem when using all interfaces except Lua.
Bram Moolenaar <bram@vim.org>
parents: 2330
diff changeset
77 || !defined(FEAT_LUA) \
aee7e1e5e0ce Build problem when using all interfaces except Lua.
Bram Moolenaar <bram@vim.org>
parents: 2330
diff changeset
78 || !defined(FEAT_MZSCHEME)
1315
0868e4e53fb2 updated for version 7.1-029
vimboss
parents: 1305
diff changeset
79 # define HAVE_EX_SCRIPT_NI
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
80 static void ex_script_ni(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
81 #endif
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
82 static char *invalid_range(exarg_T *eap);
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
83 static void correct_range(exarg_T *eap);
344
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
84 #ifdef FEAT_QUICKFIX
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
85 static char_u *replace_makeprg(exarg_T *eap, char_u *p, char_u **cmdlinep);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
86 #endif
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
87 static char_u *repl_cmdline(exarg_T *eap, char_u *src, int srclen, char_u *repl, char_u **cmdlinep);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
88 static void ex_highlight(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
89 static void ex_colorscheme(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
90 static void ex_cquit(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
91 static void ex_quit_all(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
92 static void ex_close(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
93 static void ex_win_close(int forceit, win_T *win, tabpage_T *tp);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
94 static void ex_only(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
95 static void ex_resize(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
96 static void ex_stag(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
97 static void ex_tabclose(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
98 static void ex_tabonly(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
99 static void ex_tabnext(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
100 static void ex_tabmove(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
101 static void ex_tabs(exarg_T *eap);
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
102 #if defined(FEAT_QUICKFIX)
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
103 static void ex_pclose(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
104 static void ex_ptag(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
105 static void ex_pedit(exarg_T *eap);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 # define ex_pclose ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 # define ex_ptag ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 # define ex_pedit ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 #endif
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
111 static void ex_hide(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
112 static void ex_stop(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
113 static void ex_exit(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
114 static void ex_print(exarg_T *eap);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 #ifdef FEAT_BYTEOFF
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
116 static void ex_goto(exarg_T *eap);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 # define ex_goto ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 #endif
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
120 static void ex_shell(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
121 static void ex_preserve(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
122 static void ex_recover(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
123 static void ex_mode(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
124 static void ex_wrongmodifier(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
125 static void ex_find(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
126 static void ex_open(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
127 static void ex_edit(exarg_T *eap);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 #ifndef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129 # define ex_gui ex_nogui
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
130 static void ex_nogui(exarg_T *eap);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131 #endif
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15866
diff changeset
132 #if defined(FEAT_GUI_MSWIN) && defined(FEAT_MENU) && defined(FEAT_TEAROFF)
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
133 static void ex_tearoff(exarg_T *eap);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135 # define ex_tearoff ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136 #endif
13392
d5347779fb20 patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents: 13384
diff changeset
137 #if (defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_GTK) \
d5347779fb20 patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents: 13384
diff changeset
138 || defined(FEAT_TERM_POPUP_MENU)) && defined(FEAT_MENU)
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
139 static void ex_popup(exarg_T *eap);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141 # define ex_popup ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143 #ifndef FEAT_GUI_MSWIN
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144 # define ex_simalt ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 #endif
573
c85bf6a4999b updated for version 7.0163
vimboss
parents: 557
diff changeset
146 #if !defined(FEAT_GUI_MSWIN) && !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_MOTIF)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147 # define gui_mch_find_dialog ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148 # define gui_mch_replace_dialog ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149 #endif
573
c85bf6a4999b updated for version 7.0163
vimboss
parents: 557
diff changeset
150 #if !defined(FEAT_GUI_GTK)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151 # define ex_helpfind ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153 #ifndef FEAT_CSCOPE
10373
bd674706408a commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents: 10361
diff changeset
154 # define ex_cscope ex_ni
bd674706408a commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents: 10361
diff changeset
155 # define ex_scscope ex_ni
bd674706408a commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents: 10361
diff changeset
156 # define ex_cstag ex_ni
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
158 #ifndef FEAT_SYN_HL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159 # define ex_syntax ex_ni
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2238
diff changeset
160 # define ex_ownsyntax ex_ni
737
59971e227f8c updated for version 7.0222
vimboss
parents: 727
diff changeset
161 #endif
4766
ec24ff78a79c updated for version 7.3.1130
Bram Moolenaar <bram@vim.org>
parents: 4764
diff changeset
162 #if !defined(FEAT_SYN_HL) || !defined(FEAT_PROFILE)
4764
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4710
diff changeset
163 # define ex_syntime ex_ni
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4710
diff changeset
164 #endif
737
59971e227f8c updated for version 7.0222
vimboss
parents: 727
diff changeset
165 #ifndef FEAT_SPELL
310
04bf54c587f4 updated for version 7.0082
vimboss
parents: 296
diff changeset
166 # define ex_spell ex_ni
236
4707450c2b33 updated for version 7.0066
vimboss
parents: 198
diff changeset
167 # define ex_mkspell ex_ni
351
a89aebda7f37 updated for version 7.0091
vimboss
parents: 344
diff changeset
168 # define ex_spelldump ex_ni
714
0f9f4761ad9c updated for version 7.0216
vimboss
parents: 698
diff changeset
169 # define ex_spellinfo ex_ni
372
a698eb686ded updated for version 7.0096
vimboss
parents: 358
diff changeset
170 # define ex_spellrepall ex_ni
236
4707450c2b33 updated for version 7.0066
vimboss
parents: 198
diff changeset
171 #endif
2214
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2210
diff changeset
172 #ifndef FEAT_PERSISTENT_UNDO
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2210
diff changeset
173 # define ex_rundo ex_ni
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2210
diff changeset
174 # define ex_wundo ex_ni
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2210
diff changeset
175 #endif
2320
966a5609669e Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents: 2311
diff changeset
176 #ifndef FEAT_LUA
966a5609669e Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents: 2311
diff changeset
177 # define ex_lua ex_script_ni
966a5609669e Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents: 2311
diff changeset
178 # define ex_luado ex_ni
966a5609669e Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents: 2311
diff changeset
179 # define ex_luafile ex_ni
966a5609669e Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents: 2311
diff changeset
180 #endif
14
946da5994c01 updated for version 7.0006
vimboss
parents: 11
diff changeset
181 #ifndef FEAT_MZSCHEME
946da5994c01 updated for version 7.0006
vimboss
parents: 11
diff changeset
182 # define ex_mzscheme ex_script_ni
946da5994c01 updated for version 7.0006
vimboss
parents: 11
diff changeset
183 # define ex_mzfile ex_ni
946da5994c01 updated for version 7.0006
vimboss
parents: 11
diff changeset
184 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185 #ifndef FEAT_PERL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186 # define ex_perl ex_script_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187 # define ex_perldo ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
189 #ifndef FEAT_PYTHON
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190 # define ex_python ex_script_ni
4435
9b800f0a757f updated for version 7.3.966
Bram Moolenaar <bram@vim.org>
parents: 4417
diff changeset
191 # define ex_pydo ex_ni
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192 # define ex_pyfile ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193 #endif
2329
ad2889f48843 Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents: 2320
diff changeset
194 #ifndef FEAT_PYTHON3
2350
06feaf4fe36a Rename some "python3" symbols to "py3", as the command name.
Bram Moolenaar <bram@vim.org>
parents: 2340
diff changeset
195 # define ex_py3 ex_script_ni
4417
c16602758d84 updated for version 7.3.957
Bram Moolenaar <bram@vim.org>
parents: 4365
diff changeset
196 # define ex_py3do ex_ni
2329
ad2889f48843 Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents: 2320
diff changeset
197 # define ex_py3file ex_ni
ad2889f48843 Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents: 2320
diff changeset
198 #endif
10722
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10656
diff changeset
199 #if !defined(FEAT_PYTHON) && !defined(FEAT_PYTHON3)
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10656
diff changeset
200 # define ex_pyx ex_script_ni
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10656
diff changeset
201 # define ex_pyxdo ex_ni
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10656
diff changeset
202 # define ex_pyxfile ex_ni
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10656
diff changeset
203 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
204 #ifndef FEAT_TCL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205 # define ex_tcl ex_script_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206 # define ex_tcldo ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
207 # define ex_tclfile ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
208 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
209 #ifndef FEAT_RUBY
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
210 # define ex_ruby ex_script_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
211 # define ex_rubydo ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
212 # define ex_rubyfile ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
213 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214 #ifndef FEAT_KEYMAP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
215 # define ex_loadkeymap ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
216 #endif
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
217 static void ex_swapname(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
218 static void ex_syncbind(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
219 static void ex_read(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
220 static void ex_pwd(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
221 static void ex_equal(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
222 static void ex_sleep(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
223 static void ex_winsize(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
224 static void ex_wincmd(exarg_T *eap);
11
4424b47a0797 updated for version 7.0003
vimboss
parents: 9
diff changeset
225 #if defined(FEAT_GUI) || defined(UNIX) || defined(VMS) || defined(MSWIN)
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
226 static void ex_winpos(exarg_T *eap);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
227 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
228 # define ex_winpos ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
229 #endif
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
230 static void ex_operators(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
231 static void ex_put(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
232 static void ex_copymove(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
233 static void ex_submagic(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
234 static void ex_join(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
235 static void ex_at(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
236 static void ex_bang(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
237 static void ex_undo(exarg_T *eap);
2214
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2210
diff changeset
238 #ifdef FEAT_PERSISTENT_UNDO
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
239 static void ex_wundo(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
240 static void ex_rundo(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
241 #endif
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
242 static void ex_redo(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
243 static void ex_later(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
244 static void ex_redir(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
245 static void ex_redrawstatus(exarg_T *eap);
15396
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 15263
diff changeset
246 static void ex_redrawtabline(exarg_T *eap);
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
247 static void close_redir(void);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
248 static void ex_mark(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
249 static void ex_startinsert(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
250 static void ex_stopinsert(exarg_T *eap);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
251 #ifdef FEAT_FIND_ID
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
252 static void ex_checkpath(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
253 static void ex_findpat(exarg_T *eap);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
254 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
255 # define ex_findpat ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
256 # define ex_checkpath ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
257 #endif
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
258 #if defined(FEAT_FIND_ID) && defined(FEAT_QUICKFIX)
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
259 static void ex_psearch(exarg_T *eap);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
260 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
261 # define ex_psearch ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
262 #endif
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
263 static void ex_tag(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
264 static void ex_tag_cmd(exarg_T *eap, char_u *name);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
265 #ifndef FEAT_EVAL
17622
ccbf8c2a47ee patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17576
diff changeset
266 # define ex_break ex_ni
ccbf8c2a47ee patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17576
diff changeset
267 # define ex_breakadd ex_ni
ccbf8c2a47ee patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17576
diff changeset
268 # define ex_breakdel ex_ni
ccbf8c2a47ee patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17576
diff changeset
269 # define ex_breaklist ex_ni
ccbf8c2a47ee patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17576
diff changeset
270 # define ex_call ex_ni
ccbf8c2a47ee patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17576
diff changeset
271 # define ex_catch ex_ni
ccbf8c2a47ee patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17576
diff changeset
272 # define ex_compiler ex_ni
ccbf8c2a47ee patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17576
diff changeset
273 # define ex_continue ex_ni
ccbf8c2a47ee patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17576
diff changeset
274 # define ex_debug ex_ni
ccbf8c2a47ee patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17576
diff changeset
275 # define ex_debuggreedy ex_ni
20528
489cb75c76b6 patch 8.2.0818: Vim9: using a discovery phase doesn't work well
Bram Moolenaar <Bram@vim.org>
parents: 20474
diff changeset
276 # define ex_def ex_ni
489cb75c76b6 patch 8.2.0818: Vim9: using a discovery phase doesn't work well
Bram Moolenaar <Bram@vim.org>
parents: 20474
diff changeset
277 # define ex_defcompile ex_ni
17622
ccbf8c2a47ee patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17576
diff changeset
278 # define ex_delfunction ex_ni
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
279 # define ex_disassemble ex_ni
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
280 # define ex_echo ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
22393
d1b9bd52d721 patch 8.2.1745: tiny version doesn't build
Bram Moolenaar <Bram@vim.org>
parents: 22391
diff changeset
294 # define ex_var ex_ni
17622
ccbf8c2a47ee patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17576
diff changeset
295 # define ex_lockvar ex_ni
ccbf8c2a47ee patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17576
diff changeset
296 # define ex_oldfiles ex_ni
ccbf8c2a47ee patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17576
diff changeset
297 # define ex_options ex_ni
ccbf8c2a47ee patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17576
diff changeset
298 # define ex_packadd ex_ni
ccbf8c2a47ee patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17576
diff changeset
299 # define ex_packloadall ex_ni
ccbf8c2a47ee patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17576
diff changeset
300 # define ex_return ex_ni
ccbf8c2a47ee patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17576
diff changeset
301 # define ex_scriptnames ex_ni
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
302 # define ex_throw ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
303 # define ex_try ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
304 # define ex_unlet ex_ni
146
5cc0aca13a3f updated for version 7.0046
vimboss
parents: 128
diff changeset
305 # define ex_unlockvar ex_ni
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
306 # define ex_vim9script ex_ni
17622
ccbf8c2a47ee patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17576
diff changeset
307 # define ex_while ex_ni
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
308 # define ex_import ex_ni
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
309 # define ex_export ex_ni
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
310 #endif
17536
e00d12c085a5 patch 8.1.1766: code for writing session file is spread out
Bram Moolenaar <Bram@vim.org>
parents: 17496
diff changeset
311 #ifndef FEAT_SESSION
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
312 # define ex_loadview ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
313 #endif
17458
cfdef48743ed patch 8.1.1727: code for viminfo support is spread out
Bram Moolenaar <Bram@vim.org>
parents: 17431
diff changeset
314 #ifndef FEAT_VIMINFO
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
315 # define ex_viminfo ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
316 #endif
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
317 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
318 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
319 static void ex_setfiletype(exarg_T *eap);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
320 #ifndef FEAT_DIFF
16
3ba373b54370 updated for version 7.0008
vimboss
parents: 14
diff changeset
321 # define ex_diffoff ex_ni
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
322 # define ex_diffpatch ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
323 # define ex_diffgetput ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
324 # define ex_diffsplit ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
325 # define ex_diffthis ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
326 # define ex_diffupdate ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
327 #endif
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
328 static void ex_digraphs(exarg_T *eap);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
329 #ifdef FEAT_SEARCH_EXTRA
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
330 static void ex_nohlsearch(exarg_T *eap);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
331 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
332 # define ex_nohlsearch ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
333 # define ex_match ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
334 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
335 #ifdef FEAT_CRYPT
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
336 static void ex_X(exarg_T *eap);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
337 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
338 # define ex_X ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
339 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
340 #ifdef FEAT_FOLDING
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
341 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
342 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
343 static void ex_folddo(exarg_T *eap);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
344 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
345 # define ex_fold ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
346 # define ex_foldopen ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
347 # define ex_folddo ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
348 #endif
15595
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15591
diff changeset
349 #if !(defined(HAVE_LOCALE_H) || defined(X_LOCALE))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
350 # define ex_language ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
351 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
352 #ifndef FEAT_SIGNS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
353 # define ex_sign ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
354 #endif
33
f6033dcbaf31 updated for version 7.0020
vimboss
parents: 28
diff changeset
355 #ifndef FEAT_NETBEANS_INTG
2210
8c6a66e2b3cc Add :nbstart and :nbclose.
Bram Moolenaar <bram@vim.org>
parents: 2180
diff changeset
356 # define ex_nbclose ex_ni
33
f6033dcbaf31 updated for version 7.0020
vimboss
parents: 28
diff changeset
357 # define ex_nbkey ex_ni
2210
8c6a66e2b3cc Add :nbstart and :nbclose.
Bram Moolenaar <bram@vim.org>
parents: 2180
diff changeset
358 # define ex_nbstart ex_ni
33
f6033dcbaf31 updated for version 7.0020
vimboss
parents: 28
diff changeset
359 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
360
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
361 #ifndef FEAT_JUMPLIST
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
362 # define ex_jumps ex_ni
9284
78712a2f687a commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents: 9260
diff changeset
363 # define ex_clearjumps ex_ni
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
364 # define ex_changes ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
365 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
366
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
367 #ifndef FEAT_PROFILE
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
368 # define ex_profile ex_ni
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
369 #endif
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents: 11547
diff changeset
370 #ifndef FEAT_TERMINAL
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents: 11547
diff changeset
371 # define ex_terminal ex_ni
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents: 11547
diff changeset
372 #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
373 #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
374 # 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
375 #endif
18763
49b78d6465e5 patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents: 18715
diff changeset
376 #if !defined(FEAT_PROP_POPUP)
16780
491c01280a5d patch 8.1.1392: build failure in tiny version
Bram Moolenaar <Bram@vim.org>
parents: 16764
diff changeset
377 # define ex_popupclear ex_ni
491c01280a5d patch 8.1.1392: build failure in tiny version
Bram Moolenaar <Bram@vim.org>
parents: 16764
diff changeset
378 #endif
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
379
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
380 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
381 * Declare cmdnames[].
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
382 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
383 #define DO_DECLARE_EXCMD
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
384 #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
385 #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
386
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
387 static char_u dollar_command[2] = {'$', 0};
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
388
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
389
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
390 #ifdef FEAT_EVAL
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
391 // Struct for storing a line inside a while/for loop
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
392 typedef struct
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
393 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
394 char_u *line; // command line
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
395 linenr_T lnum; // sourcing_lnum of the line
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
396 } wcmd_T;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
397
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
398 /*
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
399 * Structure used to store info for line position in a while or for loop.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
400 * This is required, because do_one_cmd() may invoke ex_function(), which
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
401 * reads more lines that may come from the while/for loop.
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
402 */
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
403 struct loop_cookie
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
404 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
405 garray_T *lines_gap; // growarray with line info
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
406 int current_line; // last read line from growarray
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
407 int repeating; // TRUE when looping a second time
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
408 // When "repeating" is FALSE use "getline" and "cookie" to get lines
21885
72525eabfe61 patch 8.2.1492: build failures
Bram Moolenaar <Bram@vim.org>
parents: 21883
diff changeset
409 char_u *(*getline)(int, void *, int, getline_opt_T);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
410 void *cookie;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
411 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
412
21885
72525eabfe61 patch 8.2.1492: build failures
Bram Moolenaar <Bram@vim.org>
parents: 21883
diff changeset
413 static char_u *get_loop_line(int c, void *cookie, int indent, getline_opt_T options);
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
414 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
415 static void free_cmdlines(garray_T *gap);
8
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
416
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
417 // Struct to save a few things while debugging. Used in do_cmdline() only.
8
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
418 struct dbg_stuff
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
419 {
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
420 int trylevel;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
421 int force_abort;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
422 except_T *caught_stack;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
423 char_u *vv_exception;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
424 char_u *vv_throwpoint;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
425 int did_emsg;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
426 int got_int;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
427 int did_throw;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
428 int need_rethrow;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
429 int check_cstack;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
430 except_T *current_exception;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
431 };
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
432
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
433 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
434 save_dbg_stuff(struct dbg_stuff *dsp)
8
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
435 {
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
436 dsp->trylevel = trylevel; trylevel = 0;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
437 dsp->force_abort = force_abort; force_abort = FALSE;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
438 dsp->caught_stack = caught_stack; caught_stack = NULL;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
439 dsp->vv_exception = v_exception(NULL);
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
440 dsp->vv_throwpoint = v_throwpoint(NULL);
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
441
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
442 // Necessary for debugging an inactive ":catch", ":finally", ":endtry"
8
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
443 dsp->did_emsg = did_emsg; did_emsg = FALSE;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
444 dsp->got_int = got_int; got_int = FALSE;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
445 dsp->did_throw = did_throw; did_throw = FALSE;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
446 dsp->need_rethrow = need_rethrow; need_rethrow = FALSE;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
447 dsp->check_cstack = check_cstack; check_cstack = FALSE;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
448 dsp->current_exception = current_exception; current_exception = NULL;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
449 }
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
450
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
451 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
452 restore_dbg_stuff(struct dbg_stuff *dsp)
8
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
453 {
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
454 suppress_errthrow = FALSE;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
455 trylevel = dsp->trylevel;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
456 force_abort = dsp->force_abort;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
457 caught_stack = dsp->caught_stack;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
458 (void)v_exception(dsp->vv_exception);
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
459 (void)v_throwpoint(dsp->vv_throwpoint);
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
460 did_emsg = dsp->did_emsg;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
461 got_int = dsp->got_int;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
462 did_throw = dsp->did_throw;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
463 need_rethrow = dsp->need_rethrow;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
464 check_cstack = dsp->check_cstack;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
465 current_exception = dsp->current_exception;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
466 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
467 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
468
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
469 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
470 * do_exmode(): Repeatedly get commands for the "Ex" mode, until the ":vi"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
471 * command is given.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
472 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
473 void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
474 do_exmode(
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
475 int improved) // TRUE for "improved Ex" mode
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
476 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
477 int save_msg_scroll;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
478 int prev_msg_row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
479 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
480 varnumber_T changedtick;
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
481
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
482 if (improved)
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
483 exmode_active = EXMODE_VIM;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
484 else
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
485 exmode_active = EXMODE_NORMAL;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
486 State = NORMAL;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
487
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
488 // When using ":global /pat/ visual" and then "Q" we return to continue
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
489 // the :global command.
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
490 if (global_busy)
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
491 return;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
492
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
493 save_msg_scroll = msg_scroll;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
494 ++RedrawingDisabled; // don't redisplay the window
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
495 ++no_wait_return; // don't wait for return
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
496 #ifdef FEAT_GUI
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
497 // Ignore scrollbar and mouse events in Ex mode
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
498 ++hold_gui_events;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
499 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
500
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15510
diff changeset
501 msg(_("Entering Ex mode. Type \"visual\" to go to Normal mode."));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
502 while (exmode_active)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
503 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
504 // Check for a ":normal" command and no more characters left.
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
505 if (ex_normal_busy > 0 && typebuf.tb_len == 0)
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
506 {
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
507 exmode_active = FALSE;
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
508 break;
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
509 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
510 msg_scroll = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
511 need_wait_return = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
512 ex_pressedreturn = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
513 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
514 changedtick = CHANGEDTICK(curbuf);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
515 prev_msg_row = msg_row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
516 prev_line = curwin->w_cursor.lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
517 if (improved)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
518 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
519 cmdline_row = msg_row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
520 do_cmdline(NULL, getexline, NULL, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
521 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
522 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
523 do_cmdline(NULL, getexmodeline, NULL, DOCMD_NOWAIT);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
524 lines_left = Rows - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
525
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
526 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
527 || changedtick != CHANGEDTICK(curbuf)) && !ex_no_reprint)
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
528 {
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
529 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
530 emsg(_(e_emptybuf));
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
531 else
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
532 {
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
533 if (ex_pressedreturn)
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
534 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
535 // go up one line, to overwrite the ":<CR>" line, so the
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
536 // output doesn't contain empty lines.
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
537 msg_row = prev_msg_row;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
538 if (prev_msg_row == Rows - 1)
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
539 msg_row--;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
540 }
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
541 msg_col = 0;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
542 print_line_no_prefix(curwin->w_cursor.lnum, FALSE, FALSE);
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
543 msg_clr_eos();
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
544 }
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
545 }
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
546 else if (ex_pressedreturn && !ex_no_reprint) // must be at EOF
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
547 {
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
548 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
549 emsg(_(e_emptybuf));
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
550 else
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
551 emsg(_("E501: At end-of-file"));
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
552 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
553 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
554
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
555 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
556 --hold_gui_events;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
557 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
558 --RedrawingDisabled;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
559 --no_wait_return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
560 update_screen(CLEAR);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
561 need_wait_return = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
562 msg_scroll = save_msg_scroll;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
563 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
564
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
565 /*
18297
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
566 * Print the executed command for when 'verbose' is set.
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
567 * When "lnum" is 0 only print the command.
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
568 */
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
569 static void
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
570 msg_verbose_cmd(linenr_T lnum, char_u *cmd)
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
571 {
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
572 ++no_wait_return;
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
573 verbose_enter_scroll();
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
574
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
575 if (lnum == 0)
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
576 smsg(_("Executing: %s"), cmd);
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
577 else
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
578 smsg(_("line %ld: %s"), (long)lnum, cmd);
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
579 if (msg_silent == 0)
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
580 msg_puts("\n"); // don't overwrite this
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
581
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
582 verbose_leave_scroll();
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
583 --no_wait_return;
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
584 }
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
585
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
586 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
587 * Execute a simple command line. Used for translated commands like "*".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
588 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
589 int
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
590 do_cmdline_cmd(char_u *cmd)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
591 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
592 return do_cmdline(cmd, NULL, NULL,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
593 DOCMD_VERBOSE|DOCMD_NOWAIT|DOCMD_KEYTYPED);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
594 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
595
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
596 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
597 * do_cmdline(): execute one Ex command line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
598 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
599 * 1. Execute "cmdline" when it is not NULL.
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
600 * If "cmdline" is NULL, or more lines are needed, fgetline() is used.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
601 * 2. Split up in parts separated with '|'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
602 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
603 * This function can be called recursively!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
604 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
605 * flags:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
606 * DOCMD_VERBOSE - The command will be included in the error message.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
607 * DOCMD_NOWAIT - Don't call wait_return() and friends.
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
608 * DOCMD_REPEAT - Repeat execution until fgetline() returns NULL.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
609 * DOCMD_KEYTYPED - Don't reset KeyTyped.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
610 * DOCMD_EXCRESET - Reset the exception environment (used for debugging).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
611 * DOCMD_KEEPLINE - Store first typed line (for repeating with ".").
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
612 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
613 * return FAIL if cmdline could not be executed, OK otherwise
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
614 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
615 int
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
616 do_cmdline(
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
617 char_u *cmdline,
21883
a427f5f26419 patch 8.2.1491: Vim9: crash when compiling heredoc lines start with comment
Bram Moolenaar <Bram@vim.org>
parents: 21845
diff changeset
618 char_u *(*fgetline)(int, void *, int, getline_opt_T),
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
619 void *cookie, // argument for fgetline()
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
620 int flags)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
621 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
622 char_u *next_cmdline; // next cmd to execute
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
623 char_u *cmdline_copy = NULL; // copy of cmd line
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
624 int used_getline = FALSE; // used "fgetline" to obtain command
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
625 static int recursive = 0; // recursive depth
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
626 int msg_didout_before_start = 0;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
627 int count = 0; // line number count
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
628 int did_inc = FALSE; // incremented RedrawingDisabled
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
629 int retval = OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
630 #ifdef FEAT_EVAL
18904
2bdc2e1f6e1f patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents: 18849
diff changeset
631 cstack_T cstack; // conditional stack
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
632 garray_T lines_ga; // keep lines for ":while"/":for"
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
633 int current_line = 0; // active line in lines_ga
21056
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
634 int current_line_before = 0;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
635 char_u *fname = NULL; // function or script name
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
636 linenr_T *breakpoint = NULL; // ptr to breakpoint field in cookie
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
637 int *dbg_tick = NULL; // ptr to dbg_tick field in cookie
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
638 struct dbg_stuff debug_saved; // saved things for debug mode
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
639 int initial_trylevel;
20538
9f921ba86d05 patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents: 20536
diff changeset
640 msglist_T **saved_msg_list = NULL;
9f921ba86d05 patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents: 20536
diff changeset
641 msglist_T *private_msg_list;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
642
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
643 // "fgetline" and "cookie" passed to do_one_cmd()
21883
a427f5f26419 patch 8.2.1491: Vim9: crash when compiling heredoc lines start with comment
Bram Moolenaar <Bram@vim.org>
parents: 21845
diff changeset
644 char_u *(*cmd_getline)(int, void *, int, getline_opt_T);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
645 void *cmd_cookie;
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
646 struct loop_cookie cmd_loop_cookie;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
647 void *real_cookie;
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
648 int getline_is_func;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
649 #else
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
650 # define cmd_getline fgetline
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
651 # define cmd_cookie cookie
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
652 #endif
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
653 static int call_depth = 0; // recursiveness
20009
6eb3c91d9875 patch 8.2.0560: compiler warning in tiny build
Bram Moolenaar <Bram@vim.org>
parents: 20007
diff changeset
654 #ifdef FEAT_EVAL
19075
af1eca322b9e patch 8.2.0098: exe stack length can be wrong without being detected
Bram Moolenaar <Bram@vim.org>
parents: 19069
diff changeset
655 ESTACK_CHECK_DECLARATION
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
656
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
657 // For every pair of do_cmdline()/do_one_cmd() calls, use an extra memory
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
658 // location for storing error messages to be converted to an exception.
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
659 // This ensures that the do_errthrow() call in do_one_cmd() does not
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
660 // combine the messages stored by an earlier invocation of do_one_cmd()
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
661 // with the command name of the later one. This would happen when
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
662 // BufWritePost autocommands are executed after a write error.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
663 saved_msg_list = msg_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
664 msg_list = &private_msg_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
665 private_msg_list = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
666 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
667
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
668 // It's possible to create an endless loop with ":execute", catch that
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
669 // here. The value of 200 allows nested function calls, ":source", etc.
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
670 // 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
671 if (call_depth >= 200
8f2191b56d52 commit https://github.com/vim/vim/commit/b094ff4b2be4d8b7364c566a1cc7e27aa4452a50
Christian Brabandt <cb@256bit.org>
parents: 10488
diff changeset
672 #ifdef FEAT_EVAL
8f2191b56d52 commit https://github.com/vim/vim/commit/b094ff4b2be4d8b7364c566a1cc7e27aa4452a50
Christian Brabandt <cb@256bit.org>
parents: 10488
diff changeset
673 && call_depth >= p_mfd
8f2191b56d52 commit https://github.com/vim/vim/commit/b094ff4b2be4d8b7364c566a1cc7e27aa4452a50
Christian Brabandt <cb@256bit.org>
parents: 10488
diff changeset
674 #endif
8f2191b56d52 commit https://github.com/vim/vim/commit/b094ff4b2be4d8b7364c566a1cc7e27aa4452a50
Christian Brabandt <cb@256bit.org>
parents: 10488
diff changeset
675 )
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
676 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
677 emsg(_("E169: Command too recursive"));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
678 #ifdef FEAT_EVAL
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
679 // When converting to an exception, we do not include the command name
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
680 // since this is not an error of the specific command.
18904
2bdc2e1f6e1f patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents: 18849
diff changeset
681 do_errthrow((cstack_T *)NULL, (char_u *)NULL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
682 msg_list = saved_msg_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
683 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
684 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
685 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
686 ++call_depth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
687
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
688 #ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
689 cstack.cs_idx = -1;
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
690 cstack.cs_looplevel = 0;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
691 cstack.cs_trylevel = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
692 cstack.cs_emsg_silent_list = NULL;
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
693 cstack.cs_lflags = 0;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
694 ga_init2(&lines_ga, (int)sizeof(wcmd_T), 10);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
695
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
696 real_cookie = getline_cookie(fgetline, cookie);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
697
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
698 // Inside a function use a higher nesting level.
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
699 getline_is_func = getline_equal(fgetline, cookie, get_func_line);
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
700 if (getline_is_func && ex_nesting_level == func_level(real_cookie))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
701 ++ex_nesting_level;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
702
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
703 // Get the function or script name and the address where the next breakpoint
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
704 // line and the debug tick for a function or script are stored.
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
705 if (getline_is_func)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
706 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
707 fname = func_name(real_cookie);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
708 breakpoint = func_breakpoint(real_cookie);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
709 dbg_tick = func_dbg_tick(real_cookie);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
710 }
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
711 else if (getline_equal(fgetline, cookie, getsourceline))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
712 {
18991
847cc7932c42 patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents: 18904
diff changeset
713 fname = SOURCING_NAME;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
714 breakpoint = source_breakpoint(real_cookie);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
715 dbg_tick = source_dbg_tick(real_cookie);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
716 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
717
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
718 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
719 * Initialize "force_abort" and "suppress_errthrow" at the top level.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
720 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
721 if (!recursive)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
722 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
723 force_abort = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
724 suppress_errthrow = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
725 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
726
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
727 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
728 * If requested, store and reset the global values controlling the
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 930
diff changeset
729 * exception handling (used when debugging). Otherwise clear it to avoid
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 930
diff changeset
730 * a bogus compiler warning when the optimizer uses inline functions...
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
731 */
878
64be6e0b070a updated for version 7.0-004
vimboss
parents: 866
diff changeset
732 if (flags & DOCMD_EXCRESET)
8
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
733 save_dbg_stuff(&debug_saved);
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 930
diff changeset
734 else
20007
aadd1cae2ff5 patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents: 19892
diff changeset
735 CLEAR_FIELD(debug_saved);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
736
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
737 initial_trylevel = trylevel;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
738
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
739 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
740 * "did_throw" will be set to TRUE when an exception is being thrown.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
741 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
742 did_throw = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
743 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
744 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
745 * "did_emsg" will be set to TRUE when emsg() is used, in which case we
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
746 * cancel the whole command line, and any if/endif or loop.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
747 * If force_abort is set, we cancel everything.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
748 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
749 did_emsg = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
750
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
751 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
752 * KeyTyped is only set when calling vgetc(). Reset it here when not
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
753 * calling vgetc() (sourced command lines).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
754 */
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
755 if (!(flags & DOCMD_KEYTYPED)
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
756 && !getline_equal(fgetline, cookie, getexline))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
757 KeyTyped = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
758
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
759 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
760 * Continue executing command lines:
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
761 * - when inside an ":if", ":while" or ":for"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
762 * - for multiple commands on one line, separated with '|'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
763 * - when repeating until there are no more lines (for ":source")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
764 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
765 next_cmdline = cmdline;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
766 do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
767 {
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
768 #ifdef FEAT_EVAL
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
769 getline_is_func = getline_equal(fgetline, cookie, get_func_line);
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
770 #endif
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
771
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
772 // stop skipping cmds for an error msg after all endif/while/for
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
773 if (next_cmdline == NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
774 #ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
775 && !force_abort
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
776 && cstack.cs_idx < 0
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
777 && !(getline_is_func && func_has_abort(real_cookie))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
778 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
779 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
780 did_emsg = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
781
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
782 /*
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
783 * 1. If repeating a line in a loop, get a line from lines_ga.
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
784 * 2. If no line given: Get an allocated line with fgetline().
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
785 * 3. If a line is given: Make a copy, so we can mess with it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
786 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
787
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
788 #ifdef FEAT_EVAL
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
789 // 1. If repeating, get a previous line from lines_ga.
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
790 if (cstack.cs_looplevel > 0 && current_line < lines_ga.ga_len)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
791 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
792 // Each '|' separated command is stored separately in lines_ga, to
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
793 // 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
794 VIM_CLEAR(cmdline_copy);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
795
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
796 // Check if a function has returned or, unless it has an unclosed
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
797 // try conditional, aborted.
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
798 if (getline_is_func)
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
799 {
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
800 # ifdef FEAT_PROFILE
788
b5aed52a4881 updated for version 7.0230
vimboss
parents: 771
diff changeset
801 if (do_profiling == PROF_YES)
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
802 func_line_end(real_cookie);
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
803 # endif
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
804 if (func_has_ended(real_cookie))
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
805 {
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
806 retval = FAIL;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
807 break;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
808 }
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
809 }
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
810 #ifdef FEAT_PROFILE
788
b5aed52a4881 updated for version 7.0230
vimboss
parents: 771
diff changeset
811 else if (do_profiling == PROF_YES
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
812 && getline_equal(fgetline, cookie, getsourceline))
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
813 script_line_end();
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
814 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
815
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
816 // Check if a sourced file hit a ":finish" command.
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
817 if (source_finished(fgetline, cookie))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
818 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
819 retval = FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
820 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
821 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
822
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
823 // If breakpoints have been added/deleted need to check for it.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
824 if (breakpoint != NULL && dbg_tick != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
825 && *dbg_tick != debug_tick)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
826 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
827 *breakpoint = dbg_find_breakpoint(
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
828 getline_equal(fgetline, cookie, getsourceline),
18991
847cc7932c42 patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents: 18904
diff changeset
829 fname, SOURCING_LNUM);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
830 *dbg_tick = debug_tick;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
831 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
832
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
833 next_cmdline = ((wcmd_T *)(lines_ga.ga_data))[current_line].line;
18991
847cc7932c42 patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents: 18904
diff changeset
834 SOURCING_LNUM = ((wcmd_T *)(lines_ga.ga_data))[current_line].lnum;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
835
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
836 // Did we encounter a breakpoint?
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
837 if (breakpoint != NULL && *breakpoint != 0
18991
847cc7932c42 patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents: 18904
diff changeset
838 && *breakpoint <= SOURCING_LNUM)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
839 {
18991
847cc7932c42 patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents: 18904
diff changeset
840 dbg_breakpoint(fname, SOURCING_LNUM);
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
841 // Find next breakpoint.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
842 *breakpoint = dbg_find_breakpoint(
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
843 getline_equal(fgetline, cookie, getsourceline),
18991
847cc7932c42 patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents: 18904
diff changeset
844 fname, SOURCING_LNUM);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
845 *dbg_tick = debug_tick;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
846 }
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
847 # ifdef FEAT_PROFILE
788
b5aed52a4881 updated for version 7.0230
vimboss
parents: 771
diff changeset
848 if (do_profiling == PROF_YES)
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
849 {
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
850 if (getline_is_func)
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
851 func_line_start(real_cookie);
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
852 else if (getline_equal(fgetline, cookie, getsourceline))
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
853 script_line_start();
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
854 }
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
855 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
856 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
857 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
858
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
859 // 2. If no line given, get an allocated line with fgetline().
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
860 if (next_cmdline == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
861 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
862 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
863 * Need to set msg_didout for the first line after an ":if",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
864 * otherwise the ":if" will be overwritten.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
865 */
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
866 if (count == 1 && getline_equal(fgetline, cookie, getexline))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
867 msg_didout = TRUE;
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
868 if (fgetline == NULL || (next_cmdline = fgetline(':', cookie,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
869 #ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
870 cstack.cs_idx < 0 ? 0 : (cstack.cs_idx + 1) * 2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
871 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
872 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
873 #endif
17178
40c4cb095d53 patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
874 , TRUE)) == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
875 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
876 // Don't call wait_return for aborted command line. The NULL
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
877 // returned for the end of a sourced file or executed function
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
878 // doesn't do this.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
879 if (KeyTyped && !(flags & DOCMD_REPEAT))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
880 need_wait_return = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
881 retval = FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
882 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
883 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
884 used_getline = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
885
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
886 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
887 * Keep the first typed line. Clear it when more lines are typed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
888 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
889 if (flags & DOCMD_KEEPLINE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
890 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
891 vim_free(repeat_cmdline);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
892 if (count == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
893 repeat_cmdline = vim_strsave(next_cmdline);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
894 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
895 repeat_cmdline = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
896 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
897 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
898
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
899 // 3. Make a copy of the command so we can mess with it.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
900 else if (cmdline_copy == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
901 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
902 next_cmdline = vim_strsave(next_cmdline);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
903 if (next_cmdline == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
904 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
905 emsg(_(e_outofmem));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
906 retval = FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
907 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
908 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
909 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
910 cmdline_copy = next_cmdline;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
911
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
912 #ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
913 /*
21056
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
914 * Inside a while/for loop, and when the command looks like a ":while"
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
915 * or ":for", the line is stored, because we may need it later when
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
916 * looping.
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
917 *
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
918 * When there is a '|' and another command, it is stored separately,
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
919 * because we need to be able to jump back to it from an
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
920 * :endwhile/:endfor.
21056
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
921 *
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
922 * Pass a different "fgetline" function to do_one_cmd() below,
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
923 * that it stores lines in or reads them from "lines_ga". Makes it
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
924 * possible to define a function inside a while/for loop and handles
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
925 * line continuation.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
926 */
21056
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
927 if ((cstack.cs_looplevel > 0 || has_loop_cmd(next_cmdline)))
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
928 {
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
929 cmd_getline = get_loop_line;
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
930 cmd_cookie = (void *)&cmd_loop_cookie;
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
931 cmd_loop_cookie.lines_gap = &lines_ga;
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
932 cmd_loop_cookie.current_line = current_line;
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
933 cmd_loop_cookie.getline = fgetline;
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
934 cmd_loop_cookie.cookie = cookie;
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
935 cmd_loop_cookie.repeating = (current_line < lines_ga.ga_len);
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
936
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
937 // Save the current line when encountering it the first time.
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
938 if (current_line == lines_ga.ga_len
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
939 && store_loop_line(&lines_ga, next_cmdline) == FAIL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
940 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
941 retval = FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
942 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
943 }
21056
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
944 current_line_before = current_line;
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
945 }
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
946 else
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
947 {
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
948 cmd_getline = fgetline;
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
949 cmd_cookie = cookie;
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
950 }
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
951
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
952 did_endif = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
953 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
954
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
955 if (count++ == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
956 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
957 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
958 * All output from the commands is put below each other, without
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
959 * waiting for a return. Don't do this when executing commands
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
960 * from a script or when being called recursive (e.g. for ":e
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
961 * +command file").
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
962 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
963 if (!(flags & DOCMD_NOWAIT) && !recursive)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
964 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
965 msg_didout_before_start = msg_didout;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
966 msg_didany = FALSE; // no output yet
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
967 msg_start();
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
968 msg_scroll = TRUE; // put messages below each other
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
969 ++no_wait_return; // don't wait for return until finished
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
970 ++RedrawingDisabled;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
971 did_inc = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
972 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
973 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
974
20575
501b72481d0a patch 8.2.0841: 'verbose' value 16 causes duplicate output
Bram Moolenaar <Bram@vim.org>
parents: 20538
diff changeset
975 if ((p_verbose >= 15 && SOURCING_NAME != NULL) || p_verbose >= 16)
18991
847cc7932c42 patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents: 18904
diff changeset
976 msg_verbose_cmd(SOURCING_LNUM, cmdline_copy);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
977
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
978 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
979 * 2. Execute one '|' separated command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
980 * do_one_cmd() will return NULL if there is no trailing '|'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
981 * "cmdline_copy" can change, e.g. for '%' and '#' expansion.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
982 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
983 ++recursive;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
984 next_cmdline = do_one_cmd(&cmdline_copy, flags & DOCMD_VERBOSE,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
985 #ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
986 &cstack,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
987 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
988 cmd_getline, cmd_cookie);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
989 --recursive;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
990
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
991 #ifdef FEAT_EVAL
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
992 if (cmd_cookie == (void *)&cmd_loop_cookie)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
993 // Use "current_line" from "cmd_loop_cookie", it may have been
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
994 // incremented when defining a function.
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
995 current_line = cmd_loop_cookie.current_line;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
996 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
997
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
998 if (next_cmdline == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
999 {
13244
ac42c4b11dbc patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents: 13221
diff changeset
1000 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
1001
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1002 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1003 * If the command was typed, remember it for the ':' register.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1004 * Do this AFTER executing the command to make :@: work.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1005 */
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
1006 if (getline_equal(fgetline, cookie, getexline)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1007 && new_last_cmdline != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1008 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1009 vim_free(last_cmdline);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1010 last_cmdline = new_last_cmdline;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1011 new_last_cmdline = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1012 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1013 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1014 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1015 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1016 // need to copy the command after the '|' to cmdline_copy, for the
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1017 // next do_one_cmd()
1619
b9740fb41986 updated for version 7.2a
vimboss
parents: 1613
diff changeset
1018 STRMOVE(cmdline_copy, next_cmdline);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1019 next_cmdline = cmdline_copy;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1020 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1021
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1022
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1023 #ifdef FEAT_EVAL
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1024 // reset did_emsg for a function that is not aborted by an error
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1025 if (did_emsg && !force_abort
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
1026 && getline_equal(fgetline, cookie, get_func_line)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1027 && !func_has_abort(real_cookie))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1028 did_emsg = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1029
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1030 if (cstack.cs_looplevel > 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1031 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1032 ++current_line;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1033
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1034 /*
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1035 * An ":endwhile", ":endfor" and ":continue" is handled here.
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1036 * If we were executing commands, jump back to the ":while" or
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1037 * ":for".
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1038 * If we were not executing commands, decrement cs_looplevel.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1039 */
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1040 if (cstack.cs_lflags & (CSL_HAD_CONT | CSL_HAD_ENDLOOP))
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1041 {
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1042 cstack.cs_lflags &= ~(CSL_HAD_CONT | CSL_HAD_ENDLOOP);
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1043
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1044 // Jump back to the matching ":while" or ":for". Be careful
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1045 // not to use a cs_line[] from an entry that isn't a ":while"
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1046 // or ":for": It would make "current_line" invalid and can
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1047 // cause a crash.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1048 if (!did_emsg && !got_int && !did_throw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1049 && cstack.cs_idx >= 0
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1050 && (cstack.cs_flags[cstack.cs_idx]
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1051 & (CSF_WHILE | CSF_FOR))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1052 && cstack.cs_line[cstack.cs_idx] >= 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1053 && (cstack.cs_flags[cstack.cs_idx] & CSF_ACTIVE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1054 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1055 current_line = cstack.cs_line[cstack.cs_idx];
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1056 // remember we jumped there
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1057 cstack.cs_lflags |= CSL_HAD_LOOP;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1058 line_breakcheck(); // check if CTRL-C typed
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1059
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1060 // Check for the next breakpoint at or after the ":while"
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1061 // or ":for".
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1062 if (breakpoint != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1063 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1064 *breakpoint = dbg_find_breakpoint(
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
1065 getline_equal(fgetline, cookie, getsourceline),
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1066 fname,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1067 ((wcmd_T *)lines_ga.ga_data)[current_line].lnum-1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1068 *dbg_tick = debug_tick;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1069 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1070 }
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1071 else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1072 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1073 // can only get here with ":endwhile" or ":endfor"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1074 if (cstack.cs_idx >= 0)
77
31e555c6c691 updated for version 7.0032
vimboss
parents: 72
diff changeset
1075 rewind_conditionals(&cstack, cstack.cs_idx - 1,
31e555c6c691 updated for version 7.0032
vimboss
parents: 72
diff changeset
1076 CSF_WHILE | CSF_FOR, &cstack.cs_looplevel);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1077 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1078 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1079
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1080 /*
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1081 * For a ":while" or ":for" we need to remember the line number.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1082 */
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1083 else if (cstack.cs_lflags & CSL_HAD_LOOP)
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1084 {
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1085 cstack.cs_lflags &= ~CSL_HAD_LOOP;
21056
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1086 cstack.cs_line[cstack.cs_idx] = current_line_before;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1087 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1088 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1089
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1090 // Check for the next breakpoint after a watchexpression
13262
69278c25429d patch 8.0.1505: debugger can't break on a condition
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
1091 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
1092 {
18991
847cc7932c42 patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents: 18904
diff changeset
1093 *breakpoint = dbg_find_breakpoint(FALSE, fname, SOURCING_LNUM);
13262
69278c25429d patch 8.0.1505: debugger can't break on a condition
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
1094 *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
1095 }
69278c25429d patch 8.0.1505: debugger can't break on a condition
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
1096
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1097 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1098 * When not inside any ":while" loop, clear remembered lines.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1099 */
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1100 if (cstack.cs_looplevel == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1101 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1102 if (lines_ga.ga_len > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1103 {
18991
847cc7932c42 patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents: 18904
diff changeset
1104 SOURCING_LNUM =
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1105 ((wcmd_T *)lines_ga.ga_data)[lines_ga.ga_len - 1].lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1106 free_cmdlines(&lines_ga);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1107 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1108 current_line = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1109 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1110
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1111 /*
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1112 * A ":finally" makes did_emsg, got_int, and did_throw pending for
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1113 * being restored at the ":endtry". Reset them here and set the
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1114 * ACTIVE and FINALLY flags, so that the finally clause gets executed.
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1115 * This includes the case where a missing ":endif", ":endwhile" or
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1116 * ":endfor" was detected by the ":finally" itself.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1117 */
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1118 if (cstack.cs_lflags & CSL_HAD_FINA)
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1119 {
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1120 cstack.cs_lflags &= ~CSL_HAD_FINA;
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1121 report_make_pending(cstack.cs_pending[cstack.cs_idx]
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1122 & (CSTP_ERROR | CSTP_INTERRUPT | CSTP_THROW),
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1123 did_throw ? (void *)current_exception : NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1124 did_emsg = got_int = did_throw = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1125 cstack.cs_flags[cstack.cs_idx] |= CSF_ACTIVE | CSF_FINALLY;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1126 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1127
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1128 // Update global "trylevel" for recursive calls to do_cmdline() from
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1129 // within this loop.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1130 trylevel = initial_trylevel + cstack.cs_trylevel;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1131
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1132 /*
1190
4e90dc161511 updated for version 7.1b
vimboss
parents: 1132
diff changeset
1133 * If the outermost try conditional (across function calls and sourced
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1134 * files) is aborted because of an error, an interrupt, or an uncaught
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1135 * exception, cancel everything. If it is left normally, reset
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1136 * force_abort to get the non-EH compatible abortion behavior for
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1137 * the rest of the script.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1138 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1139 if (trylevel == 0 && !did_emsg && !got_int && !did_throw)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1140 force_abort = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1141
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1142 // Convert an interrupt to an exception if appropriate.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1143 (void)do_intthrow(&cstack);
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1144 #endif // FEAT_EVAL
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1145
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1146 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1147 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1148 * Continue executing command lines when:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1149 * - no CTRL-C typed, no aborting error, no exception thrown or try
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1150 * conditionals need to be checked for executing finally clauses or
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1151 * catching an interrupt exception
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1152 * - didn't get an error message or lines are not typed
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1153 * - there is a command after '|', inside a :if, :while, :for or :try, or
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1154 * looping for ":source" command or function call.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1155 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1156 while (!((got_int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1157 #ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1158 || (did_emsg && force_abort) || did_throw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1159 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1160 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1161 #ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1162 && cstack.cs_trylevel == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1163 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1164 )
3757
3b62d8f36cdf updated for version 7.3.637
Bram Moolenaar <bram@vim.org>
parents: 3744
diff changeset
1165 && !(did_emsg
3b62d8f36cdf updated for version 7.3.637
Bram Moolenaar <bram@vim.org>
parents: 3744
diff changeset
1166 #ifdef FEAT_EVAL
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1167 // Keep going when inside try/catch, so that the error can be
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1168 // deal with, except when it is a syntax error, it may cause
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1169 // the :endtry to be missed.
3757
3b62d8f36cdf updated for version 7.3.637
Bram Moolenaar <bram@vim.org>
parents: 3744
diff changeset
1170 && (cstack.cs_trylevel == 0 || did_emsg_syntax)
3b62d8f36cdf updated for version 7.3.637
Bram Moolenaar <bram@vim.org>
parents: 3744
diff changeset
1171 #endif
3b62d8f36cdf updated for version 7.3.637
Bram Moolenaar <bram@vim.org>
parents: 3744
diff changeset
1172 && used_getline
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
1173 && (getline_equal(fgetline, cookie, getexmodeline)
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
1174 || getline_equal(fgetline, cookie, getexline)))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1175 && (next_cmdline != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1176 #ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1177 || cstack.cs_idx >= 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1178 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1179 || (flags & DOCMD_REPEAT)));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1180
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1181 vim_free(cmdline_copy);
3757
3b62d8f36cdf updated for version 7.3.637
Bram Moolenaar <bram@vim.org>
parents: 3744
diff changeset
1182 did_emsg_syntax = FALSE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1183 #ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1184 free_cmdlines(&lines_ga);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1185 ga_clear(&lines_ga);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1186
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1187 if (cstack.cs_idx >= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1188 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1189 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1190 * If a sourced file or executed function ran to its end, report the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1191 * unclosed conditional.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1192 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1193 if (!got_int && !did_throw
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
1194 && ((getline_equal(fgetline, cookie, getsourceline)
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
1195 && !source_finished(fgetline, cookie))
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
1196 || (getline_equal(fgetline, cookie, get_func_line)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1197 && !func_has_ended(real_cookie))))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1198 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1199 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
1200 emsg(_(e_endtry));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1201 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
1202 emsg(_(e_endwhile));
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1203 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
1204 emsg(_(e_endfor));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1205 else
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
1206 emsg(_(e_endif));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1207 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1208
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1209 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1210 * Reset "trylevel" in case of a ":finish" or ":return" or a missing
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1211 * ":endtry" in a sourced file or executed function. If the try
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1212 * conditional is in its finally clause, ignore anything pending.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1213 * If it is in a catch clause, finish the caught exception.
77
31e555c6c691 updated for version 7.0032
vimboss
parents: 72
diff changeset
1214 * Also cleanup any "cs_forinfo" structures.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1215 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1216 do
77
31e555c6c691 updated for version 7.0032
vimboss
parents: 72
diff changeset
1217 {
31e555c6c691 updated for version 7.0032
vimboss
parents: 72
diff changeset
1218 int idx = cleanup_conditionals(&cstack, 0, TRUE);
31e555c6c691 updated for version 7.0032
vimboss
parents: 72
diff changeset
1219
111
a3d7e800ddec updated for version 7.0041
vimboss
parents: 98
diff changeset
1220 if (idx >= 0)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1221 --idx; // remove try block not in its finally clause
77
31e555c6c691 updated for version 7.0032
vimboss
parents: 72
diff changeset
1222 rewind_conditionals(&cstack, idx, CSF_WHILE | CSF_FOR,
31e555c6c691 updated for version 7.0032
vimboss
parents: 72
diff changeset
1223 &cstack.cs_looplevel);
31e555c6c691 updated for version 7.0032
vimboss
parents: 72
diff changeset
1224 }
31e555c6c691 updated for version 7.0032
vimboss
parents: 72
diff changeset
1225 while (cstack.cs_idx >= 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1226 trylevel = initial_trylevel;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1227 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1228
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1229 // If a missing ":endtry", ":endwhile", ":endfor", or ":endif" or a memory
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1230 // lack was reported above and the error message is to be converted to an
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1231 // exception, do this now after rewinding the cstack.
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
1232 do_errthrow(&cstack, getline_equal(fgetline, cookie, get_func_line)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1233 ? (char_u *)"endfunction" : (char_u *)NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1234
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1235 if (trylevel == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1236 {
22543
1722ed01c729 patch 8.2.1820: Vim9: crash when error happens in timer callback
Bram Moolenaar <Bram@vim.org>
parents: 22442
diff changeset
1237 // Just in case did_throw got set but current_exception wasn't.
1722ed01c729 patch 8.2.1820: Vim9: crash when error happens in timer callback
Bram Moolenaar <Bram@vim.org>
parents: 22442
diff changeset
1238 if (current_exception == NULL)
1722ed01c729 patch 8.2.1820: Vim9: crash when error happens in timer callback
Bram Moolenaar <Bram@vim.org>
parents: 22442
diff changeset
1239 did_throw = FALSE;
1722ed01c729 patch 8.2.1820: Vim9: crash when error happens in timer callback
Bram Moolenaar <Bram@vim.org>
parents: 22442
diff changeset
1240
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1241 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1242 * When an exception is being thrown out of the outermost try
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1243 * conditional, discard the uncaught exception, disable the conversion
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1244 * of interrupts or errors to exceptions, and ensure that no more
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1245 * commands are executed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1246 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1247 if (did_throw)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1248 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1249 void *p = NULL;
20538
9f921ba86d05 patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents: 20536
diff changeset
1250 msglist_T *messages = NULL, *next;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1251
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1252 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1253 * If the uncaught exception is a user exception, report it as an
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1254 * error. If it is an error exception, display the saved error
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1255 * message now. For an interrupt exception, do nothing; the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1256 * interrupt message is given elsewhere.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1257 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1258 switch (current_exception->type)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1259 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1260 case ET_USER:
272
ddada568db54 updated for version 7.0073
vimboss
parents: 268
diff changeset
1261 vim_snprintf((char *)IObuff, IOSIZE,
ddada568db54 updated for version 7.0073
vimboss
parents: 268
diff changeset
1262 _("E605: Exception not caught: %s"),
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1263 current_exception->value);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1264 p = vim_strsave(IObuff);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1265 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1266 case ET_ERROR:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1267 messages = current_exception->messages;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1268 current_exception->messages = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1269 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1270 case ET_INTERRUPT:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1271 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1272 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1273
18991
847cc7932c42 patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents: 18904
diff changeset
1274 estack_push(ETYPE_EXCEPT, current_exception->throw_name,
847cc7932c42 patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents: 18904
diff changeset
1275 current_exception->throw_lnum);
19075
af1eca322b9e patch 8.2.0098: exe stack length can be wrong without being detected
Bram Moolenaar <Bram@vim.org>
parents: 19069
diff changeset
1276 ESTACK_CHECK_SETUP
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1277 current_exception->throw_name = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1278
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1279 discard_current_exception(); // uses IObuff if 'verbose'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1280 suppress_errthrow = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1281 force_abort = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1282
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1283 if (messages != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1284 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1285 do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1286 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1287 next = messages->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1288 emsg(messages->msg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1289 vim_free(messages->msg);
20659
3437bf2ce2d4 patch 8.2.0883: memory leak in test 49
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
1290 vim_free(messages->sfile);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1291 vim_free(messages);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1292 messages = next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1293 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1294 while (messages != NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1295 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1296 else if (p != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1297 {
15490
98c35d312987 patch 8.1.0753: printf format not checked for semsg()
Bram Moolenaar <Bram@vim.org>
parents: 15488
diff changeset
1298 emsg(p);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1299 vim_free(p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1300 }
18991
847cc7932c42 patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents: 18904
diff changeset
1301 vim_free(SOURCING_NAME);
19075
af1eca322b9e patch 8.2.0098: exe stack length can be wrong without being detected
Bram Moolenaar <Bram@vim.org>
parents: 19069
diff changeset
1302 ESTACK_CHECK_NOW
18991
847cc7932c42 patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents: 18904
diff changeset
1303 estack_pop();
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1304 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1305
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1306 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1307 * On an interrupt or an aborting error not converted to an exception,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1308 * disable the conversion of errors to exceptions. (Interrupts are not
20009
6eb3c91d9875 patch 8.2.0560: compiler warning in tiny build
Bram Moolenaar <Bram@vim.org>
parents: 20007
diff changeset
1309 * converted anymore, here.) This enables also the interrupt message
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1310 * when force_abort is set and did_emsg unset in case of an interrupt
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1311 * from a finally clause after an error.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1312 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1313 else if (got_int || (did_emsg && force_abort))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1314 suppress_errthrow = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1315 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1316
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1317 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1318 * The current cstack will be freed when do_cmdline() returns. An uncaught
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1319 * exception will have to be rethrown in the previous cstack. If a function
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1320 * has just returned or a script file was just finished and the previous
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1321 * cstack belongs to the same function or, respectively, script file, it
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1322 * will have to be checked for finally clauses to be executed due to the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1323 * ":return" or ":finish". This is done in do_one_cmd().
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1324 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1325 if (did_throw)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1326 need_rethrow = TRUE;
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
1327 if ((getline_equal(fgetline, cookie, getsourceline)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1328 && ex_nesting_level > source_level(real_cookie))
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
1329 || (getline_equal(fgetline, cookie, get_func_line)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1330 && ex_nesting_level > func_level(real_cookie) + 1))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1331 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1332 if (!did_throw)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1333 check_cstack = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1334 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1335 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1336 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1337 // When leaving a function, reduce nesting level.
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
1338 if (getline_equal(fgetline, cookie, get_func_line))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1339 --ex_nesting_level;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1340 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1341 * Go to debug mode when returning from a function in which we are
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1342 * single-stepping.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1343 */
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
1344 if ((getline_equal(fgetline, cookie, getsourceline)
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
1345 || getline_equal(fgetline, cookie, get_func_line))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1346 && ex_nesting_level + 1 <= debug_break_level)
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
1347 do_debug(getline_equal(fgetline, cookie, getsourceline)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1348 ? (char_u *)_("End of sourced file")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1349 : (char_u *)_("End of function"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1350 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1351
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1352 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1353 * Restore the exception environment (done after returning from the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1354 * debugger).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1355 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1356 if (flags & DOCMD_EXCRESET)
8
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
1357 restore_dbg_stuff(&debug_saved);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1358
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1359 msg_list = saved_msg_list;
19685
d64f403289db patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents: 19621
diff changeset
1360
d64f403289db patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents: 19621
diff changeset
1361 // Cleanup if "cs_emsg_silent_list" remains.
d64f403289db patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents: 19621
diff changeset
1362 if (cstack.cs_emsg_silent_list != NULL)
d64f403289db patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents: 19621
diff changeset
1363 {
d64f403289db patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents: 19621
diff changeset
1364 eslist_T *elem, *temp;
d64f403289db patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents: 19621
diff changeset
1365
d64f403289db patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents: 19621
diff changeset
1366 for (elem = cstack.cs_emsg_silent_list; elem != NULL; elem = temp)
d64f403289db patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents: 19621
diff changeset
1367 {
d64f403289db patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents: 19621
diff changeset
1368 temp = elem->next;
d64f403289db patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents: 19621
diff changeset
1369 vim_free(elem);
d64f403289db patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents: 19621
diff changeset
1370 }
d64f403289db patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents: 19621
diff changeset
1371 }
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1372 #endif // FEAT_EVAL
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1373
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1374 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1375 * If there was too much output to fit on the command line, ask the user to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1376 * hit return before redrawing the screen. With the ":global" command we do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1377 * this only once after the command is finished.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1378 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1379 if (did_inc)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1380 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1381 --RedrawingDisabled;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1382 --no_wait_return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1383 msg_scroll = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1384
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1385 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1386 * When just finished an ":if"-":else" which was typed, no need to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1387 * wait for hit-return. Also for an error situation.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1388 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1389 if (retval == FAIL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1390 #ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1391 || (did_endif && KeyTyped && !did_emsg)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1392 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1393 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1394 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1395 need_wait_return = FALSE;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1396 msg_didany = FALSE; // don't wait when restarting edit
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1397 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1398 else if (need_wait_return)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1399 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1400 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1401 * The msg_start() above clears msg_didout. The wait_return we do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1402 * here should not overwrite the command that may be shown before
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1403 * doing that.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1404 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1405 msg_didout |= msg_didout_before_start;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1406 wait_return(FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1407 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1408 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1409
3976
67e3b2753a6e updated for version 7.3.743
Bram Moolenaar <bram@vim.org>
parents: 3972
diff changeset
1410 #ifdef FEAT_EVAL
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1411 did_endif = FALSE; // in case do_cmdline used recursively
3976
67e3b2753a6e updated for version 7.3.743
Bram Moolenaar <bram@vim.org>
parents: 3972
diff changeset
1412 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1413 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1414 * Reset if_level, in case a sourced script file contains more ":if" than
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1415 * ":endif" (could be ":if x | foo | endif").
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1416 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1417 if_level = 0;
3972
6e1fe64cf440 updated for version 7.3.741
Bram Moolenaar <bram@vim.org>
parents: 3963
diff changeset
1418 #endif
3963
1773d5aa6437 updated for version 7.3.737
Bram Moolenaar <bram@vim.org>
parents: 3839
diff changeset
1419
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1420 --call_depth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1421 return retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1422 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1423
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1424 #ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1425 /*
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1426 * Obtain a line when inside a ":while" or ":for" loop.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1427 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1428 static char_u *
21885
72525eabfe61 patch 8.2.1492: build failures
Bram Moolenaar <Bram@vim.org>
parents: 21883
diff changeset
1429 get_loop_line(int c, void *cookie, int indent, getline_opt_T options)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1430 {
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1431 struct loop_cookie *cp = (struct loop_cookie *)cookie;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1432 wcmd_T *wp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1433 char_u *line;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1434
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1435 if (cp->current_line + 1 >= cp->lines_gap->ga_len)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1436 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1437 if (cp->repeating)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1438 return NULL; // trying to read past ":endwhile"/":endfor"
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1439
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1440 // First time inside the ":while"/":for": get line normally.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1441 if (cp->getline == NULL)
21885
72525eabfe61 patch 8.2.1492: build failures
Bram Moolenaar <Bram@vim.org>
parents: 21883
diff changeset
1442 line = getcmdline(c, 0L, indent, options);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1443 else
21885
72525eabfe61 patch 8.2.1492: build failures
Bram Moolenaar <Bram@vim.org>
parents: 21883
diff changeset
1444 line = cp->getline(c, cp->cookie, indent, options);
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
1445 if (line != NULL && store_loop_line(cp->lines_gap, line) == OK)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1446 ++cp->current_line;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1447
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1448 return line;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1449 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1450
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1451 KeyTyped = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1452 ++cp->current_line;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1453 wp = (wcmd_T *)(cp->lines_gap->ga_data) + cp->current_line;
18991
847cc7932c42 patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents: 18904
diff changeset
1454 SOURCING_LNUM = wp->lnum;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1455 return vim_strsave(wp->line);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1456 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1457
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1458 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1459 * Store a line in "gap" so that a ":while" loop can execute it again.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1460 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1461 static int
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
1462 store_loop_line(garray_T *gap, char_u *line)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1463 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1464 if (ga_grow(gap, 1) == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1465 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1466 ((wcmd_T *)(gap->ga_data))[gap->ga_len].line = vim_strsave(line);
18991
847cc7932c42 patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents: 18904
diff changeset
1467 ((wcmd_T *)(gap->ga_data))[gap->ga_len].lnum = SOURCING_LNUM;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1468 ++gap->ga_len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1469 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1470 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1471
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1472 /*
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1473 * Free the lines stored for a ":while" or ":for" loop.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1474 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1475 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
1476 free_cmdlines(garray_T *gap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1477 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1478 while (gap->ga_len > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1479 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1480 vim_free(((wcmd_T *)(gap->ga_data))[gap->ga_len - 1].line);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1481 --gap->ga_len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1482 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1483 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1484 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1485
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1486 /*
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 930
diff changeset
1487 * If "fgetline" is get_loop_line(), return TRUE if the getline it uses equals
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 930
diff changeset
1488 * "func". * Otherwise return TRUE when "fgetline" equals "func".
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1489 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1490 int
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
1491 getline_equal(
21883
a427f5f26419 patch 8.2.1491: Vim9: crash when compiling heredoc lines start with comment
Bram Moolenaar <Bram@vim.org>
parents: 21845
diff changeset
1492 char_u *(*fgetline)(int, void *, int, getline_opt_T),
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1493 void *cookie UNUSED, // argument for fgetline()
21883
a427f5f26419 patch 8.2.1491: Vim9: crash when compiling heredoc lines start with comment
Bram Moolenaar <Bram@vim.org>
parents: 21845
diff changeset
1494 char_u *(*func)(int, void *, int, getline_opt_T))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1495 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1496 #ifdef FEAT_EVAL
21885
72525eabfe61 patch 8.2.1492: build failures
Bram Moolenaar <Bram@vim.org>
parents: 21883
diff changeset
1497 char_u *(*gp)(int, void *, int, getline_opt_T);
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1498 struct loop_cookie *cp;
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1499
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1500 // When "fgetline" is "get_loop_line()" use the "cookie" to find the
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1501 // function that's originally used to obtain the lines. This may be
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1502 // nested several levels.
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 930
diff changeset
1503 gp = fgetline;
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1504 cp = (struct loop_cookie *)cookie;
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1505 while (gp == get_loop_line)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1506 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1507 gp = cp->getline;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1508 cp = cp->cookie;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1509 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1510 return gp == func;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1511 #else
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 930
diff changeset
1512 return fgetline == func;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1513 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1514 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1515
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1516 /*
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 930
diff changeset
1517 * If "fgetline" is get_loop_line(), return the cookie used by the original
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1518 * getline function. Otherwise return "cookie".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1519 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1520 void *
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
1521 getline_cookie(
21883
a427f5f26419 patch 8.2.1491: Vim9: crash when compiling heredoc lines start with comment
Bram Moolenaar <Bram@vim.org>
parents: 21845
diff changeset
1522 char_u *(*fgetline)(int, void *, int, getline_opt_T) UNUSED,
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1523 void *cookie) // argument for fgetline()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1524 {
15595
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15591
diff changeset
1525 #ifdef FEAT_EVAL
21885
72525eabfe61 patch 8.2.1492: build failures
Bram Moolenaar <Bram@vim.org>
parents: 21883
diff changeset
1526 char_u *(*gp)(int, void *, int, getline_opt_T);
21056
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1527 struct loop_cookie *cp;
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1528
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1529 // When "fgetline" is "get_loop_line()" use the "cookie" to find the
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1530 // cookie that's originally used to obtain the lines. This may be nested
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1531 // several levels.
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 930
diff changeset
1532 gp = fgetline;
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1533 cp = (struct loop_cookie *)cookie;
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1534 while (gp == get_loop_line)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1535 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1536 gp = cp->getline;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1537 cp = cp->cookie;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1538 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1539 return cp;
15595
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15591
diff changeset
1540 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1541 return cookie;
15595
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15591
diff changeset
1542 #endif
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15591
diff changeset
1543 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1544
21056
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1545 #if defined(FEAT_EVAL) || defined(PROT)
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1546 /*
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1547 * Get the next line source line without advancing.
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1548 */
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1549 char_u *
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1550 getline_peek(
21883
a427f5f26419 patch 8.2.1491: Vim9: crash when compiling heredoc lines start with comment
Bram Moolenaar <Bram@vim.org>
parents: 21845
diff changeset
1551 char_u *(*fgetline)(int, void *, int, getline_opt_T) UNUSED,
21056
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1552 void *cookie) // argument for fgetline()
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1553 {
21885
72525eabfe61 patch 8.2.1492: build failures
Bram Moolenaar <Bram@vim.org>
parents: 21883
diff changeset
1554 char_u *(*gp)(int, void *, int, getline_opt_T);
21056
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1555 struct loop_cookie *cp;
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1556 wcmd_T *wp;
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1557
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1558 // When "fgetline" is "get_loop_line()" use the "cookie" to find the
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1559 // cookie that's originally used to obtain the lines. This may be nested
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1560 // several levels.
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1561 gp = fgetline;
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1562 cp = (struct loop_cookie *)cookie;
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1563 while (gp == get_loop_line)
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1564 {
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1565 if (cp->current_line + 1 < cp->lines_gap->ga_len)
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1566 {
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1567 // executing lines a second time, use the stored copy
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1568 wp = (wcmd_T *)(cp->lines_gap->ga_data) + cp->current_line + 1;
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1569 return wp->line;
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1570 }
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1571 gp = cp->getline;
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1572 cp = cp->cookie;
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1573 }
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1574 if (gp == getsourceline)
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1575 return source_nextline(cp);
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1576 return NULL;
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1577 }
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1578 #endif
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1579
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1580
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1581 /*
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1582 * Helper function to apply an offset for buffer commands, i.e. ":bdelete",
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1583 * ":bwipeout", etc.
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1584 * Returns the buffer number.
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1585 */
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1586 static int
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
1587 compute_buffer_local_count(int addr_type, int lnum, int offset)
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1588 {
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1589 buf_T *buf;
6417
77fe94082f53 updated for version 7.4.539
Bram Moolenaar <bram@vim.org>
parents: 6409
diff changeset
1590 buf_T *nextbuf;
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1591 int count = offset;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1592
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1593 buf = firstbuf;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1594 while (buf->b_next != NULL && buf->b_fnum < lnum)
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1595 buf = buf->b_next;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1596 while (count != 0)
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1597 {
6417
77fe94082f53 updated for version 7.4.539
Bram Moolenaar <bram@vim.org>
parents: 6409
diff changeset
1598 count += (offset < 0) ? 1 : -1;
77fe94082f53 updated for version 7.4.539
Bram Moolenaar <bram@vim.org>
parents: 6409
diff changeset
1599 nextbuf = (offset < 0) ? buf->b_prev : buf->b_next;
77fe94082f53 updated for version 7.4.539
Bram Moolenaar <bram@vim.org>
parents: 6409
diff changeset
1600 if (nextbuf == NULL)
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1601 break;
6417
77fe94082f53 updated for version 7.4.539
Bram Moolenaar <bram@vim.org>
parents: 6409
diff changeset
1602 buf = nextbuf;
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1603 if (addr_type == ADDR_LOADED_BUFFERS)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1604 // skip over unloaded buffers
6417
77fe94082f53 updated for version 7.4.539
Bram Moolenaar <bram@vim.org>
parents: 6409
diff changeset
1605 while (buf->b_ml.ml_mfp == NULL)
77fe94082f53 updated for version 7.4.539
Bram Moolenaar <bram@vim.org>
parents: 6409
diff changeset
1606 {
77fe94082f53 updated for version 7.4.539
Bram Moolenaar <bram@vim.org>
parents: 6409
diff changeset
1607 nextbuf = (offset < 0) ? buf->b_prev : buf->b_next;
77fe94082f53 updated for version 7.4.539
Bram Moolenaar <bram@vim.org>
parents: 6409
diff changeset
1608 if (nextbuf == NULL)
77fe94082f53 updated for version 7.4.539
Bram Moolenaar <bram@vim.org>
parents: 6409
diff changeset
1609 break;
77fe94082f53 updated for version 7.4.539
Bram Moolenaar <bram@vim.org>
parents: 6409
diff changeset
1610 buf = nextbuf;
77fe94082f53 updated for version 7.4.539
Bram Moolenaar <bram@vim.org>
parents: 6409
diff changeset
1611 }
77fe94082f53 updated for version 7.4.539
Bram Moolenaar <bram@vim.org>
parents: 6409
diff changeset
1612 }
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1613 // we might have gone too far, last buffer is not loadedd
6417
77fe94082f53 updated for version 7.4.539
Bram Moolenaar <bram@vim.org>
parents: 6409
diff changeset
1614 if (addr_type == ADDR_LOADED_BUFFERS)
77fe94082f53 updated for version 7.4.539
Bram Moolenaar <bram@vim.org>
parents: 6409
diff changeset
1615 while (buf->b_ml.ml_mfp == NULL)
77fe94082f53 updated for version 7.4.539
Bram Moolenaar <bram@vim.org>
parents: 6409
diff changeset
1616 {
77fe94082f53 updated for version 7.4.539
Bram Moolenaar <bram@vim.org>
parents: 6409
diff changeset
1617 nextbuf = (offset >= 0) ? buf->b_prev : buf->b_next;
77fe94082f53 updated for version 7.4.539
Bram Moolenaar <bram@vim.org>
parents: 6409
diff changeset
1618 if (nextbuf == NULL)
77fe94082f53 updated for version 7.4.539
Bram Moolenaar <bram@vim.org>
parents: 6409
diff changeset
1619 break;
77fe94082f53 updated for version 7.4.539
Bram Moolenaar <bram@vim.org>
parents: 6409
diff changeset
1620 buf = nextbuf;
77fe94082f53 updated for version 7.4.539
Bram Moolenaar <bram@vim.org>
parents: 6409
diff changeset
1621 }
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1622 return buf->b_fnum;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1623 }
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1624
16475
854fb0ad4be6 patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents: 16451
diff changeset
1625 /*
854fb0ad4be6 patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents: 16451
diff changeset
1626 * 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
1627 * 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
1628 */
6409
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1629 static int
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
1630 current_win_nr(win_T *win)
6409
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1631 {
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1632 win_T *wp;
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1633 int nr = 0;
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1634
9649
fd9727ae3c49 commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents: 9538
diff changeset
1635 FOR_ALL_WINDOWS(wp)
6409
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1636 {
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1637 ++nr;
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1638 if (wp == win)
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1639 break;
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1640 }
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1641 return nr;
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1642 }
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1643
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1644 static int
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
1645 current_tab_nr(tabpage_T *tab)
6409
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1646 {
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1647 tabpage_T *tp;
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1648 int nr = 0;
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1649
9649
fd9727ae3c49 commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents: 9538
diff changeset
1650 FOR_ALL_TABPAGES(tp)
6409
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1651 {
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1652 ++nr;
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1653 if (tp == tab)
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1654 break;
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1655 }
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1656 return nr;
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1657 }
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1658
21357
72bf1b368cfe patch 8.2.1229: build error without the eval feature
Bram Moolenaar <Bram@vim.org>
parents: 21353
diff changeset
1659 static int
21353
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
1660 comment_start(char_u *p, int starts_with_colon UNUSED)
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
1661 {
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
1662 #ifdef FEAT_EVAL
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
1663 if (in_vim9script())
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
1664 return p[0] == '#' && p[1] != '{' && !starts_with_colon;
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
1665 #endif
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
1666 return *p == '"';
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
1667 }
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
1668
6409
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1669 # define CURRENT_WIN_NR current_win_nr(curwin)
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1670 # define LAST_WIN_NR current_win_nr(NULL)
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1671 # define CURRENT_TAB_NR current_tab_nr(curtab)
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1672 # define LAST_TAB_NR current_tab_nr(NULL)
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1673
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1674 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1675 * Execute one Ex command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1676 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1677 * If 'sourcing' is TRUE, the command will be included in the error message.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1678 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1679 * 1. skip comment lines and leading space
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1680 * 2. handle command modifiers
6400
2c0cddd0df8c updated for version 7.4.531
Bram Moolenaar <bram@vim.org>
parents: 6398
diff changeset
1681 * 3. find the command
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1682 * 4. parse range
6400
2c0cddd0df8c updated for version 7.4.531
Bram Moolenaar <bram@vim.org>
parents: 6398
diff changeset
1683 * 5. Parse the command.
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1684 * 6. parse arguments
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1685 * 7. switch on command name
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1686 *
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 930
diff changeset
1687 * Note: "fgetline" can be NULL.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1688 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1689 * This function may be called recursively!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1690 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1691 #if (_MSC_VER == 1200)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1692 /*
8
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
1693 * Avoid optimisation bug in VC++ version 6.0
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1694 */
128
8def260d486d updated for version 7.0044
vimboss
parents: 122
diff changeset
1695 #pragma optimize( "g", off )
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1696 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1697 static char_u *
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
1698 do_one_cmd(
18904
2bdc2e1f6e1f patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents: 18849
diff changeset
1699 char_u **cmdlinep,
2bdc2e1f6e1f patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents: 18849
diff changeset
1700 int sourcing,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1701 #ifdef FEAT_EVAL
18904
2bdc2e1f6e1f patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents: 18849
diff changeset
1702 cstack_T *cstack,
2bdc2e1f6e1f patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents: 18849
diff changeset
1703 #endif
21885
72525eabfe61 patch 8.2.1492: build failures
Bram Moolenaar <Bram@vim.org>
parents: 21883
diff changeset
1704 char_u *(*fgetline)(int, void *, int, getline_opt_T),
18904
2bdc2e1f6e1f patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents: 18849
diff changeset
1705 void *cookie) // argument for fgetline()
2bdc2e1f6e1f patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents: 18849
diff changeset
1706 {
2bdc2e1f6e1f patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents: 18849
diff changeset
1707 char_u *p;
2bdc2e1f6e1f patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents: 18849
diff changeset
1708 linenr_T lnum;
2bdc2e1f6e1f patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents: 18849
diff changeset
1709 long n;
2bdc2e1f6e1f patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents: 18849
diff changeset
1710 char *errormsg = NULL; // error message
2bdc2e1f6e1f patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents: 18849
diff changeset
1711 char_u *after_modifier = NULL;
2bdc2e1f6e1f patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents: 18849
diff changeset
1712 exarg_T ea; // Ex command arguments
2bdc2e1f6e1f patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents: 18849
diff changeset
1713 int save_msg_scroll = msg_scroll;
2bdc2e1f6e1f patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents: 18849
diff changeset
1714 cmdmod_T save_cmdmod;
2bdc2e1f6e1f patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents: 18849
diff changeset
1715 int save_reg_executing = reg_executing;
2bdc2e1f6e1f patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents: 18849
diff changeset
1716 int ni; // set when Not Implemented
2bdc2e1f6e1f patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents: 18849
diff changeset
1717 char_u *cmd;
21357
72bf1b368cfe patch 8.2.1229: build error without the eval feature
Bram Moolenaar <Bram@vim.org>
parents: 21353
diff changeset
1718 int starts_with_colon = FALSE;
19497
639b1d672757 patch 8.2.0306: Vim9: :substitute(pat(repl does not work in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19481
diff changeset
1719 #ifdef FEAT_EVAL
21526
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
1720 int may_have_range;
21335
af3663df42bf patch 8.2.1218: Vim9: cannot use 'text'->func()
Bram Moolenaar <Bram@vim.org>
parents: 21279
diff changeset
1721 int vim9script = in_vim9script();
19497
639b1d672757 patch 8.2.0306: Vim9: :substitute(pat(repl does not work in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19481
diff changeset
1722 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1723
20007
aadd1cae2ff5 patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents: 19892
diff changeset
1724 CLEAR_FIELD(ea);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1725 ea.line1 = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1726 ea.line2 = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1727 #ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1728 ++ex_nesting_level;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1729 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1730
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1731 // When the last file has not been edited :q has to be typed twice.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1732 if (quitmore
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1733 #ifdef FEAT_EVAL
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1734 // avoid that a function call in 'statusline' does this
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 930
diff changeset
1735 && !getline_equal(fgetline, cookie, get_func_line)
4133
36fd800b8c6c updated for version 7.3.819
Bram Moolenaar <bram@vim.org>
parents: 3997
diff changeset
1736 #endif
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1737 // 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
1738 && !getline_equal(fgetline, cookie, getnextac))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1739 --quitmore;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1740
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1741 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1742 * Reset browse, confirm, etc.. They are restored when returning, for
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1743 * recursive calls.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1744 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1745 save_cmdmod = cmdmod;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1746
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1747 // "#!anything" is handled like a comment.
930
529c6a431ff5 updated for version 7.0-056
vimboss
parents: 878
diff changeset
1748 if ((*cmdlinep)[0] == '#' && (*cmdlinep)[1] == '!')
529c6a431ff5 updated for version 7.0-056
vimboss
parents: 878
diff changeset
1749 goto doend;
529c6a431ff5 updated for version 7.0-056
vimboss
parents: 878
diff changeset
1750
14538
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
1751 /*
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
1752 * 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
1753 * 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
1754 */
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
1755 // The "ea" structure holds the arguments that can be used.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1756 ea.cmd = *cmdlinep;
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
1757 ea.cmdlinep = cmdlinep;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
1758 ea.getline = fgetline;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
1759 ea.cookie = cookie;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
1760 #ifdef FEAT_EVAL
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
1761 ea.cstack = cstack;
19497
639b1d672757 patch 8.2.0306: Vim9: :substitute(pat(repl does not work in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19481
diff changeset
1762 starts_with_colon = *skipwhite(ea.cmd) == ':';
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
1763 #endif
14538
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
1764 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
1765 goto doend;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
1766
9941
e975914c17e9 commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents: 9927
diff changeset
1767 after_modifier = ea.cmd;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1768
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1769 #ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1770 ea.skip = did_emsg || got_int || did_throw || (cstack->cs_idx >= 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1771 && !(cstack->cs_flags[cstack->cs_idx] & CSF_ACTIVE));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1772 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1773 ea.skip = (if_level > 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1774 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1775
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1776 /*
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1777 * 3. Skip over the range to find the command. Let "p" point to after it.
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1778 *
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1779 * We need the command to know what kind of range it uses.
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1780 */
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1781 cmd = ea.cmd;
21335
af3663df42bf patch 8.2.1218: Vim9: cannot use 'text'->func()
Bram Moolenaar <Bram@vim.org>
parents: 21279
diff changeset
1782 #ifdef FEAT_EVAL
21526
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
1783 // In Vim9 script a colon is required before the range.
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
1784 may_have_range = !vim9script || starts_with_colon;
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
1785 if (may_have_range)
21335
af3663df42bf patch 8.2.1218: Vim9: cannot use 'text'->func()
Bram Moolenaar <Bram@vim.org>
parents: 21279
diff changeset
1786 #endif
22260
d7c1e3efa88e patch 8.2.1679: Vim9: ":*" is not recognized as a range
Bram Moolenaar <Bram@vim.org>
parents: 22208
diff changeset
1787 ea.cmd = skip_range(ea.cmd, TRUE, NULL);
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
1788
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
1789 #ifdef FEAT_EVAL
21335
af3663df42bf patch 8.2.1218: Vim9: cannot use 'text'->func()
Bram Moolenaar <Bram@vim.org>
parents: 21279
diff changeset
1790 if (vim9script && !starts_with_colon)
20982
bb49b5090a9c patch 8.2.1042: Vim9: cannot put an operator on the next line
Bram Moolenaar <Bram@vim.org>
parents: 20897
diff changeset
1791 {
21526
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
1792 if (ea.cmd == cmd + 1 && *cmd == '$')
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
1793 // should be "$VAR = val"
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
1794 --ea.cmd;
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
1795 else if (ea.cmd > cmd)
20982
bb49b5090a9c patch 8.2.1042: Vim9: cannot put an operator on the next line
Bram Moolenaar <Bram@vim.org>
parents: 20897
diff changeset
1796 {
21789
f84625b961a8 patch 8.2.1444: error messages are spread out and names can be confusing
Bram Moolenaar <Bram@vim.org>
parents: 21773
diff changeset
1797 emsg(_(e_colon_required_before_a_range));
20982
bb49b5090a9c patch 8.2.1042: Vim9: cannot put an operator on the next line
Bram Moolenaar <Bram@vim.org>
parents: 20897
diff changeset
1798 goto doend;
bb49b5090a9c patch 8.2.1042: Vim9: cannot put an operator on the next line
Bram Moolenaar <Bram@vim.org>
parents: 20897
diff changeset
1799 }
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
1800 p = find_ex_command(&ea, NULL, lookup_scriptvar, NULL);
20982
bb49b5090a9c patch 8.2.1042: Vim9: cannot put an operator on the next line
Bram Moolenaar <Bram@vim.org>
parents: 20897
diff changeset
1801 }
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
1802 else
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
1803 #endif
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
1804 p = find_ex_command(&ea, NULL, NULL, NULL);
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1805
14591
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1806 #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
1807 # 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
1808 // 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
1809 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
1810 && (!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
1811 && (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
1812 {
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1813 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
1814
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1815 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
1816 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
1817 && (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
1818 && !(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
1819 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
1820 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
1821 && !(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
1822 & (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
1823 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
1824 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
1825 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
1826 && 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
1827 && 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
1828 && 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
1829 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
1830
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1831 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
1832 {
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1833 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
1834 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
1835 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
1836 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
1837 }
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1838 }
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1839 # endif
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1840
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1841 // May go to debug mode. If this happens and the ">quit" debug command is
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1842 // used, throw an interrupt exception and skip the next command.
14591
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1843 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
1844 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
1845 {
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1846 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
1847 (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
1848 }
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1849 #endif
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1850
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1851 /*
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1852 * 4. parse a range specifier of the form: addr [,addr] [;addr] ..
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1853 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1854 * where 'addr' is:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1855 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1856 * % (entire file)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1857 * $ [+-NUM]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1858 * 'x [+-NUM] (where x denotes a currently defined mark)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1859 * . [+-NUM]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1860 * [+-NUM]..
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1861 * NUM
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1862 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1863 * The ea.cmd pointer is updated to point to the first character following the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1864 * range spec. If an initial address is found, but no second, the upper bound
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1865 * is equal to the lower.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1866 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1867
16515
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
1868 // ea.addr_type for user commands is set by find_ucmd
6489
cba15023c403 updated for version 7.4.572
Bram Moolenaar <bram@vim.org>
parents: 6480
diff changeset
1869 if (!IS_USER_CMDIDX(ea.cmdidx))
cba15023c403 updated for version 7.4.572
Bram Moolenaar <bram@vim.org>
parents: 6480
diff changeset
1870 {
cba15023c403 updated for version 7.4.572
Bram Moolenaar <bram@vim.org>
parents: 6480
diff changeset
1871 if (ea.cmdidx != CMD_SIZE)
cba15023c403 updated for version 7.4.572
Bram Moolenaar <bram@vim.org>
parents: 6480
diff changeset
1872 ea.addr_type = cmdnames[(int)ea.cmdidx].cmd_addr_type;
cba15023c403 updated for version 7.4.572
Bram Moolenaar <bram@vim.org>
parents: 6480
diff changeset
1873 else
cba15023c403 updated for version 7.4.572
Bram Moolenaar <bram@vim.org>
parents: 6480
diff changeset
1874 ea.addr_type = ADDR_LINES;
cba15023c403 updated for version 7.4.572
Bram Moolenaar <bram@vim.org>
parents: 6480
diff changeset
1875
16515
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
1876 // :wincmd range depends on the argument.
6506
a5a6f1467b1e updated for version 7.4.580
Bram Moolenaar <bram@vim.org>
parents: 6489
diff changeset
1877 if (ea.cmdidx == CMD_wincmd && p != NULL)
a5a6f1467b1e updated for version 7.4.580
Bram Moolenaar <bram@vim.org>
parents: 6489
diff changeset
1878 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
1879 #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
1880 // :.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
1881 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
1882 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
1883 #endif
6489
cba15023c403 updated for version 7.4.572
Bram Moolenaar <bram@vim.org>
parents: 6480
diff changeset
1884 }
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1885
6489
cba15023c403 updated for version 7.4.572
Bram Moolenaar <bram@vim.org>
parents: 6480
diff changeset
1886 ea.cmd = cmd;
21335
af3663df42bf patch 8.2.1218: Vim9: cannot use 'text'->func()
Bram Moolenaar <Bram@vim.org>
parents: 21279
diff changeset
1887 #ifdef FEAT_EVAL
21939
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
1888 if (!may_have_range)
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
1889 ea.line1 = ea.line2 = default_address(&ea);
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
1890 else
21335
af3663df42bf patch 8.2.1218: Vim9: cannot use 'text'->func()
Bram Moolenaar <Bram@vim.org>
parents: 21279
diff changeset
1891 #endif
af3663df42bf patch 8.2.1218: Vim9: cannot use 'text'->func()
Bram Moolenaar <Bram@vim.org>
parents: 21279
diff changeset
1892 if (parse_cmd_address(&ea, &errormsg, FALSE) == FAIL)
af3663df42bf patch 8.2.1218: Vim9: cannot use 'text'->func()
Bram Moolenaar <Bram@vim.org>
parents: 21279
diff changeset
1893 goto doend;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1894
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1895 /*
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1896 * 5. Parse the command.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1897 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1898
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1899 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1900 * Skip ':' and any white space
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1901 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1902 ea.cmd = skipwhite(ea.cmd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1903 while (*ea.cmd == ':')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1904 ea.cmd = skipwhite(ea.cmd + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1905
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1906 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1907 * If we got a line, but no command, then go to the line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1908 * If we find a '|' or '\n' we set ea.nextcmd.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1909 */
21353
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
1910 if (*ea.cmd == NUL || comment_start(ea.cmd, starts_with_colon)
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
1911 || (ea.nextcmd = check_nextcmd(ea.cmd)) != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1912 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1913 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1914 * strange vi behaviour:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1915 * ":3" jumps to line 3
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1916 * ":3|..." prints line 3
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1917 * ":|" prints current line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1918 */
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1919 if (ea.skip) // skip this if inside :if
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1920 goto doend;
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
1921 if (*ea.cmd == '|' || (exmode_active && ea.line1 != ea.line2))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1922 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1923 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
1924 ea.argt = EX_RANGE+EX_COUNT+EX_TRLBAR;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1925 if ((errormsg = invalid_range(&ea)) == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1926 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1927 correct_range(&ea);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1928 ex_print(&ea);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1929 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1930 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1931 else if (ea.addr_count != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1932 {
631
68a196b7504d updated for version 7.0182
vimboss
parents: 625
diff changeset
1933 if (ea.line2 > curbuf->b_ml.ml_line_count)
68a196b7504d updated for version 7.0182
vimboss
parents: 625
diff changeset
1934 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1935 // With '-' in 'cpoptions' a line number past the file is an
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1936 // error, otherwise put it at the end of the file.
631
68a196b7504d updated for version 7.0182
vimboss
parents: 625
diff changeset
1937 if (vim_strchr(p_cpo, CPO_MINUS) != NULL)
68a196b7504d updated for version 7.0182
vimboss
parents: 625
diff changeset
1938 ea.line2 = -1;
68a196b7504d updated for version 7.0182
vimboss
parents: 625
diff changeset
1939 else
68a196b7504d updated for version 7.0182
vimboss
parents: 625
diff changeset
1940 ea.line2 = curbuf->b_ml.ml_line_count;
68a196b7504d updated for version 7.0182
vimboss
parents: 625
diff changeset
1941 }
68a196b7504d updated for version 7.0182
vimboss
parents: 625
diff changeset
1942
68a196b7504d updated for version 7.0182
vimboss
parents: 625
diff changeset
1943 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
1944 errormsg = _(e_invrange);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1945 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1946 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1947 if (ea.line2 == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1948 curwin->w_cursor.lnum = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1949 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1950 curwin->w_cursor.lnum = ea.line2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1951 beginline(BL_SOL | BL_FIX);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1952 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1953 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1954 goto doend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1955 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1956
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1957 // If this looks like an undefined user command and there are CmdUndefined
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1958 // autocommands defined, trigger the matching autocommands.
6154
67edf731a240 updated for version 7.4.414
Bram Moolenaar <bram@vim.org>
parents: 6122
diff changeset
1959 if (p != NULL && ea.cmdidx == CMD_SIZE && !ea.skip
67edf731a240 updated for version 7.4.414
Bram Moolenaar <bram@vim.org>
parents: 6122
diff changeset
1960 && ASCII_ISUPPER(*ea.cmd)
67edf731a240 updated for version 7.4.414
Bram Moolenaar <bram@vim.org>
parents: 6122
diff changeset
1961 && has_cmdundefined())
67edf731a240 updated for version 7.4.414
Bram Moolenaar <bram@vim.org>
parents: 6122
diff changeset
1962 {
67edf731a240 updated for version 7.4.414
Bram Moolenaar <bram@vim.org>
parents: 6122
diff changeset
1963 int ret;
67edf731a240 updated for version 7.4.414
Bram Moolenaar <bram@vim.org>
parents: 6122
diff changeset
1964
6156
20dbceb6f471 updated for version 7.4.415
Bram Moolenaar <bram@vim.org>
parents: 6154
diff changeset
1965 p = ea.cmd;
6154
67edf731a240 updated for version 7.4.414
Bram Moolenaar <bram@vim.org>
parents: 6122
diff changeset
1966 while (ASCII_ISALNUM(*p))
67edf731a240 updated for version 7.4.414
Bram Moolenaar <bram@vim.org>
parents: 6122
diff changeset
1967 ++p;
20897
213fb059e02e patch 8.2.1000: get error when leaving Ex mode with :visual
Bram Moolenaar <Bram@vim.org>
parents: 20711
diff changeset
1968 p = vim_strnsave(ea.cmd, p - ea.cmd);
6154
67edf731a240 updated for version 7.4.414
Bram Moolenaar <bram@vim.org>
parents: 6122
diff changeset
1969 ret = apply_autocmds(EVENT_CMDUNDEFINED, p, p, TRUE, NULL);
67edf731a240 updated for version 7.4.414
Bram Moolenaar <bram@vim.org>
parents: 6122
diff changeset
1970 vim_free(p);
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1971 // If the autocommands did something and didn't cause an error, try
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1972 // finding the command again.
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13288
diff changeset
1973 p = (ret
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13288
diff changeset
1974 #ifdef FEAT_EVAL
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13288
diff changeset
1975 && !aborting()
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13288
diff changeset
1976 #endif
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
1977 ) ? find_ex_command(&ea, NULL, NULL, NULL) : ea.cmd;
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13288
diff changeset
1978 }
6154
67edf731a240 updated for version 7.4.414
Bram Moolenaar <bram@vim.org>
parents: 6122
diff changeset
1979
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1980 if (p == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1981 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1982 if (!ea.skip)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
1983 errormsg = _("E464: Ambiguous use of user-defined command");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1984 goto doend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1985 }
16411
5b5c5daf57de patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents: 16399
diff changeset
1986 // 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
1987 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
1988 && !IS_USER_CMDIDX(ea.cmdidx))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1989 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1990 errormsg = uc_fun_cmd();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1991 goto doend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1992 }
16411
5b5c5daf57de patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents: 16399
diff changeset
1993
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1994 if (ea.cmdidx == CMD_SIZE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1995 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1996 if (!ea.skip)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1997 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1998 STRCPY(IObuff, _("E492: Not an editor command"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1999 if (!sourcing)
9941
e975914c17e9 commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents: 9927
diff changeset
2000 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2001 // If the modifier was parsed OK the error must be in the
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2002 // following command
9941
e975914c17e9 commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents: 9927
diff changeset
2003 if (after_modifier != NULL)
e975914c17e9 commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents: 9927
diff changeset
2004 append_command(after_modifier);
e975914c17e9 commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents: 9927
diff changeset
2005 else
e975914c17e9 commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents: 9927
diff changeset
2006 append_command(*cmdlinep);
e975914c17e9 commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents: 9927
diff changeset
2007 }
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
2008 errormsg = (char *)IObuff;
3757
3b62d8f36cdf updated for version 7.3.637
Bram Moolenaar <bram@vim.org>
parents: 3744
diff changeset
2009 did_emsg_syntax = TRUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2010 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2011 goto doend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2012 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2013
6305
b8caf7045e3d updated for version 7.4.486
Bram Moolenaar <bram@vim.org>
parents: 6230
diff changeset
2014 ni = (!IS_USER_CMDIDX(ea.cmdidx)
b8caf7045e3d updated for version 7.4.486
Bram Moolenaar <bram@vim.org>
parents: 6230
diff changeset
2015 && (cmdnames[ea.cmdidx].cmd_func == ex_ni
1315
0868e4e53fb2 updated for version 7.1-029
vimboss
parents: 1305
diff changeset
2016 #ifdef HAVE_EX_SCRIPT_NI
0868e4e53fb2 updated for version 7.1-029
vimboss
parents: 1305
diff changeset
2017 || cmdnames[ea.cmdidx].cmd_func == ex_script_ni
0868e4e53fb2 updated for version 7.1-029
vimboss
parents: 1305
diff changeset
2018 #endif
0868e4e53fb2 updated for version 7.1-029
vimboss
parents: 1305
diff changeset
2019 ));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2020
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2021 #ifndef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2022 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2023 * When the expression evaluation is disabled, recognize the ":if" and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2024 * ":endif" commands and ignore everything in between it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2025 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2026 if (ea.cmdidx == CMD_if)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2027 ++if_level;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2028 if (if_level)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2029 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2030 if (ea.cmdidx == CMD_endif)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2031 --if_level;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2032 goto doend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2033 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2034
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2035 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2036
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2037 // forced commands
1613
a0a98a0f1281 updated for version 7.1-326
vimboss
parents: 1603
diff changeset
2038 if (*p == '!' && ea.cmdidx != CMD_substitute
a0a98a0f1281 updated for version 7.1-326
vimboss
parents: 1603
diff changeset
2039 && ea.cmdidx != CMD_smagic && ea.cmdidx != CMD_snomagic)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2040 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2041 ++p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2042 ea.forceit = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2043 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2044 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2045 ea.forceit = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2046
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2047 /*
16475
854fb0ad4be6 patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents: 16451
diff changeset
2048 * 6. Parse arguments. Then check for errors.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2049 */
6305
b8caf7045e3d updated for version 7.4.486
Bram Moolenaar <bram@vim.org>
parents: 6230
diff changeset
2050 if (!IS_USER_CMDIDX(ea.cmdidx))
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 827
diff changeset
2051 ea.argt = (long)cmdnames[(int)ea.cmdidx].cmd_argt;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2052
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2053 if (!ea.skip)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2054 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2055 #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
2056 if (sandbox != 0 && !(ea.argt & EX_SBOXOK))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2057 {
15748
93b78c4a7cd5 patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents: 15713
diff changeset
2058 // 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
2059 errormsg = _(e_sandbox);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2060 goto doend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2061 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2062 #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
2063 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
2064 {
93b78c4a7cd5 patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents: 15713
diff changeset
2065 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
2066 goto doend;
93b78c4a7cd5 patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents: 15713
diff changeset
2067 }
17336
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
2068 if (!curbuf->b_p_ma && (ea.argt & EX_MODIFY))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2069 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2070 // 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
2071 errormsg = _(e_modifiable);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2072 goto doend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2073 }
631
68a196b7504d updated for version 7.0182
vimboss
parents: 625
diff changeset
2074
21487
5c92877092f9 patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents: 21475
diff changeset
2075 if (!IS_USER_CMDIDX(ea.cmdidx))
5c92877092f9 patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents: 21475
diff changeset
2076 {
5c92877092f9 patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents: 21475
diff changeset
2077 #ifdef FEAT_CMDWIN
5c92877092f9 patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents: 21475
diff changeset
2078 if (cmdwin_type != 0 && !(ea.argt & EX_CMDWIN))
5c92877092f9 patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents: 21475
diff changeset
2079 {
5c92877092f9 patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents: 21475
diff changeset
2080 // Command not allowed in the command line window
5c92877092f9 patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents: 21475
diff changeset
2081 errormsg = _(e_cmdwin);
5c92877092f9 patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents: 21475
diff changeset
2082 goto doend;
5c92877092f9 patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents: 21475
diff changeset
2083 }
5c92877092f9 patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents: 21475
diff changeset
2084 #endif
5c92877092f9 patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents: 21475
diff changeset
2085 if (text_locked() && !(ea.argt & EX_LOCK_OK))
5c92877092f9 patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents: 21475
diff changeset
2086 {
5c92877092f9 patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents: 21475
diff changeset
2087 // Command not allowed when text is locked
5c92877092f9 patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents: 21475
diff changeset
2088 errormsg = _(get_text_locked_msg());
5c92877092f9 patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents: 21475
diff changeset
2089 goto doend;
5c92877092f9 patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents: 21475
diff changeset
2090 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2091 }
14648
c3222a7342ab patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents: 14640
diff changeset
2092
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2093 // Disallow editing another buffer when "curbuf_lock" is set.
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2094 // Do allow ":checktime" (it is postponed).
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2095 // Do allow ":edit" (check for an argument later).
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2096 // Do allow ":file" with no arguments (check for an argument later).
21664
60ba361a7fdb patch 8.2.1382: Vim9: using :import in filetype plugin gives an error
Bram Moolenaar <Bram@vim.org>
parents: 21618
diff changeset
2097 if (!(ea.argt & (EX_CMDWIN | EX_LOCK_OK))
14648
c3222a7342ab patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents: 14640
diff changeset
2098 && ea.cmdidx != CMD_checktime
822
45fad0f590d0 updated for version 7.0c12
vimboss
parents: 820
diff changeset
2099 && ea.cmdidx != CMD_edit
14648
c3222a7342ab patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents: 14640
diff changeset
2100 && ea.cmdidx != CMD_file
6305
b8caf7045e3d updated for version 7.4.486
Bram Moolenaar <bram@vim.org>
parents: 6230
diff changeset
2101 && !IS_USER_CMDIDX(ea.cmdidx)
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 815
diff changeset
2102 && curbuf_locked())
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 815
diff changeset
2103 goto doend;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2104
17336
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
2105 if (!ni && !(ea.argt & EX_RANGE) && ea.addr_count > 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2106 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2107 // no range allowed
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
2108 errormsg = _(e_norange);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2109 goto doend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2110 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2111 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2112
17336
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
2113 if (!ni && !(ea.argt & EX_BANG) && ea.forceit) // no <!> allowed
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2114 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
2115 errormsg = _(e_nobang);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2116 goto doend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2117 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2118
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2119 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2120 * Don't complain about the range if it is not used
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2121 * (could happen if line_count is accidentally set to 0).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2122 */
17336
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
2123 if (!ea.skip && !ni && (ea.argt & EX_RANGE))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2124 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2125 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2126 * If the range is backwards, ask for confirmation and, if given, swap
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2127 * ea.line1 & ea.line2 so it's forwards again.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2128 * When global command is busy, don't ask, will fail below.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2129 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2130 if (!global_busy && ea.line1 > ea.line2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2131 {
557
862863033fdd updated for version 7.0158
vimboss
parents: 534
diff changeset
2132 if (msg_silent == 0)
862863033fdd updated for version 7.0158
vimboss
parents: 534
diff changeset
2133 {
862863033fdd updated for version 7.0158
vimboss
parents: 534
diff changeset
2134 if (sourcing || exmode_active)
862863033fdd updated for version 7.0158
vimboss
parents: 534
diff changeset
2135 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
2136 errormsg = _("E493: Backwards range given");
557
862863033fdd updated for version 7.0158
vimboss
parents: 534
diff changeset
2137 goto doend;
862863033fdd updated for version 7.0158
vimboss
parents: 534
diff changeset
2138 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2139 if (ask_yesno((char_u *)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2140 _("Backwards range given, OK to swap"), FALSE) != 'y')
557
862863033fdd updated for version 7.0158
vimboss
parents: 534
diff changeset
2141 goto doend;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2142 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2143 lnum = ea.line1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2144 ea.line1 = ea.line2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2145 ea.line2 = lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2146 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2147 if ((errormsg = invalid_range(&ea)) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2148 goto doend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2149 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2150
16475
854fb0ad4be6 patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents: 16451
diff changeset
2151 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
2152 // default is 1, not cursor
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2153 ea.line2 = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2154
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2155 correct_range(&ea);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2156
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2157 #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
2158 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
2159 && ea.addr_type == ADDR_LINES)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2160 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2161 // Put the first line at the start of a closed fold, put the last line
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2162 // at the end of a closed fold.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2163 (void)hasFolding(ea.line1, &ea.line1, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2164 (void)hasFolding(ea.line2, NULL, &ea.line2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2165 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2166 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2167
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2168 #ifdef FEAT_QUICKFIX
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2169 /*
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 40
diff changeset
2170 * For the ":make" and ":grep" commands we insert the 'makeprg'/'grepprg'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2171 * option here, so things like % get expanded.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2172 */
344
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
2173 p = replace_makeprg(&ea, p, cmdlinep);
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
2174 if (p == NULL)
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
2175 goto doend;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2176 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2177
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2178 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2179 * Skip to start of argument.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2180 * Don't do this for the ":!" command, because ":!! -l" needs the space.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2181 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2182 if (ea.cmdidx == CMD_bang)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2183 ea.arg = p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2184 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2185 ea.arg = skipwhite(p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2186
14648
c3222a7342ab patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents: 14640
diff changeset
2187 // ":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
2188 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
2189 goto doend;
c3222a7342ab patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents: 14640
diff changeset
2190
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2191 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2192 * Check for "++opt=val" argument.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2193 * Must be first, allow ":w ++enc=utf8 !cmd"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2194 */
17336
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
2195 if (ea.argt & EX_ARGOPT)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2196 while (ea.arg[0] == '+' && ea.arg[1] == '+')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2197 if (getargopt(&ea) == FAIL && !ni)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2198 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
2199 errormsg = _(e_invarg);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2200 goto doend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2201 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2202
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2203 if (ea.cmdidx == CMD_write || ea.cmdidx == CMD_update)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2204 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2205 if (*ea.arg == '>') // append
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2206 {
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2207 if (*++ea.arg != '>') // typed wrong
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2208 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
2209 errormsg = _("E494: Use w or w>>");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2210 goto doend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2211 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2212 ea.arg = skipwhite(ea.arg + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2213 ea.append = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2214 }
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2215 else if (*ea.arg == '!' && ea.cmdidx == CMD_write) // :w !filter
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2216 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2217 ++ea.arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2218 ea.usefilter = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2219 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2220 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2221
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2222 if (ea.cmdidx == CMD_read)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2223 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2224 if (ea.forceit)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2225 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2226 ea.usefilter = TRUE; // :r! filter if ea.forceit
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2227 ea.forceit = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2228 }
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2229 else if (*ea.arg == '!') // :r !filter
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2230 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2231 ++ea.arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2232 ea.usefilter = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2233 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2234 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2235
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2236 if (ea.cmdidx == CMD_lshift || ea.cmdidx == CMD_rshift)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2237 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2238 ea.amount = 1;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2239 while (*ea.arg == *ea.cmd) // count number of '>' or '<'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2240 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2241 ++ea.arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2242 ++ea.amount;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2243 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2244 ea.arg = skipwhite(ea.arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2245 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2246
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2247 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2248 * Check for "+command" argument, before checking for next command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2249 * Don't do this for ":read !cmd" and ":write !cmd".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2250 */
17336
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
2251 if ((ea.argt & EX_CMDARG) && !ea.usefilter)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2252 ea.do_ecmd_cmd = getargcmd(&ea.arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2253
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2254 /*
21353
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
2255 * Check for '|' to separate commands and '"' or '#' to start comments.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2256 * Don't do this for ":read !cmd" and ":write !cmd".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2257 */
17336
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
2258 if ((ea.argt & EX_TRLBAR) && !ea.usefilter)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2259 separate_nextcmd(&ea);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2260
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2261 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2262 * Check for <newline> to end a shell command.
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
2263 * Also do this for ":read !cmd", ":write !cmd" and ":global".
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
2264 * Any others?
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2265 */
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
2266 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
2267 || ea.cmdidx == CMD_terminal
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
2268 || ea.cmdidx == CMD_global
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
2269 || ea.cmdidx == CMD_vglobal
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
2270 || ea.usefilter)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2271 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2272 for (p = ea.arg; *p; ++p)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2273 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2274 // Remove one backslash before a newline, so that it's possible to
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2275 // pass a newline to the shell and also a newline that is preceded
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2276 // with a backslash. This makes it impossible to end a shell
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2277 // command in a backslash, but that doesn't appear useful.
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2278 // Halving the number of backslashes is incompatible with previous
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2279 // versions.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2280 if (*p == '\\' && p[1] == '\n')
1619
b9740fb41986 updated for version 7.2a
vimboss
parents: 1613
diff changeset
2281 STRMOVE(p, p + 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2282 else if (*p == '\n')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2283 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2284 ea.nextcmd = p + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2285 *p = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2286 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2287 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2288 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2289 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2290
17336
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
2291 if ((ea.argt & EX_DFLALL) && ea.addr_count == 0)
21939
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
2292 address_default_all(&ea);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2293
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2294 // 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
2295 if ( (ea.argt & EX_REGSTR)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2296 && *ea.arg != NUL
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2297 // Do not allow register = for user commands
6305
b8caf7045e3d updated for version 7.4.486
Bram Moolenaar <bram@vim.org>
parents: 6230
diff changeset
2298 && (!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
2299 && !((ea.argt & EX_COUNT) && VIM_ISDIGIT(*ea.arg)))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2300 {
2791
1bd8af13fb43 updated for version 7.3.171
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
2301 #ifndef FEAT_CLIPBOARD
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2302 // check these explicitly for a more specific error message
2791
1bd8af13fb43 updated for version 7.3.171
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
2303 if (*ea.arg == '*' || *ea.arg == '+')
1bd8af13fb43 updated for version 7.3.171
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
2304 {
15474
79e3dcc5aa50 patch 8.1.0745: compiler warnings for signed/unsigned string
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
2305 errormsg = _(e_invalidreg);
2791
1bd8af13fb43 updated for version 7.3.171
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
2306 goto doend;
1bd8af13fb43 updated for version 7.3.171
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
2307 }
1bd8af13fb43 updated for version 7.3.171
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
2308 #endif
6305
b8caf7045e3d updated for version 7.4.486
Bram Moolenaar <bram@vim.org>
parents: 6230
diff changeset
2309 if (valid_yank_reg(*ea.arg, (ea.cmdidx != CMD_put
b8caf7045e3d updated for version 7.4.486
Bram Moolenaar <bram@vim.org>
parents: 6230
diff changeset
2310 && !IS_USER_CMDIDX(ea.cmdidx))))
2791
1bd8af13fb43 updated for version 7.3.171
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
2311 {
1bd8af13fb43 updated for version 7.3.171
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
2312 ea.regname = *ea.arg++;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2313 #ifdef FEAT_EVAL
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2314 // for '=' register: accept the rest of the line as an expression
2791
1bd8af13fb43 updated for version 7.3.171
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
2315 if (ea.arg[-1] == '=' && ea.arg[0] != NUL)
1bd8af13fb43 updated for version 7.3.171
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
2316 {
1bd8af13fb43 updated for version 7.3.171
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
2317 set_expr_line(vim_strsave(ea.arg));
1bd8af13fb43 updated for version 7.3.171
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
2318 ea.arg += STRLEN(ea.arg);
1bd8af13fb43 updated for version 7.3.171
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
2319 }
1bd8af13fb43 updated for version 7.3.171
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
2320 #endif
1bd8af13fb43 updated for version 7.3.171
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
2321 ea.arg = skipwhite(ea.arg);
1bd8af13fb43 updated for version 7.3.171
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
2322 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2323 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2324
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2325 /*
17336
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
2326 * Check for a count. When accepting a EX_BUFNAME, don't use "123foo" as a
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2327 * count, it's a buffer name.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2328 */
17336
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
2329 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
2330 && (!(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
2331 || VIM_ISWHITE(*p)))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2332 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2333 n = getdigits(&ea.arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2334 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
2335 if (n <= 0 && !ni && (ea.argt & EX_ZEROR) == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2336 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
2337 errormsg = _(e_zerocount);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2338 goto doend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2339 }
16475
854fb0ad4be6 patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents: 16451
diff changeset
2340 if (ea.addr_type != ADDR_LINES) // e.g. :buffer 2, :sleep 3
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2341 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2342 ea.line2 = n;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2343 if (ea.addr_count == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2344 ea.addr_count = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2345 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2346 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2347 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2348 ea.line1 = ea.line2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2349 ea.line2 += n - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2350 ++ea.addr_count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2351 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2352 * Be vi compatible: no error message for out of range.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2353 */
16475
854fb0ad4be6 patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents: 16451
diff changeset
2354 if (ea.line2 > curbuf->b_ml.ml_line_count)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2355 ea.line2 = curbuf->b_ml.ml_line_count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2356 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2357 }
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
2358
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
2359 /*
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
2360 * Check for flags: 'l', 'p' and '#'.
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
2361 */
17336
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
2362 if (ea.argt & EX_FLAGS)
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
2363 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
2364 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
2365 && *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
2366 {
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
2367 // no arguments allowed but there is something
21461
4dfd00f481fb patch 8.2.1281: the "trailing characters" error can be hard to understand
Bram Moolenaar <Bram@vim.org>
parents: 21459
diff changeset
2368 errormsg = ex_errmsg(e_trailing_arg, ea.arg);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2369 goto doend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2370 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2371
17336
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
2372 if (!ni && (ea.argt & EX_NEEDARG) && *ea.arg == NUL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2373 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
2374 errormsg = _(e_argreq);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2375 goto doend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2376 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2377
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2378 #ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2379 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2380 * Skip the command when it's not going to be executed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2381 * The commands like :if, :endif, etc. always need to be executed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2382 * Also make an exception for commands that handle a trailing command
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2383 * themselves.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2384 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2385 if (ea.skip)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2386 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2387 switch (ea.cmdidx)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2388 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2389 // commands that need evaluation
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2390 case CMD_while:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2391 case CMD_endwhile:
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
2392 case CMD_for:
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
2393 case CMD_endfor:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2394 case CMD_if:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2395 case CMD_elseif:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2396 case CMD_else:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2397 case CMD_endif:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2398 case CMD_try:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2399 case CMD_catch:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2400 case CMD_finally:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2401 case CMD_endtry:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2402 case CMD_function:
19575
3c0de44077cd patch 8.2.0344: ":def" not skipped properly
Bram Moolenaar <Bram@vim.org>
parents: 19497
diff changeset
2403 case CMD_def:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2404 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2405
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2406 // Commands that handle '|' themselves. Check: A command should
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2407 // either have the EX_TRLBAR flag, appear in this list or appear in
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2408 // the list at ":help :bar".
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2409 case CMD_aboveleft:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2410 case CMD_and:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2411 case CMD_belowright:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2412 case CMD_botright:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2413 case CMD_browse:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2414 case CMD_call:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2415 case CMD_confirm:
18713
baf890fa1621 patch 8.1.2348: :const cannot be followed by "| endif"
Bram Moolenaar <Bram@vim.org>
parents: 18406
diff changeset
2416 case CMD_const:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2417 case CMD_delfunction:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2418 case CMD_djump:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2419 case CMD_dlist:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2420 case CMD_dsearch:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2421 case CMD_dsplit:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2422 case CMD_echo:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2423 case CMD_echoerr:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2424 case CMD_echomsg:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2425 case CMD_echon:
19415
90e24240904b patch 8.2.0265: "eval" after "if 0" doesn't check for following command
Bram Moolenaar <Bram@vim.org>
parents: 19348
diff changeset
2426 case CMD_eval:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2427 case CMD_execute:
9941
e975914c17e9 commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents: 9927
diff changeset
2428 case CMD_filter:
22391
a9fb7efa31d6 patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents: 22361
diff changeset
2429 case CMD_final:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2430 case CMD_help:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2431 case CMD_hide:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2432 case CMD_ijump:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2433 case CMD_ilist:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2434 case CMD_isearch:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2435 case CMD_isplit:
22
cc049b00ee70 updated for version 7.0014
vimboss
parents: 17
diff changeset
2436 case CMD_keepalt:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2437 case CMD_keepjumps:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2438 case CMD_keepmarks:
5467
6367a766027d updated for version 7.4.083
Bram Moolenaar <bram@vim.org>
parents: 5464
diff changeset
2439 case CMD_keeppatterns:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2440 case CMD_leftabove:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2441 case CMD_let:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2442 case CMD_lockmarks:
18715
bd4c34db84ab patch 8.1.2349: :lockvar and :unlockvar cannot be followed by "| endif"
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
2443 case CMD_lockvar:
2320
966a5609669e Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents: 2311
diff changeset
2444 case CMD_lua:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2445 case CMD_match:
14
946da5994c01 updated for version 7.0006
vimboss
parents: 11
diff changeset
2446 case CMD_mzscheme:
5737
e25a04c1c515 updated for version 7.4.213
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
2447 case CMD_noautocmd:
e25a04c1c515 updated for version 7.4.213
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
2448 case CMD_noswapfile:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2449 case CMD_perl:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2450 case CMD_psearch:
2350
06feaf4fe36a Rename some "python3" symbols to "py3", as the command name.
Bram Moolenaar <bram@vim.org>
parents: 2340
diff changeset
2451 case CMD_py3:
2366
7a57fe6a5157 Fix that :py3file was not working.
Bram Moolenaar <bram@vim.org>
parents: 2360
diff changeset
2452 case CMD_python3:
22391
a9fb7efa31d6 patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents: 22361
diff changeset
2453 case CMD_python:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2454 case CMD_return:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2455 case CMD_rightbelow:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2456 case CMD_ruby:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2457 case CMD_silent:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2458 case CMD_smagic:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2459 case CMD_snomagic:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2460 case CMD_substitute:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2461 case CMD_syntax:
690
0e922220d322 updated for version 7.0208
vimboss
parents: 685
diff changeset
2462 case CMD_tab:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2463 case CMD_tcl:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2464 case CMD_throw:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2465 case CMD_tilde:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2466 case CMD_topleft:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2467 case CMD_unlet:
18715
bd4c34db84ab patch 8.1.2349: :lockvar and :unlockvar cannot be followed by "| endif"
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
2468 case CMD_unlockvar:
22391
a9fb7efa31d6 patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents: 22361
diff changeset
2469 case CMD_var:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2470 case CMD_verbose:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2471 case CMD_vertical:
2887
15705b520c29 updated for version 7.3.217
Bram Moolenaar <bram@vim.org>
parents: 2853
diff changeset
2472 case CMD_wincmd:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2473 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2474
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2475 default: goto doend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2476 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2477 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2478 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2479
17336
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
2480 if (ea.argt & EX_XFILE)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2481 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2482 if (expand_filename(&ea, cmdlinep, &errormsg) == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2483 goto doend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2484 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2485
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2486 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2487 * Accept buffer name. Cannot be used at the same time with a buffer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2488 * number. Don't do this for a user command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2489 */
17336
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
2490 if ((ea.argt & EX_BUFNAME) && *ea.arg != NUL && ea.addr_count == 0
6305
b8caf7045e3d updated for version 7.4.486
Bram Moolenaar <bram@vim.org>
parents: 6230
diff changeset
2491 && !IS_USER_CMDIDX(ea.cmdidx))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2492 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2493 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2494 * :bdelete, :bwipeout and :bunload take several arguments, separated
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2495 * by spaces: find next space (skipping over escaped characters).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2496 * The others take one argument: ignore trailing spaces.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2497 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2498 if (ea.cmdidx == CMD_bdelete || ea.cmdidx == CMD_bwipeout
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2499 || ea.cmdidx == CMD_bunload)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2500 p = skiptowhite_esc(ea.arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2501 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2502 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2503 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
2504 while (p > ea.arg && VIM_ISWHITE(p[-1]))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2505 --p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2506 }
17336
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
2507 ea.line2 = buflist_findpat(ea.arg, p, (ea.argt & EX_BUFUNL) != 0,
4236
23ce9a61bdc2 updated for version 7.3.869
Bram Moolenaar <bram@vim.org>
parents: 4211
diff changeset
2508 FALSE, FALSE);
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2509 if (ea.line2 < 0) // failed
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2510 goto doend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2511 ea.addr_count = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2512 ea.arg = skipwhite(p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2513 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2514
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2515 // The :try command saves the emsg_silent flag, reset it here when
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2516 // ":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
2517 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
2518 {
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2519 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
2520 if (emsg_silent < 0)
530943a23d3f patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents: 13268
diff changeset
2521 emsg_silent = 0;
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2522 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
2523 }
530943a23d3f patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents: 13268
diff changeset
2524
530943a23d3f patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents: 13268
diff changeset
2525 /*
530943a23d3f patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents: 13268
diff changeset
2526 * 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
2527 */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2528
6305
b8caf7045e3d updated for version 7.4.486
Bram Moolenaar <bram@vim.org>
parents: 6230
diff changeset
2529 if (IS_USER_CMDIDX(ea.cmdidx))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2530 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2531 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2532 * Execute a user-defined command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2533 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2534 do_ucmd(&ea);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2535 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2536 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2537 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2538 /*
16411
5b5c5daf57de patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents: 16399
diff changeset
2539 * Call the function to execute the builtin command.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2540 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2541 ea.errmsg = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2542 (cmdnames[ea.cmdidx].cmd_func)(&ea);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2543 if (ea.errmsg != NULL)
21459
a422bd80b434 patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents: 21413
diff changeset
2544 errormsg = ea.errmsg;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2545 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2546
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2547 #ifdef FEAT_EVAL
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
2548 // Set flag that any command was executed, used by ex_vim9script().
19348
b6da81589f8c patch 8.2.0232: the :compiler command causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 19271
diff changeset
2549 if (getline_equal(ea.getline, ea.cookie, getsourceline)
b6da81589f8c patch 8.2.0232: the :compiler command causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 19271
diff changeset
2550 && current_sctx.sc_sid > 0)
19191
133ef7ba4e4e patch 8.2.0154: reallocating the list of scripts is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 19181
diff changeset
2551 SCRIPT_ITEM(current_sctx.sc_sid)->sn_had_command = TRUE;
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
2552
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2553 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2554 * If the command just executed called do_cmdline(), any throw or ":return"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2555 * or ":finish" encountered there must also check the cstack of the still
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2556 * active do_cmdline() that called this do_one_cmd(). Rethrow an uncaught
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2557 * exception, or reanimate a returned function or finished script file and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2558 * return or finish it again.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2559 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2560 if (need_rethrow)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2561 do_throw(cstack);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2562 else if (check_cstack)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2563 {
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 930
diff changeset
2564 if (source_finished(fgetline, cookie))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2565 do_finish(&ea, TRUE);
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 930
diff changeset
2566 else if (getline_equal(fgetline, cookie, get_func_line)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2567 && current_func_returned())
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2568 do_return(&ea, TRUE, FALSE, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2569 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2570 need_rethrow = check_cstack = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2571 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2572
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2573 doend:
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2574 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
2575 {
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2576 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
2577 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
2578 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2579
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2580 if (errormsg != NULL && *errormsg != NUL && !did_emsg)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2581 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2582 if (sourcing)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2583 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
2584 if (errormsg != (char *)IObuff)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2585 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2586 STRCPY(IObuff, errormsg);
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
2587 errormsg = (char *)IObuff;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2588 }
3097
738ea87c1964 updated for version 7.3.320
Bram Moolenaar <bram@vim.org>
parents: 2970
diff changeset
2589 append_command(*cmdlinep);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2590 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2591 emsg(errormsg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2592 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2593 #ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2594 do_errthrow(cstack,
6305
b8caf7045e3d updated for version 7.4.486
Bram Moolenaar <bram@vim.org>
parents: 6230
diff changeset
2595 (ea.cmdidx != CMD_SIZE && !IS_USER_CMDIDX(ea.cmdidx))
b8caf7045e3d updated for version 7.4.486
Bram Moolenaar <bram@vim.org>
parents: 6230
diff changeset
2596 ? cmdnames[(int)ea.cmdidx].cmd_name : (char_u *)NULL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2597 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2598
21172
96ae8622cfb6 patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents: 21130
diff changeset
2599 undo_cmdmod(&ea, save_msg_scroll);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2600 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
2601 reg_executing = save_reg_executing;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2602
28
726bdc53fa49 updated for version 7.0018
vimboss
parents: 24
diff changeset
2603 #ifdef HAVE_SANDBOX
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2604 if (ea.did_sandbox)
28
726bdc53fa49 updated for version 7.0018
vimboss
parents: 24
diff changeset
2605 --sandbox;
726bdc53fa49 updated for version 7.0018
vimboss
parents: 24
diff changeset
2606 #endif
726bdc53fa49 updated for version 7.0018
vimboss
parents: 24
diff changeset
2607
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2608 if (ea.nextcmd && *ea.nextcmd == NUL) // not really a next command
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2609 ea.nextcmd = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2610
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2611 #ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2612 --ex_nesting_level;
20996
3af71cbcfdbe patch 8.2.1049: Vim9: leaking memory when using continuation line
Bram Moolenaar <Bram@vim.org>
parents: 20982
diff changeset
2613 vim_free(ea.cmdline_tofree);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2614 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2615
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2616 return ea.nextcmd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2617 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2618 #if (_MSC_VER == 1200)
128
8def260d486d updated for version 7.0044
vimboss
parents: 122
diff changeset
2619 #pragma optimize( "", on )
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2620 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2621
21459
a422bd80b434 patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents: 21413
diff changeset
2622 static char ex_error_buf[MSG_BUF_LEN];
a422bd80b434 patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents: 21413
diff changeset
2623
a422bd80b434 patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents: 21413
diff changeset
2624 /*
a422bd80b434 patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents: 21413
diff changeset
2625 * Return an error message with argument included.
a422bd80b434 patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents: 21413
diff changeset
2626 * Uses a static buffer, only the last error will be kept.
a422bd80b434 patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents: 21413
diff changeset
2627 * "msg" will be translated, caller should use N_().
a422bd80b434 patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents: 21413
diff changeset
2628 */
a422bd80b434 patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents: 21413
diff changeset
2629 char *
a422bd80b434 patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents: 21413
diff changeset
2630 ex_errmsg(char *msg, char_u *arg)
a422bd80b434 patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents: 21413
diff changeset
2631 {
a422bd80b434 patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents: 21413
diff changeset
2632 vim_snprintf(ex_error_buf, MSG_BUF_LEN, _(msg), arg);
a422bd80b434 patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents: 21413
diff changeset
2633 return ex_error_buf;
a422bd80b434 patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents: 21413
diff changeset
2634 }
a422bd80b434 patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents: 21413
diff changeset
2635
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2636 /*
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2637 * Parse and skip over command modifiers:
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2638 * - update eap->cmd
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2639 * - store flags in "cmdmod".
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2640 * - Set ex_pressedreturn for an empty command line.
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2641 * - set msg_silent for ":silent"
14538
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2642 * - set 'eventignore' to "all" for ":noautocmd"
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2643 * - set p_verbose for ":verbose"
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2644 * - Increment "sandbox" for ":sandbox"
14538
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2645 * When "skip_only" is TRUE the global variables are not changed, except for
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2646 * "cmdmod".
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2647 * Return FAIL when the command is not to be executed.
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2648 * May set "errormsg" to an error message.
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2649 */
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2650 int
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
2651 parse_command_modifiers(exarg_T *eap, char **errormsg, int skip_only)
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2652 {
21353
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
2653 char_u *p;
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
2654 int starts_with_colon = FALSE;
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2655
20007
aadd1cae2ff5 patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents: 19892
diff changeset
2656 CLEAR_FIELD(cmdmod);
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2657 eap->verbose_save = -1;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2658 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
2659
14538
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2660 // 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
2661 for (;;)
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2662 {
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2663 while (*eap->cmd == ' ' || *eap->cmd == '\t' || *eap->cmd == ':')
21353
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
2664 {
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
2665 if (*eap->cmd == ':')
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
2666 starts_with_colon = TRUE;
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2667 ++eap->cmd;
21353
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
2668 }
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2669
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2670 // in ex mode, an empty line works like :+
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2671 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
2672 && (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
2673 || 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
2674 && 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
2675 {
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2676 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
2677 if (!skip_only)
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2678 ex_pressedreturn = TRUE;
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2679 }
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2680
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2681 // ignore comment and empty lines
21353
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
2682 if (comment_start(eap->cmd, starts_with_colon))
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2683 return FAIL;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2684 if (*eap->cmd == NUL)
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2685 {
14538
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2686 if (!skip_only)
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2687 ex_pressedreturn = TRUE;
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2688 return FAIL;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2689 }
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2690
22260
d7c1e3efa88e patch 8.2.1679: Vim9: ":*" is not recognized as a range
Bram Moolenaar <Bram@vim.org>
parents: 22208
diff changeset
2691 p = skip_range(eap->cmd, TRUE, NULL);
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2692 switch (*p)
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2693 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2694 // When adding an entry, also modify cmd_exists().
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2695 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
2696 break;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2697 cmdmod.split |= WSP_ABOVE;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2698 continue;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2699
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2700 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
2701 {
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2702 cmdmod.split |= WSP_BELOW;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2703 continue;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2704 }
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2705 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
2706 {
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2707 #ifdef FEAT_BROWSE_CMD
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2708 cmdmod.browse = TRUE;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2709 #endif
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2710 continue;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2711 }
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2712 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
2713 break;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2714 cmdmod.split |= WSP_BOT;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2715 continue;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2716
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2717 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
2718 break;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2719 #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
2720 cmdmod.confirm = TRUE;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2721 #endif
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2722 continue;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2723
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2724 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
2725 {
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2726 cmdmod.keepmarks = TRUE;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2727 continue;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2728 }
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2729 if (checkforcmd(&eap->cmd, "keepalt", 5))
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2730 {
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2731 cmdmod.keepalt = TRUE;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2732 continue;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2733 }
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2734 if (checkforcmd(&eap->cmd, "keeppatterns", 5))
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2735 {
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2736 cmdmod.keeppatterns = TRUE;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2737 continue;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2738 }
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2739 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
2740 break;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2741 cmdmod.keepjumps = TRUE;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2742 continue;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2743
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2744 case 'f': // only accept ":filter {pat} cmd"
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2745 {
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2746 char_u *reg_pat;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2747
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2748 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
2749 || *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
2750 break;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2751 if (*p == '!')
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2752 {
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2753 cmdmod.filter_force = TRUE;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2754 p = skipwhite(p + 1);
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2755 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
2756 break;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2757 }
21259
ee0e2ada88c0 patch 8.2.1180: build failure in small version
Bram Moolenaar <Bram@vim.org>
parents: 21255
diff changeset
2758 #ifdef FEAT_EVAL
21255
4be91a7eafb2 patch 8.2.1178: Vim9: filter function recognized as command modifier
Bram Moolenaar <Bram@vim.org>
parents: 21212
diff changeset
2759 // Avoid that "filter(arg)" is recognized.
4be91a7eafb2 patch 8.2.1178: Vim9: filter function recognized as command modifier
Bram Moolenaar <Bram@vim.org>
parents: 21212
diff changeset
2760 if (in_vim9script() && !VIM_ISWHITE(*p))
4be91a7eafb2 patch 8.2.1178: Vim9: filter function recognized as command modifier
Bram Moolenaar <Bram@vim.org>
parents: 21212
diff changeset
2761 break;
21259
ee0e2ada88c0 patch 8.2.1180: build failure in small version
Bram Moolenaar <Bram@vim.org>
parents: 21255
diff changeset
2762 #endif
14538
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2763 if (skip_only)
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2764 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
2765 else
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2766 // 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
2767 p = skip_vimgrep_pat(p, &reg_pat, NULL);
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2768 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
2769 break;
14538
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2770 if (!skip_only)
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2771 {
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2772 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
2773 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
2774 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
2775 break;
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2776 }
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2777 eap->cmd = p;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2778 continue;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2779 }
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2780
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2781 // ":hide" and ":hide | cmd" are not modifiers
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2782 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
2783 || *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
2784 break;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2785 eap->cmd = p;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2786 cmdmod.hide = TRUE;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2787 continue;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2788
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2789 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
2790 {
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2791 cmdmod.lockmarks = TRUE;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2792 continue;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2793 }
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2794
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2795 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
2796 break;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2797 cmdmod.split |= WSP_ABOVE;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2798 continue;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2799
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2800 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
2801 {
14538
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2802 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
2803 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2804 // Set 'eventignore' to "all". Restore the
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2805 // existing option value later.
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2806 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
2807 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
2808 (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
2809 }
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 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
2813 break;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2814 cmdmod.noswapfile = TRUE;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2815 continue;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2816
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2817 case '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
2818 break;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2819 cmdmod.split |= WSP_BELOW;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2820 continue;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2821
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2822 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
2823 {
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2824 #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
2825 if (!skip_only)
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2826 {
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2827 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
2828 ++sandbox;
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2829 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
2830 }
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2831 #endif
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2832 continue;
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 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
2835 break;
14538
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2836 if (!skip_only)
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2837 {
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2838 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
2839 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
2840 ++msg_silent;
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2841 }
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2842 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
2843 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2844 // ":silent!", but not "silent !cmd"
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2845 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
2846 if (!skip_only)
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2847 {
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2848 ++emsg_silent;
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2849 ++eap->did_esilent;
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2850 }
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2851 }
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2852 continue;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2853
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2854 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
2855 {
15263
ad065b8123e8 patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents: 15239
diff changeset
2856 if (!skip_only)
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2857 {
15263
ad065b8123e8 patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents: 15239
diff changeset
2858 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
2859 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
2860 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
2861 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
2862 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
2863 else
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2864 {
15263
ad065b8123e8 patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents: 15239
diff changeset
2865 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
2866 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
2867 *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
2868 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
2869 }
ad065b8123e8 patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents: 15239
diff changeset
2870 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
2871 }
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2872 }
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2873 eap->cmd = p;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2874 continue;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2875 }
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2876 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
2877 break;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2878 cmdmod.split |= WSP_TOP;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2879 continue;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2880
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2881 case '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
2882 break;
14538
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2883 if (!skip_only)
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2884 {
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2885 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
2886 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
2887 msg_silent = 0;
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2888 }
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2889 continue;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2890
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2891 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
2892 {
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2893 cmdmod.split |= WSP_VERT;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2894 continue;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2895 }
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2896 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
2897 break;
14538
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2898 if (!skip_only)
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2899 {
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2900 if (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
2901 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
2902 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
2903 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
2904 else
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2905 p_verbose = 1;
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2906 }
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2907 eap->cmd = p;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2908 continue;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2909 }
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2910 break;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2911 }
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2912
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2913 return OK;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2914 }
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2915
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2916 /*
21255
4be91a7eafb2 patch 8.2.1178: Vim9: filter function recognized as command modifier
Bram Moolenaar <Bram@vim.org>
parents: 21212
diff changeset
2917 * Undo and free contents of "cmdmod".
21172
96ae8622cfb6 patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents: 21130
diff changeset
2918 */
96ae8622cfb6 patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents: 21130
diff changeset
2919 void
96ae8622cfb6 patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents: 21130
diff changeset
2920 undo_cmdmod(exarg_T *eap, int save_msg_scroll)
96ae8622cfb6 patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents: 21130
diff changeset
2921 {
96ae8622cfb6 patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents: 21130
diff changeset
2922 if (eap->verbose_save >= 0)
96ae8622cfb6 patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents: 21130
diff changeset
2923 p_verbose = eap->verbose_save;
96ae8622cfb6 patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents: 21130
diff changeset
2924
14538
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2925 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
2926 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2927 // Restore 'eventignore' to the value before ":noautocmd".
14538
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2928 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
2929 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
2930 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
2931 }
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2932
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2933 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
2934 vim_regfree(cmdmod.filter_regmatch.regprog);
21172
96ae8622cfb6 patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents: 21130
diff changeset
2935
96ae8622cfb6 patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents: 21130
diff changeset
2936 if (eap->save_msg_silent != -1)
96ae8622cfb6 patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents: 21130
diff changeset
2937 {
96ae8622cfb6 patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents: 21130
diff changeset
2938 // messages could be enabled for a serious error, need to check if the
96ae8622cfb6 patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents: 21130
diff changeset
2939 // counters don't become negative
96ae8622cfb6 patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents: 21130
diff changeset
2940 if (!did_emsg || msg_silent > eap->save_msg_silent)
96ae8622cfb6 patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents: 21130
diff changeset
2941 msg_silent = eap->save_msg_silent;
96ae8622cfb6 patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents: 21130
diff changeset
2942 emsg_silent -= eap->did_esilent;
96ae8622cfb6 patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents: 21130
diff changeset
2943 if (emsg_silent < 0)
96ae8622cfb6 patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents: 21130
diff changeset
2944 emsg_silent = 0;
96ae8622cfb6 patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents: 21130
diff changeset
2945 // Restore msg_scroll, it's set by file I/O commands, even when no
96ae8622cfb6 patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents: 21130
diff changeset
2946 // message is actually displayed.
96ae8622cfb6 patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents: 21130
diff changeset
2947 msg_scroll = save_msg_scroll;
96ae8622cfb6 patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents: 21130
diff changeset
2948
96ae8622cfb6 patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents: 21130
diff changeset
2949 // "silent reg" or "silent echo x" inside "redir" leaves msg_col
96ae8622cfb6 patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents: 21130
diff changeset
2950 // somewhere in the line. Put it back in the first column.
96ae8622cfb6 patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents: 21130
diff changeset
2951 if (redirecting())
96ae8622cfb6 patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents: 21130
diff changeset
2952 msg_col = 0;
96ae8622cfb6 patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents: 21130
diff changeset
2953 }
14538
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2954 }
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2955
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2956 /*
14505
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
2957 * 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
2958 * 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
2959 * 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
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 int
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
2962 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
2963 {
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
2964 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
2965 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
2966
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
2967 // 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
2968 for (;;)
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
2969 {
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
2970 eap->line1 = eap->line2;
21939
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
2971 eap->line2 = default_address(eap);
14505
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
2972 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
2973 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
2974 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
2975 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
2976 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
2977 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
2978 {
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
2979 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
2980 {
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->cmd;
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
2982 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
2983 {
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
2984 case ADDR_LINES:
16475
854fb0ad4be6 patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents: 16451
diff changeset
2985 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
2986 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
2987 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
2988 break;
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
2989 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
2990 {
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
2991 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
2992
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
2993 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
2994 && buf->b_ml.ml_mfp == NULL)
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
2995 buf = buf->b_next;
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
2996 eap->line1 = buf->b_fnum;
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
2997 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
2998 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
2999 && 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
3000 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
3001 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
3002 break;
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3003 }
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3004 case ADDR_BUFFERS:
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3005 eap->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
3006 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
3007 break;
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3008 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
3009 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
3010 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
3011 {
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3012 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
3013 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
3014 ? 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
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 {
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3018 // 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
3019 // 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
3020 *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
3021 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
3022 }
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3023 break;
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3024 case ADDR_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
3025 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
3026 case ADDR_QUICKFIX:
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
3027 *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
3028 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
3029 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
3030 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
3031 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
3032 else
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 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
3035 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
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 break;
16515
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
3038 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
3039 #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
3040 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
3041 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
3042 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
3043 eap->line2 = 1;
16479
7dcf301d1432 patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents: 16475
diff changeset
3044 #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
3045 break;
16475
854fb0ad4be6 patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents: 16451
diff changeset
3046 case ADDR_NONE:
854fb0ad4be6 patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents: 16451
diff changeset
3047 // 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
3048 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
3049 }
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3050 ++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
3051 }
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3052 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
3053 {
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3054 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
3055
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3056 // '*' - 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
3057 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
3058 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
3059 *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
3060 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
3061 }
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3062
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3063 ++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
3064 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
3065 {
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3066 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
3067 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
3068 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
3069 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
3070 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
3071 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
3072 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
3073 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
3074 ++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
3075 }
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3076 }
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3077 }
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3078 else
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3079 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
3080 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
3081
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3082 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
3083 {
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3084 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
3085 {
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3086 curwin->w_cursor.lnum = eap->line2;
20185
0610f1ddb3a0 patch 8.2.0648: semicolon search does not work in first line
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
3087 // Don't leave the cursor on an illegal line or column, but do
0610f1ddb3a0 patch 8.2.0648: semicolon search does not work in first line
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
3088 // accept zero as address, so 0;/PATTERN/ works correctly.
0610f1ddb3a0 patch 8.2.0648: semicolon search does not work in first line
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
3089 if (eap->line2 > 0)
0610f1ddb3a0 patch 8.2.0648: semicolon search does not work in first line
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
3090 check_cursor();
14505
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3091 }
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3092 }
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3093 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
3094 break;
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3095 ++eap->cmd;
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3096 }
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3097
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3098 // 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
3099 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
3100 {
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3101 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
3102 // ... 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
3103 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
3104 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
3105 }
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3106 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
3107 }
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3108
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3109 /*
93
9c72ca2bfa44 updated for version 7.0037
vimboss
parents: 89
diff changeset
3110 * Check for an Ex command with optional tail.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3111 * If there is a match advance "pp" to the argument and return TRUE.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3112 */
93
9c72ca2bfa44 updated for version 7.0037
vimboss
parents: 89
diff changeset
3113 int
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
3114 checkforcmd(
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
3115 char_u **pp, // start of command
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
3116 char *cmd, // name of command
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
3117 int len) // required length
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3118 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3119 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3120
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3121 for (i = 0; cmd[i] != NUL; ++i)
1872
f13849167330 updated for version 7.2-169
vimboss
parents: 1868
diff changeset
3122 if (((char_u *)cmd)[i] != (*pp)[i])
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3123 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3124 if (i >= len && !isalpha((*pp)[i]))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3125 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3126 *pp = skipwhite(*pp + i);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3127 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3128 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3129 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3130 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3131
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3132 /*
3097
738ea87c1964 updated for version 7.3.320
Bram Moolenaar <bram@vim.org>
parents: 2970
diff changeset
3133 * Append "cmd" to the error message in IObuff.
738ea87c1964 updated for version 7.3.320
Bram Moolenaar <bram@vim.org>
parents: 2970
diff changeset
3134 * Takes care of limiting the length and handling 0xa0, which would be
738ea87c1964 updated for version 7.3.320
Bram Moolenaar <bram@vim.org>
parents: 2970
diff changeset
3135 * invisible otherwise.
738ea87c1964 updated for version 7.3.320
Bram Moolenaar <bram@vim.org>
parents: 2970
diff changeset
3136 */
738ea87c1964 updated for version 7.3.320
Bram Moolenaar <bram@vim.org>
parents: 2970
diff changeset
3137 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
3138 append_command(char_u *cmd)
3097
738ea87c1964 updated for version 7.3.320
Bram Moolenaar <bram@vim.org>
parents: 2970
diff changeset
3139 {
738ea87c1964 updated for version 7.3.320
Bram Moolenaar <bram@vim.org>
parents: 2970
diff changeset
3140 char_u *s = cmd;
738ea87c1964 updated for version 7.3.320
Bram Moolenaar <bram@vim.org>
parents: 2970
diff changeset
3141 char_u *d;
738ea87c1964 updated for version 7.3.320
Bram Moolenaar <bram@vim.org>
parents: 2970
diff changeset
3142
738ea87c1964 updated for version 7.3.320
Bram Moolenaar <bram@vim.org>
parents: 2970
diff changeset
3143 STRCAT(IObuff, ": ");
738ea87c1964 updated for version 7.3.320
Bram Moolenaar <bram@vim.org>
parents: 2970
diff changeset
3144 d = IObuff + STRLEN(IObuff);
738ea87c1964 updated for version 7.3.320
Bram Moolenaar <bram@vim.org>
parents: 2970
diff changeset
3145 while (*s != NUL && d - IObuff < IOSIZE - 7)
738ea87c1964 updated for version 7.3.320
Bram Moolenaar <bram@vim.org>
parents: 2970
diff changeset
3146 {
15595
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15591
diff changeset
3147 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
3148 {
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15591
diff changeset
3149 s += enc_utf8 ? 2 : 1;
3097
738ea87c1964 updated for version 7.3.320
Bram Moolenaar <bram@vim.org>
parents: 2970
diff changeset
3150 STRCPY(d, "<a0>");
738ea87c1964 updated for version 7.3.320
Bram Moolenaar <bram@vim.org>
parents: 2970
diff changeset
3151 d += 4;
738ea87c1964 updated for version 7.3.320
Bram Moolenaar <bram@vim.org>
parents: 2970
diff changeset
3152 }
738ea87c1964 updated for version 7.3.320
Bram Moolenaar <bram@vim.org>
parents: 2970
diff changeset
3153 else
738ea87c1964 updated for version 7.3.320
Bram Moolenaar <bram@vim.org>
parents: 2970
diff changeset
3154 MB_COPY_CHAR(s, d);
738ea87c1964 updated for version 7.3.320
Bram Moolenaar <bram@vim.org>
parents: 2970
diff changeset
3155 }
738ea87c1964 updated for version 7.3.320
Bram Moolenaar <bram@vim.org>
parents: 2970
diff changeset
3156 *d = NUL;
738ea87c1964 updated for version 7.3.320
Bram Moolenaar <bram@vim.org>
parents: 2970
diff changeset
3157 }
738ea87c1964 updated for version 7.3.320
Bram Moolenaar <bram@vim.org>
parents: 2970
diff changeset
3158
738ea87c1964 updated for version 7.3.320
Bram Moolenaar <bram@vim.org>
parents: 2970
diff changeset
3159 /*
21937
b931df03adcc patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents: 21893
diff changeset
3160 * If "start" points "&opt", "&l:opt", "&g:opt" or "$ENV" return a pointer to
b931df03adcc patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents: 21893
diff changeset
3161 * the name. Otherwise just return "start".
b931df03adcc patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents: 21893
diff changeset
3162 */
b931df03adcc patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents: 21893
diff changeset
3163 char_u *
b931df03adcc patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents: 21893
diff changeset
3164 skip_option_env_lead(char_u *start)
b931df03adcc patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents: 21893
diff changeset
3165 {
b931df03adcc patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents: 21893
diff changeset
3166 char_u *name = start;
b931df03adcc patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents: 21893
diff changeset
3167
b931df03adcc patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents: 21893
diff changeset
3168 if (*start == '&')
b931df03adcc patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents: 21893
diff changeset
3169 {
b931df03adcc patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents: 21893
diff changeset
3170 if ((start[1] == 'l' || start[1] == 'g') && start[2] == ':')
b931df03adcc patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents: 21893
diff changeset
3171 name += 3;
b931df03adcc patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents: 21893
diff changeset
3172 else
b931df03adcc patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents: 21893
diff changeset
3173 name += 1;
b931df03adcc patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents: 21893
diff changeset
3174 }
b931df03adcc patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents: 21893
diff changeset
3175 else if (*start == '$')
b931df03adcc patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents: 21893
diff changeset
3176 name += 1;
b931df03adcc patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents: 21893
diff changeset
3177 return name;
b931df03adcc patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents: 21893
diff changeset
3178 }
b931df03adcc patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents: 21893
diff changeset
3179
b931df03adcc patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents: 21893
diff changeset
3180 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3181 * Find an Ex command by its name, either built-in or user.
184
476198990769 updated for version 7.0057
vimboss
parents: 171
diff changeset
3182 * 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
3183 * Sets eap->cmdidx and returns a pointer to char after the command name.
184
476198990769 updated for version 7.0057
vimboss
parents: 171
diff changeset
3184 * "full" is set to TRUE if the whole command name matched.
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
3185 *
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
3186 * If "lookup" is not NULL recognize expression without "eval" or "call" and
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
3187 * assignment without "let". Sets eap->cmdidx to the command while returning
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
3188 * "eap->cmd".
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
3189 *
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3190 * Returns NULL for an ambiguous user command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3191 */
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
3192 char_u *
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
3193 find_ex_command(
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
3194 exarg_T *eap,
20075
516b10943fdb patch 8.2.0593: finding a user command is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 20063
diff changeset
3195 int *full UNUSED,
20239
2135b4641680 patch 8.2.0675: Vim9: no support for closures
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
3196 void *(*lookup)(char_u *, size_t, cctx_T *) UNUSED,
20075
516b10943fdb patch 8.2.0593: finding a user command is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 20063
diff changeset
3197 cctx_T *cctx UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3198 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3199 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3200 char_u *p;
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
3201 int i;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3202
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
3203 #ifdef FEAT_EVAL
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
3204 /*
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
3205 * Recognize a Vim9 script function/method call and assignment:
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
3206 * "lvar = value", "lvar(arg)", "[1, 2 3]->Func()"
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
3207 */
19481
c27837cbe922 patch 8.2.0298: Vim9 script: cannot start command with a string constant
Bram Moolenaar <Bram@vim.org>
parents: 19475
diff changeset
3208 p = eap->cmd;
21526
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3209 if (lookup != NULL)
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3210 {
21937
b931df03adcc patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents: 21893
diff changeset
3211 char_u *pskip = skip_option_env_lead(eap->cmd);
21618
9ab43576a13b patch 8.2.1359: Vim9: cannot assign to / register in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 21596
diff changeset
3212
9ab43576a13b patch 8.2.1359: Vim9: cannot assign to / register in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 21596
diff changeset
3213 if (vim_strchr((char_u *)"{('[\"@", *p) != NULL
21526
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3214 || ((p = to_name_const_end(pskip)) > eap->cmd && *p != NUL))
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3215 {
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3216 int oplen;
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3217 int heredoc;
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3218
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3219 if (
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3220 // "(..." is an expression.
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3221 // "funcname(" is always a function call.
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3222 *p == '('
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3223 || (p == eap->cmd
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3224 ? (
22555
7d25264c246c patch 8.2.1826: Vim9: cannot use a {} block at script level
Bram Moolenaar <Bram@vim.org>
parents: 22543
diff changeset
3225 // "{..." is a dict expression or block start.
21526
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3226 *eap->cmd == '{'
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3227 // "'string'->func()" is an expression.
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3228 || *eap->cmd == '\''
21544
6c67c86a202a patch 8.2.1322: Vim9: method on double quoted string doesn't work
Bram Moolenaar <Bram@vim.org>
parents: 21526
diff changeset
3229 // '"string"->func()' is an expression.
6c67c86a202a patch 8.2.1322: Vim9: method on double quoted string doesn't work
Bram Moolenaar <Bram@vim.org>
parents: 21526
diff changeset
3230 || *eap->cmd == '"'
21526
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3231 // "g:varname" is an expression.
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3232 || eap->cmd[1] == ':'
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3233 )
22268
2eaee3396f7a patch 8.2.1683: Vim9: assignment test fails
Bram Moolenaar <Bram@vim.org>
parents: 22260
diff changeset
3234 // "varname->func()" is an expression.
2eaee3396f7a patch 8.2.1683: Vim9: assignment test fails
Bram Moolenaar <Bram@vim.org>
parents: 22260
diff changeset
3235 : (*p == '-' && p[1] == '>')))
2eaee3396f7a patch 8.2.1683: Vim9: assignment test fails
Bram Moolenaar <Bram@vim.org>
parents: 22260
diff changeset
3236 {
22555
7d25264c246c patch 8.2.1826: Vim9: cannot use a {} block at script level
Bram Moolenaar <Bram@vim.org>
parents: 22543
diff changeset
3237 if (*eap->cmd == '{' && ends_excmd(*skipwhite(eap->cmd + 1)))
7d25264c246c patch 8.2.1826: Vim9: cannot use a {} block at script level
Bram Moolenaar <Bram@vim.org>
parents: 22543
diff changeset
3238 {
7d25264c246c patch 8.2.1826: Vim9: cannot use a {} block at script level
Bram Moolenaar <Bram@vim.org>
parents: 22543
diff changeset
3239 // "{" by itself is the start of a block.
7d25264c246c patch 8.2.1826: Vim9: cannot use a {} block at script level
Bram Moolenaar <Bram@vim.org>
parents: 22543
diff changeset
3240 eap->cmdidx = CMD_block;
7d25264c246c patch 8.2.1826: Vim9: cannot use a {} block at script level
Bram Moolenaar <Bram@vim.org>
parents: 22543
diff changeset
3241 return eap->cmd + 1;
7d25264c246c patch 8.2.1826: Vim9: cannot use a {} block at script level
Bram Moolenaar <Bram@vim.org>
parents: 22543
diff changeset
3242 }
22268
2eaee3396f7a patch 8.2.1683: Vim9: assignment test fails
Bram Moolenaar <Bram@vim.org>
parents: 22260
diff changeset
3243 eap->cmdidx = CMD_eval;
2eaee3396f7a patch 8.2.1683: Vim9: assignment test fails
Bram Moolenaar <Bram@vim.org>
parents: 22260
diff changeset
3244 return eap->cmd;
2eaee3396f7a patch 8.2.1683: Vim9: assignment test fails
Bram Moolenaar <Bram@vim.org>
parents: 22260
diff changeset
3245 }
2eaee3396f7a patch 8.2.1683: Vim9: assignment test fails
Bram Moolenaar <Bram@vim.org>
parents: 22260
diff changeset
3246
2eaee3396f7a patch 8.2.1683: Vim9: assignment test fails
Bram Moolenaar <Bram@vim.org>
parents: 22260
diff changeset
3247 if (p != eap->cmd && (
21526
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3248 // "varname[]" is an expression.
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3249 *p == '['
22268
2eaee3396f7a patch 8.2.1683: Vim9: assignment test fails
Bram Moolenaar <Bram@vim.org>
parents: 22260
diff changeset
3250 // "varname.key" is an expression.
2eaee3396f7a patch 8.2.1683: Vim9: assignment test fails
Bram Moolenaar <Bram@vim.org>
parents: 22260
diff changeset
3251 || (*p == '.' && ASCII_ISALPHA(p[1]))))
21413
8992d4f63761 patch 8.2.1257: Vim9: list unpack doesn't work at the script level
Bram Moolenaar <Bram@vim.org>
parents: 21357
diff changeset
3252 {
22268
2eaee3396f7a patch 8.2.1683: Vim9: assignment test fails
Bram Moolenaar <Bram@vim.org>
parents: 22260
diff changeset
3253 char_u *after = p;
2eaee3396f7a patch 8.2.1683: Vim9: assignment test fails
Bram Moolenaar <Bram@vim.org>
parents: 22260
diff changeset
3254
2eaee3396f7a patch 8.2.1683: Vim9: assignment test fails
Bram Moolenaar <Bram@vim.org>
parents: 22260
diff changeset
3255 // When followed by "=" or "+=" then it is an assignment.
2eaee3396f7a patch 8.2.1683: Vim9: assignment test fails
Bram Moolenaar <Bram@vim.org>
parents: 22260
diff changeset
3256 ++emsg_silent;
2eaee3396f7a patch 8.2.1683: Vim9: assignment test fails
Bram Moolenaar <Bram@vim.org>
parents: 22260
diff changeset
3257 if (skip_expr(&after) == OK
2eaee3396f7a patch 8.2.1683: Vim9: assignment test fails
Bram Moolenaar <Bram@vim.org>
parents: 22260
diff changeset
3258 && (*after == '='
2eaee3396f7a patch 8.2.1683: Vim9: assignment test fails
Bram Moolenaar <Bram@vim.org>
parents: 22260
diff changeset
3259 || (*after != NUL && after[1] == '=')))
22391
a9fb7efa31d6 patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents: 22361
diff changeset
3260 eap->cmdidx = CMD_var;
22268
2eaee3396f7a patch 8.2.1683: Vim9: assignment test fails
Bram Moolenaar <Bram@vim.org>
parents: 22260
diff changeset
3261 else
2eaee3396f7a patch 8.2.1683: Vim9: assignment test fails
Bram Moolenaar <Bram@vim.org>
parents: 22260
diff changeset
3262 eap->cmdidx = CMD_eval;
2eaee3396f7a patch 8.2.1683: Vim9: assignment test fails
Bram Moolenaar <Bram@vim.org>
parents: 22260
diff changeset
3263 --emsg_silent;
21413
8992d4f63761 patch 8.2.1257: Vim9: list unpack doesn't work at the script level
Bram Moolenaar <Bram@vim.org>
parents: 21357
diff changeset
3264 return eap->cmd;
8992d4f63761 patch 8.2.1257: Vim9: list unpack doesn't work at the script level
Bram Moolenaar <Bram@vim.org>
parents: 21357
diff changeset
3265 }
21526
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3266
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3267 // "[...]->Method()" is a list expression, but "[a, b] = Func()" is
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3268 // an assignment.
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3269 // If there is no line break inside the "[...]" then "p" is
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3270 // advanced to after the "]" by to_name_const_end(): check if a "="
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3271 // follows.
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3272 // If "[...]" has a line break "p" still points at the "[" and it
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3273 // can't be an assignment.
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3274 if (*eap->cmd == '[')
21413
8992d4f63761 patch 8.2.1257: Vim9: list unpack doesn't work at the script level
Bram Moolenaar <Bram@vim.org>
parents: 21357
diff changeset
3275 {
21526
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3276 p = to_name_const_end(eap->cmd);
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3277 if (p == eap->cmd || *skipwhite(p) != '=')
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3278 {
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3279 eap->cmdidx = CMD_eval;
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3280 return eap->cmd;
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3281 }
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3282 if (p > eap->cmd && *skipwhite(p) == '=')
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3283 {
22391
a9fb7efa31d6 patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents: 22361
diff changeset
3284 eap->cmdidx = CMD_var;
21526
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3285 return eap->cmd;
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3286 }
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3287 }
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3288
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3289 // Recognize an assignment if we recognize the variable name:
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3290 // "g:var = expr"
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3291 // "var = expr" where "var" is a local var name.
21618
9ab43576a13b patch 8.2.1359: Vim9: cannot assign to / register in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 21596
diff changeset
3292 if (*eap->cmd == '@')
9ab43576a13b patch 8.2.1359: Vim9: cannot assign to / register in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 21596
diff changeset
3293 p = eap->cmd + 2;
21526
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3294 oplen = assignment_len(skipwhite(p), &heredoc);
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3295 if (oplen > 0)
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3296 {
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3297 if (((p - eap->cmd) > 2 && eap->cmd[1] == ':')
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3298 || *eap->cmd == '&'
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3299 || *eap->cmd == '$'
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3300 || *eap->cmd == '@'
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3301 || lookup(eap->cmd, p - eap->cmd, cctx) != NULL)
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3302 {
22391
a9fb7efa31d6 patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents: 22361
diff changeset
3303 eap->cmdidx = CMD_var;
21526
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3304 return eap->cmd;
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3305 }
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3306 }
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3307
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3308 // Recognize using a type for a w:, b:, t: or g: variable:
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3309 // "w:varname: number = 123".
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3310 if (eap->cmd[1] == ':' && *p == ':')
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3311 {
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3312 eap->cmdidx = CMD_eval;
21413
8992d4f63761 patch 8.2.1257: Vim9: list unpack doesn't work at the script level
Bram Moolenaar <Bram@vim.org>
parents: 21357
diff changeset
3313 return eap->cmd;
8992d4f63761 patch 8.2.1257: Vim9: list unpack doesn't work at the script level
Bram Moolenaar <Bram@vim.org>
parents: 21357
diff changeset
3314 }
21130
4a1e8086759b patch 8.2.1116: Vim9: parsing command checks for list twice
Bram Moolenaar <Bram@vim.org>
parents: 21122
diff changeset
3315 }
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
3316 }
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
3317 #endif
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
3318
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3319 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3320 * Isolate the command and search for it in the command table.
1441
21b11491a33f updated for version 7.1-156
vimboss
parents: 1427
diff changeset
3321 * Exceptions:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3322 * - the 'k' command can directly be followed by any character.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3323 * - the 's' command can be followed directly by 'c', 'g', 'i', 'I' or 'r'
6472
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
3324 * but :sre[wind] is another command, as are :scr[iptnames],
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3325 * :scs[cope], :sim[alt], :sig[ns] and :sil[ent].
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
3326 * - the "d" command can directly be followed by 'l' or 'p' flag.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3327 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3328 p = eap->cmd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3329 if (*p == 'k')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3330 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3331 eap->cmdidx = CMD_k;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3332 ++p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3333 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3334 else if (p[0] == 's'
6987
1661dd8df592 patch 7.4.811
Bram Moolenaar <bram@vim.org>
parents: 6965
diff changeset
3335 && ((p[1] == 'c' && (p[2] == NUL || (p[2] != 's' && p[2] != 'r'
1661dd8df592 patch 7.4.811
Bram Moolenaar <bram@vim.org>
parents: 6965
diff changeset
3336 && (p[3] == NUL || (p[3] != 'i' && p[4] != 'p')))))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3337 || p[1] == 'g'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3338 || (p[1] == 'i' && p[2] != 'm' && p[2] != 'l' && p[2] != 'g')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3339 || p[1] == 'I'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3340 || (p[1] == 'r' && p[2] != 'e')))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3341 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3342 eap->cmdidx = CMD_substitute;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3343 ++p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3344 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3345 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3346 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3347 while (ASCII_ISALPHA(*p))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3348 ++p;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
3349 // for python 3.x support ":py3", ":python3", ":py3file", etc.
2330
ea4bf6df1a8a Whitespace cleanup.
Bram Moolenaar <bram@vim.org>
parents: 2329
diff changeset
3350 if (eap->cmd[0] == 'p' && eap->cmd[1] == 'y')
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
3351 {
2366
7a57fe6a5157 Fix that :py3file was not working.
Bram Moolenaar <bram@vim.org>
parents: 2360
diff changeset
3352 while (ASCII_ISALNUM(*p))
7a57fe6a5157 Fix that :py3file was not working.
Bram Moolenaar <bram@vim.org>
parents: 2360
diff changeset
3353 ++p;
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
3354 }
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
3355 else if (*p == '9' && STRNCMP("vim9", eap->cmd, 4) == 0)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
3356 {
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
3357 // include "9" for "vim9script"
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
3358 ++p;
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
3359 while (ASCII_ISALPHA(*p))
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
3360 ++p;
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
3361 }
2329
ad2889f48843 Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents: 2320
diff changeset
3362
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
3363 // check for non-alpha command
22555
7d25264c246c patch 8.2.1826: Vim9: cannot use a {} block at script level
Bram Moolenaar <Bram@vim.org>
parents: 22543
diff changeset
3364 if (p == eap->cmd && vim_strchr((char_u *)"@*!=><&~#}", *p) != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3365 ++p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3366 len = (int)(p - eap->cmd);
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
3367 if (*eap->cmd == 'd' && (p[-1] == 'l' || p[-1] == 'p'))
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
3368 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
3369 // Check for ":dl", ":dell", etc. to ":deletel": that's
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
3370 // :delete with the 'l' flag. Same for 'p'.
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
3371 for (i = 0; i < len; ++i)
1872
f13849167330 updated for version 7.2-169
vimboss
parents: 1868
diff changeset
3372 if (eap->cmd[i] != ((char_u *)"delete")[i])
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
3373 break;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
3374 if (i == len - 1)
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
3375 {
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
3376 --len;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
3377 if (p[-1] == 'l')
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
3378 eap->flags |= EXFLAG_LIST;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
3379 else
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
3380 eap->flags |= EXFLAG_PRINT;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
3381 }
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
3382 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3383
11236
62c96fee518e patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents: 11158
diff changeset
3384 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
3385 {
11240
06307d812ca7 patch 8.0.0506: can't build with ANSI C
Christian Brabandt <cb@256bit.org>
parents: 11236
diff changeset
3386 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
3387 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
3388
11236
62c96fee518e patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents: 11158
diff changeset
3389 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
3390 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
3391 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
3392 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
3393 }
62c96fee518e patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents: 11158
diff changeset
3394
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
3395 // Use a precomputed index for fast look-up in cmdnames[]
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
3396 // taking into account the first 2 letters of eap->cmd.
11236
62c96fee518e patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents: 11158
diff changeset
3397 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
3398 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
3399 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
3400 }
20075
516b10943fdb patch 8.2.0593: finding a user command is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 20063
diff changeset
3401 else if (ASCII_ISUPPER(eap->cmd[0]))
516b10943fdb patch 8.2.0593: finding a user command is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 20063
diff changeset
3402 eap->cmdidx = CMD_Next;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3403 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
3404 eap->cmdidx = CMD_bang;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3405
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3406 for ( ; (int)eap->cmdidx < (int)CMD_SIZE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3407 eap->cmdidx = (cmdidx_T)((int)eap->cmdidx + 1))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3408 if (STRNCMP(cmdnames[(int)eap->cmdidx].cmd_name, (char *)eap->cmd,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3409 (size_t)len) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3410 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3411 #ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3412 if (full != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3413 && cmdnames[(int)eap->cmdidx].cmd_name[len] == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3414 *full = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3415 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3416 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3417 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3418
16411
5b5c5daf57de patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents: 16399
diff changeset
3419 // 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
3420 // overruled by a user defined command.
2633
7002404b17b1 updated for version 7.3.054
Bram Moolenaar <bram@vim.org>
parents: 2602
diff changeset
3421 if ((eap->cmdidx == CMD_SIZE || eap->cmdidx == CMD_Print)
7002404b17b1 updated for version 7.3.054
Bram Moolenaar <bram@vim.org>
parents: 2602
diff changeset
3422 && *eap->cmd >= 'A' && *eap->cmd <= 'Z')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3423 {
16411
5b5c5daf57de patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents: 16399
diff changeset
3424 // User defined commands may contain digits.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3425 while (ASCII_ISALNUM(*p))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3426 ++p;
184
476198990769 updated for version 7.0057
vimboss
parents: 171
diff changeset
3427 p = find_ucmd(eap, p, full, NULL, NULL);
476198990769 updated for version 7.0057
vimboss
parents: 171
diff changeset
3428 }
476198990769 updated for version 7.0057
vimboss
parents: 171
diff changeset
3429 if (p == eap->cmd)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3430 eap->cmdidx = CMD_SIZE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3431 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3432
22395
03249b8976a9 patch 8.2.1746: Vim9: cannot use "fina" for "finally"
Bram Moolenaar <Bram@vim.org>
parents: 22393
diff changeset
3433 // ":fina" means ":finally" for backwards compatibility.
03249b8976a9 patch 8.2.1746: Vim9: cannot use "fina" for "finally"
Bram Moolenaar <Bram@vim.org>
parents: 22393
diff changeset
3434 if (eap->cmdidx == CMD_final && p - eap->cmd == 4)
03249b8976a9 patch 8.2.1746: Vim9: cannot use "fina" for "finally"
Bram Moolenaar <Bram@vim.org>
parents: 22393
diff changeset
3435 eap->cmdidx = CMD_finally;
03249b8976a9 patch 8.2.1746: Vim9: cannot use "fina" for "finally"
Bram Moolenaar <Bram@vim.org>
parents: 22393
diff changeset
3436
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3437 return p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3438 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3439
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3440 #if defined(FEAT_EVAL) || defined(PROTO)
1447
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3441 static struct cmdmod
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3442 {
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3443 char *name;
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3444 int minlen;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
3445 int has_count; // :123verbose :3tab
1447
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3446 } cmdmods[] = {
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3447 {"aboveleft", 3, FALSE},
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3448 {"belowright", 3, FALSE},
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3449 {"botright", 2, FALSE},
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3450 {"browse", 3, FALSE},
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3451 {"confirm", 4, FALSE},
9941
e975914c17e9 commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents: 9927
diff changeset
3452 {"filter", 4, FALSE},
1447
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3453 {"hide", 3, FALSE},
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3454 {"keepalt", 5, FALSE},
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3455 {"keepjumps", 5, FALSE},
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3456 {"keepmarks", 3, FALSE},
5467
6367a766027d updated for version 7.4.083
Bram Moolenaar <bram@vim.org>
parents: 5464
diff changeset
3457 {"keeppatterns", 5, FALSE},
1447
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3458 {"leftabove", 5, FALSE},
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3459 {"lockmarks", 3, FALSE},
1721
d23a400b7184 updated for version 7.2-019
vimboss
parents: 1689
diff changeset
3460 {"noautocmd", 3, FALSE},
5737
e25a04c1c515 updated for version 7.4.213
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
3461 {"noswapfile", 3, FALSE},
1447
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3462 {"rightbelow", 6, FALSE},
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3463 {"sandbox", 3, FALSE},
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3464 {"silent", 3, FALSE},
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3465 {"tab", 3, TRUE},
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3466 {"topleft", 2, FALSE},
1926
43d337097e4c updated for version 7.2-223
vimboss
parents: 1925
diff changeset
3467 {"unsilent", 3, FALSE},
1447
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3468 {"verbose", 4, TRUE},
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3469 {"vertical", 4, FALSE},
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3470 };
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3471
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3472 /*
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3473 * Return length of a command modifier (including optional count).
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3474 * Return zero when it's not a modifier.
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3475 */
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3476 int
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
3477 modifier_len(char_u *cmd)
1447
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3478 {
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3479 int i, j;
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3480 char_u *p = cmd;
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3481
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3482 if (VIM_ISDIGIT(*cmd))
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3483 p = skipwhite(skipdigits(cmd));
1880
e5602d92da8c updated for version 7.2-177
vimboss
parents: 1879
diff changeset
3484 for (i = 0; i < (int)(sizeof(cmdmods) / sizeof(struct cmdmod)); ++i)
1447
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3485 {
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3486 for (j = 0; p[j] != NUL; ++j)
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3487 if (p[j] != cmdmods[i].name[j])
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3488 break;
4857
84a8d1ba81c3 updated for version 7.3.1175
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3489 if (!ASCII_ISALPHA(p[j]) && j >= cmdmods[i].minlen
1447
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3490 && (p == cmd || cmdmods[i].has_count))
1570
f0cfff4dcc2f updated for version 7.1-283
vimboss
parents: 1557
diff changeset
3491 return j + (int)(p - cmd);
1447
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3492 }
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3493 return 0;
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3494 }
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3495
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3496 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3497 * Return > 0 if an Ex command "name" exists.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3498 * Return 2 if there is an exact match.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3499 * Return 3 if there is an ambiguous match.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3500 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3501 int
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
3502 cmd_exists(char_u *name)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3503 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3504 exarg_T ea;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3505 int full = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3506 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3507 int j;
866
5de6b337e1a2 updated for version 7.0g04
vimboss
parents: 862
diff changeset
3508 char_u *p;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3509
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
3510 // Check command modifiers.
1880
e5602d92da8c updated for version 7.2-177
vimboss
parents: 1879
diff changeset
3511 for (i = 0; i < (int)(sizeof(cmdmods) / sizeof(struct cmdmod)); ++i)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3512 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3513 for (j = 0; name[j] != NUL; ++j)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3514 if (name[j] != cmdmods[i].name[j])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3515 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3516 if (name[j] == NUL && j >= cmdmods[i].minlen)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3517 return (cmdmods[i].name[j] == NUL ? 2 : 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3518 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3519
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
3520 // Check built-in commands and user defined commands.
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
3521 // For ":2match" and ":3match" we need to skip the number.
862
bb084e291010 updated for version 7.0g03
vimboss
parents: 859
diff changeset
3522 ea.cmd = (*name == '2' || *name == '3') ? name + 1 : name;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3523 ea.cmdidx = (cmdidx_T)0;
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
3524 p = find_ex_command(&ea, &full, NULL, NULL);
866
5de6b337e1a2 updated for version 7.0g04
vimboss
parents: 862
diff changeset
3525 if (p == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3526 return 3;
862
bb084e291010 updated for version 7.0g03
vimboss
parents: 859
diff changeset
3527 if (vim_isdigit(*name) && ea.cmdidx != CMD_match)
bb084e291010 updated for version 7.0g03
vimboss
parents: 859
diff changeset
3528 return 0;
866
5de6b337e1a2 updated for version 7.0g04
vimboss
parents: 862
diff changeset
3529 if (*skipwhite(p) != NUL)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
3530 return 0; // trailing garbage
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3531 return (ea.cmdidx == CMD_SIZE ? 0 : (full ? 2 : 1));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3532 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3533 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3534
17835
fd6c8dc33152 patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents: 17823
diff changeset
3535 cmdidx_T
fd6c8dc33152 patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents: 17823
diff changeset
3536 excmd_get_cmdidx(char_u *cmd, int len)
fd6c8dc33152 patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents: 17823
diff changeset
3537 {
fd6c8dc33152 patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents: 17823
diff changeset
3538 cmdidx_T idx;
fd6c8dc33152 patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents: 17823
diff changeset
3539
fd6c8dc33152 patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents: 17823
diff changeset
3540 for (idx = (cmdidx_T)0; (int)idx < (int)CMD_SIZE;
fd6c8dc33152 patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents: 17823
diff changeset
3541 idx = (cmdidx_T)((int)idx + 1))
fd6c8dc33152 patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents: 17823
diff changeset
3542 if (STRNCMP(cmdnames[(int)idx].cmd_name, cmd, (size_t)len) == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3543 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3544
17835
fd6c8dc33152 patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents: 17823
diff changeset
3545 return idx;
fd6c8dc33152 patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents: 17823
diff changeset
3546 }
fd6c8dc33152 patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents: 17823
diff changeset
3547
fd6c8dc33152 patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents: 17823
diff changeset
3548 long
fd6c8dc33152 patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents: 17823
diff changeset
3549 excmd_get_argt(cmdidx_T idx)
fd6c8dc33152 patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents: 17823
diff changeset
3550 {
fd6c8dc33152 patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents: 17823
diff changeset
3551 return (long)cmdnames[(int)idx].cmd_argt;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3552 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3553
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3554 /*
14505
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3555 * Skip a range specifier of the form: addr [,addr] [;addr] ..
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3556 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3557 * Backslashed delimiters after / or ? will be skipped, and commands will
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3558 * not be expanded between /'s and ?'s or after "'".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3559 *
20982
bb49b5090a9c patch 8.2.1042: Vim9: cannot put an operator on the next line
Bram Moolenaar <Bram@vim.org>
parents: 20897
diff changeset
3560 * Also skip white space and ":" characters after the range.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3561 * Returns the "cmd" pointer advanced to beyond the range.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3562 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3563 char_u *
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
3564 skip_range(
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
3565 char_u *cmd,
22260
d7c1e3efa88e patch 8.2.1679: Vim9: ":*" is not recognized as a range
Bram Moolenaar <Bram@vim.org>
parents: 22208
diff changeset
3566 int skip_star, // skip "*" used for Visual range
d7c1e3efa88e patch 8.2.1679: Vim9: ":*" is not recognized as a range
Bram Moolenaar <Bram@vim.org>
parents: 22208
diff changeset
3567 int *ctx) // pointer to xp_context or NULL
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3568 {
1872
f13849167330 updated for version 7.2-169
vimboss
parents: 1868
diff changeset
3569 unsigned delim;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3570
10817
cc8079703414 patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents: 10809
diff changeset
3571 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
3572 {
cc8079703414 patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents: 10809
diff changeset
3573 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
3574 {
cc8079703414 patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents: 10809
diff changeset
3575 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
3576 ++cmd;
cc8079703414 patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents: 10809
diff changeset
3577 else
cc8079703414 patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents: 10809
diff changeset
3578 break;
cc8079703414 patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents: 10809
diff changeset
3579 }
cc8079703414 patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents: 10809
diff changeset
3580 else if (*cmd == '\'')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3581 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3582 if (*++cmd == NUL && ctx != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3583 *ctx = EXPAND_NOTHING;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3584 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3585 else if (*cmd == '/' || *cmd == '?')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3586 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3587 delim = *cmd++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3588 while (*cmd != NUL && *cmd != delim)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3589 if (*cmd++ == '\\' && *cmd != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3590 ++cmd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3591 if (*cmd == NUL && ctx != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3592 *ctx = EXPAND_NOTHING;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3593 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3594 if (*cmd != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3595 ++cmd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3596 }
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
3597
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
3598 // Skip ":" and white space.
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
3599 while (*cmd == ':')
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
3600 cmd = skipwhite(cmd + 1);
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
3601
22260
d7c1e3efa88e patch 8.2.1679: Vim9: ":*" is not recognized as a range
Bram Moolenaar <Bram@vim.org>
parents: 22208
diff changeset
3602 // Skip "*" used for Visual range.
d7c1e3efa88e patch 8.2.1679: Vim9: ":*" is not recognized as a range
Bram Moolenaar <Bram@vim.org>
parents: 22208
diff changeset
3603 if (skip_star && *cmd == '*' && vim_strchr(p_cpo, CPO_STAR) == NULL)
d7c1e3efa88e patch 8.2.1679: Vim9: ":*" is not recognized as a range
Bram Moolenaar <Bram@vim.org>
parents: 22208
diff changeset
3604 cmd = skipwhite(cmd + 1);
d7c1e3efa88e patch 8.2.1679: Vim9: ":*" is not recognized as a range
Bram Moolenaar <Bram@vim.org>
parents: 22208
diff changeset
3605
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3606 return cmd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3607 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3608
17650
a1437b8f2fac patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
3609 static void
a1437b8f2fac patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
3610 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
3611 {
a1437b8f2fac patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
3612 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
3613 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
3614 else
a1437b8f2fac patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
3615 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
3616 }
a1437b8f2fac patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
3617
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3618 /*
21939
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3619 * Return the default address for an address type.
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3620 */
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3621 static linenr_T
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3622 default_address(exarg_T *eap)
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3623 {
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3624 linenr_T lnum = 0;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3625
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3626 switch (eap->addr_type)
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3627 {
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3628 case ADDR_LINES:
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3629 case ADDR_OTHER:
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3630 // Default is the cursor line number. Avoid using an invalid
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3631 // line number though.
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3632 if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count)
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3633 lnum = curbuf->b_ml.ml_line_count;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3634 else
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3635 lnum = curwin->w_cursor.lnum;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3636 break;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3637 case ADDR_WINDOWS:
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3638 lnum = CURRENT_WIN_NR;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3639 break;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3640 case ADDR_ARGUMENTS:
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3641 lnum = curwin->w_arg_idx + 1;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3642 if (lnum > ARGCOUNT)
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3643 lnum = ARGCOUNT;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3644 break;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3645 case ADDR_LOADED_BUFFERS:
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3646 case ADDR_BUFFERS:
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3647 lnum = curbuf->b_fnum;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3648 break;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3649 case ADDR_TABS:
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3650 lnum = CURRENT_TAB_NR;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3651 break;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3652 case ADDR_TABS_RELATIVE:
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3653 case ADDR_UNSIGNED:
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3654 lnum = 1;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3655 break;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3656 case ADDR_QUICKFIX:
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3657 #ifdef FEAT_QUICKFIX
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3658 lnum = qf_get_cur_idx(eap);
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3659 #endif
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3660 break;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3661 case ADDR_QUICKFIX_VALID:
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3662 #ifdef FEAT_QUICKFIX
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3663 lnum = qf_get_cur_valid_idx(eap);
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3664 #endif
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3665 break;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3666 case ADDR_NONE:
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3667 // Will give an error later if a range is found.
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3668 break;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3669 }
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3670 return lnum;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3671 }
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3672
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3673 /*
14677
7771a1ff8b99 patch 8.1.0351: 'incsearch' for :/foo/s//<Esc> changes last search pattern
Christian Brabandt <cb@256bit.org>
parents: 14648
diff changeset
3674 * Get a single EX address.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3675 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3676 * Set ptr to the next character after the part that was interpreted.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3677 * 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
3678 * This may set the last used search pattern.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3679 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3680 * Return MAXLNUM when no Ex address was found.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3681 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3682 static linenr_T
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
3683 get_address(
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
3684 exarg_T *eap UNUSED,
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
3685 char_u **ptr,
18849
b77ef4b8af7c patch 8.1.2411: function argument copied unnecessarily
Bram Moolenaar <Bram@vim.org>
parents: 18779
diff changeset
3686 cmd_addr_T addr_type,
14760
fd69edd2c67e patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents: 14700
diff changeset
3687 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
3688 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
3689 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
3690 int address_count UNUSED) // 1 for first address, >1 after comma
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3691 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3692 int c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3693 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3694 long n;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3695 char_u *cmd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3696 pos_T pos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3697 pos_T *fp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3698 linenr_T lnum;
6424
de877dab1c31 updated for version 7.4.542
Bram Moolenaar <bram@vim.org>
parents: 6419
diff changeset
3699 buf_T *buf;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3700
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3701 cmd = skipwhite(*ptr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3702 lnum = MAXLNUM;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3703 do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3704 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3705 switch (*cmd)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3706 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
3707 case '.': // '.' - Cursor position
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3708 ++cmd;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3709 switch (addr_type)
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3710 {
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3711 case ADDR_LINES:
16475
854fb0ad4be6 patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents: 16451
diff changeset
3712 case ADDR_OTHER:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3713 lnum = curwin->w_cursor.lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3714 break;
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3715 case ADDR_WINDOWS:
6409
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
3716 lnum = CURRENT_WIN_NR;
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3717 break;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3718 case ADDR_ARGUMENTS:
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3719 lnum = curwin->w_arg_idx + 1;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3720 break;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3721 case ADDR_LOADED_BUFFERS:
6424
de877dab1c31 updated for version 7.4.542
Bram Moolenaar <bram@vim.org>
parents: 6419
diff changeset
3722 case ADDR_BUFFERS:
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3723 lnum = curbuf->b_fnum;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3724 break;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3725 case ADDR_TABS:
6409
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
3726 lnum = CURRENT_TAB_NR;
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3727 break;
17650
a1437b8f2fac patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
3728 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
3729 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
3730 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
3731 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
3732 cmd = NULL;
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
3733 goto error;
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
3734 break;
16479
7dcf301d1432 patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents: 16475
diff changeset
3735 case ADDR_QUICKFIX:
7105
f4456e686406 commit https://github.com/vim/vim/commit/e906c502079770ae0e0071c74cefb802689ff193
Christian Brabandt <cb@256bit.org>
parents: 7092
diff changeset
3736 #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
3737 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
3738 #endif
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
3739 break;
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
3740 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
3741 #ifdef FEAT_QUICKFIX
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7007
diff changeset
3742 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
3743 #endif
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7007
diff changeset
3744 break;
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3745 }
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3746 break;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3747
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
3748 case '$': // '$' - last line
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3749 ++cmd;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3750 switch (addr_type)
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3751 {
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3752 case ADDR_LINES:
16475
854fb0ad4be6 patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents: 16451
diff changeset
3753 case ADDR_OTHER:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3754 lnum = curbuf->b_ml.ml_line_count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3755 break;
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3756 case ADDR_WINDOWS:
6409
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
3757 lnum = LAST_WIN_NR;
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3758 break;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3759 case ADDR_ARGUMENTS:
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3760 lnum = ARGCOUNT;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3761 break;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3762 case ADDR_LOADED_BUFFERS:
6424
de877dab1c31 updated for version 7.4.542
Bram Moolenaar <bram@vim.org>
parents: 6419
diff changeset
3763 buf = lastbuf;
de877dab1c31 updated for version 7.4.542
Bram Moolenaar <bram@vim.org>
parents: 6419
diff changeset
3764 while (buf->b_ml.ml_mfp == NULL)
de877dab1c31 updated for version 7.4.542
Bram Moolenaar <bram@vim.org>
parents: 6419
diff changeset
3765 {
de877dab1c31 updated for version 7.4.542
Bram Moolenaar <bram@vim.org>
parents: 6419
diff changeset
3766 if (buf->b_prev == NULL)
de877dab1c31 updated for version 7.4.542
Bram Moolenaar <bram@vim.org>
parents: 6419
diff changeset
3767 break;
de877dab1c31 updated for version 7.4.542
Bram Moolenaar <bram@vim.org>
parents: 6419
diff changeset
3768 buf = buf->b_prev;
de877dab1c31 updated for version 7.4.542
Bram Moolenaar <bram@vim.org>
parents: 6419
diff changeset
3769 }
de877dab1c31 updated for version 7.4.542
Bram Moolenaar <bram@vim.org>
parents: 6419
diff changeset
3770 lnum = buf->b_fnum;
de877dab1c31 updated for version 7.4.542
Bram Moolenaar <bram@vim.org>
parents: 6419
diff changeset
3771 break;
de877dab1c31 updated for version 7.4.542
Bram Moolenaar <bram@vim.org>
parents: 6419
diff changeset
3772 case ADDR_BUFFERS:
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3773 lnum = lastbuf->b_fnum;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3774 break;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3775 case ADDR_TABS:
6409
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
3776 lnum = LAST_TAB_NR;
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3777 break;
17650
a1437b8f2fac patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
3778 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
3779 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
3780 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
3781 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
3782 cmd = NULL;
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
3783 goto error;
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
3784 break;
16479
7dcf301d1432 patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents: 16475
diff changeset
3785 case ADDR_QUICKFIX:
7105
f4456e686406 commit https://github.com/vim/vim/commit/e906c502079770ae0e0071c74cefb802689ff193
Christian Brabandt <cb@256bit.org>
parents: 7092
diff changeset
3786 #ifdef FEAT_QUICKFIX
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7007
diff changeset
3787 lnum = qf_get_size(eap);
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7007
diff changeset
3788 if (lnum == 0)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7007
diff changeset
3789 lnum = 1;
16479
7dcf301d1432 patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents: 16475
diff changeset
3790 #endif
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7007
diff changeset
3791 break;
16515
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
3792 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
3793 #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
3794 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
3795 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
3796 lnum = 1;
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
3797 #endif
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
3798 break;
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3799 }
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3800 break;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3801
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
3802 case '\'': // ''' - mark
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3803 if (*++cmd == NUL)
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3804 {
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3805 cmd = NULL;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3806 goto error;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3807 }
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3808 if (addr_type != ADDR_LINES)
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3809 {
17650
a1437b8f2fac patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
3810 addr_error(addr_type);
6581
05202d6ba0ef updated for version 7.4.617
Bram Moolenaar <bram@vim.org>
parents: 6506
diff changeset
3811 cmd = NULL;
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3812 goto error;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3813 }
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3814 if (skip)
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3815 ++cmd;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3816 else
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3817 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
3818 // Only accept a mark in another file when it is
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
3819 // used by itself: ":'M".
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3820 fp = getmark(*cmd, to_other_file && cmd[1] == NUL);
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3821 ++cmd;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3822 if (fp == (pos_T *)-1)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
3823 // Jumped to another file.
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3824 lnum = curwin->w_cursor.lnum;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3825 else
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3826 {
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3827 if (check_mark(fp) == FAIL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3828 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3829 cmd = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3830 goto error;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3831 }
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3832 lnum = fp->lnum;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3833 }
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3834 }
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3835 break;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3836
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3837 case '/':
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
3838 case '?': // '/' or '?' - search
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3839 c = *cmd++;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3840 if (addr_type != ADDR_LINES)
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3841 {
17650
a1437b8f2fac patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
3842 addr_error(addr_type);
6581
05202d6ba0ef updated for version 7.4.617
Bram Moolenaar <bram@vim.org>
parents: 6506
diff changeset
3843 cmd = NULL;
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3844 goto error;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3845 }
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
3846 if (skip) // skip "/pat/"
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3847 {
19892
5feb426d2ea1 patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19685
diff changeset
3848 cmd = skip_regexp(cmd, c, (int)p_magic);
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3849 if (*cmd == c)
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3850 ++cmd;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3851 }
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3852 else
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3853 {
14760
fd69edd2c67e patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents: 14700
diff changeset
3854 int flags;
fd69edd2c67e patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents: 14700
diff changeset
3855
fd69edd2c67e patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents: 14700
diff changeset
3856 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
3857
fd69edd2c67e patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents: 14700
diff changeset
3858 // 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
3859 // there.
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3860 if (lnum != MAXLNUM)
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3861 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
3862
fd69edd2c67e patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents: 14700
diff changeset
3863 // 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
3864 // 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
3865 // 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
3866 // 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
3867 // 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
3868 // next/previous line.
13082
a80082fd1a1d patch 8.0.1416: crash when searching for a sentence
Christian Brabandt <cb@256bit.org>
parents: 12824
diff changeset
3869 if (c == '/' && curwin->w_cursor.lnum > 0)
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3870 curwin->w_cursor.col = MAXCOL;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3871 else
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3872 curwin->w_cursor.col = 0;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3873 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
3874 flags = silent ? 0 : SEARCH_HIS | SEARCH_MSG;
19475
5512aa74cb62 patch 8.2.0295: highlighting for :s wrong when using different separator
Bram Moolenaar <Bram@vim.org>
parents: 19433
diff changeset
3875 if (!do_search(NULL, c, c, cmd, 1L, flags, NULL))
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3876 {
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3877 curwin->w_cursor = pos;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3878 cmd = NULL;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3879 goto error;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3880 }
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3881 lnum = curwin->w_cursor.lnum;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3882 curwin->w_cursor = pos;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
3883 // adjust command string pointer
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3884 cmd += searchcmdlen;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3885 }
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3886 break;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3887
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
3888 case '\\': // "\?", "\/" or "\&", repeat search
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3889 ++cmd;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3890 if (addr_type != ADDR_LINES)
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3891 {
17650
a1437b8f2fac patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
3892 addr_error(addr_type);
6581
05202d6ba0ef updated for version 7.4.617
Bram Moolenaar <bram@vim.org>
parents: 6506
diff changeset
3893 cmd = NULL;
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3894 goto error;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3895 }
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3896 if (*cmd == '&')
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3897 i = RE_SUBST;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3898 else if (*cmd == '?' || *cmd == '/')
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3899 i = RE_SEARCH;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3900 else
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3901 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
3902 emsg(_(e_backslash));
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3903 cmd = NULL;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3904 goto error;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3905 }
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3906
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3907 if (!skip)
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3908 {
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3909 /*
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3910 * When search follows another address, start from
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3911 * there.
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3912 */
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3913 if (lnum != MAXLNUM)
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3914 pos.lnum = lnum;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3915 else
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3916 pos.lnum = curwin->w_cursor.lnum;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3917
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3918 /*
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3919 * Start the search just like for the above
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3920 * do_search().
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3921 */
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3922 if (*cmd != '?')
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3923 pos.col = MAXCOL;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3924 else
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3925 pos.col = 0;
7007
5ea5bd9c18d2 patch 7.4.821
Bram Moolenaar <bram@vim.org>
parents: 6987
diff changeset
3926 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
3927 if (searchit(curwin, curbuf, &pos, NULL,
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3928 *cmd == '?' ? BACKWARD : FORWARD,
18358
34d5cd432cac patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents: 18297
diff changeset
3929 (char_u *)"", 1L, SEARCH_MSG, i, NULL) != FAIL)
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3930 lnum = pos.lnum;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3931 else
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3932 {
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3933 cmd = NULL;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3934 goto error;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3935 }
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3936 }
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3937 ++cmd;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3938 break;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3939
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3940 default:
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
3941 if (VIM_ISDIGIT(*cmd)) // absolute line number
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3942 lnum = getdigits(&cmd);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3943 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3944
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3945 for (;;)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3946 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3947 cmd = skipwhite(cmd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3948 if (*cmd != '-' && *cmd != '+' && !VIM_ISDIGIT(*cmd))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3949 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3950
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3951 if (lnum == MAXLNUM)
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3952 {
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3953 switch (addr_type)
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3954 {
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3955 case ADDR_LINES:
16475
854fb0ad4be6 patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents: 16451
diff changeset
3956 case ADDR_OTHER:
854fb0ad4be6 patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents: 16451
diff changeset
3957 // "+1" is same as ".+1"
6409
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
3958 lnum = curwin->w_cursor.lnum;
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3959 break;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3960 case ADDR_WINDOWS:
6409
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
3961 lnum = CURRENT_WIN_NR;
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3962 break;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3963 case ADDR_ARGUMENTS:
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3964 lnum = curwin->w_arg_idx + 1;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3965 break;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3966 case ADDR_LOADED_BUFFERS:
6424
de877dab1c31 updated for version 7.4.542
Bram Moolenaar <bram@vim.org>
parents: 6419
diff changeset
3967 case ADDR_BUFFERS:
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3968 lnum = curbuf->b_fnum;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3969 break;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3970 case ADDR_TABS:
6409
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
3971 lnum = CURRENT_TAB_NR;
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3972 break;
10739
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
3973 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
3974 lnum = 1;
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
3975 break;
16479
7dcf301d1432 patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents: 16475
diff changeset
3976 case ADDR_QUICKFIX:
7105
f4456e686406 commit https://github.com/vim/vim/commit/e906c502079770ae0e0071c74cefb802689ff193
Christian Brabandt <cb@256bit.org>
parents: 7092
diff changeset
3977 #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
3978 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
3979 #endif
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
3980 break;
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
3981 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
3982 #ifdef FEAT_QUICKFIX
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7007
diff changeset
3983 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
3984 #endif
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7007
diff changeset
3985 break;
16475
854fb0ad4be6 patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents: 16451
diff changeset
3986 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
3987 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
3988 lnum = 0;
16475
854fb0ad4be6 patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents: 16451
diff changeset
3989 break;
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3990 }
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3991 }
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
3992
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3993 if (VIM_ISDIGIT(*cmd))
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
3994 i = '+'; // "number" is same as "+number"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3995 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3996 i = *cmd++;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
3997 if (!VIM_ISDIGIT(*cmd)) // '+' is '+1', but '+0' is not '+1'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3998 n = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3999 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4000 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
4001
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
4002 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
4003 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
4004 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
4005 cmd = NULL;
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
4006 goto error;
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
4007 }
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
4008 else if (addr_type == ADDR_LOADED_BUFFERS
6424
de877dab1c31 updated for version 7.4.542
Bram Moolenaar <bram@vim.org>
parents: 6419
diff changeset
4009 || addr_type == ADDR_BUFFERS)
6581
05202d6ba0ef updated for version 7.4.617
Bram Moolenaar <bram@vim.org>
parents: 6506
diff changeset
4010 lnum = compute_buffer_local_count(
05202d6ba0ef updated for version 7.4.617
Bram Moolenaar <bram@vim.org>
parents: 6506
diff changeset
4011 addr_type, lnum, (i == '-') ? -1 * n : n);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4012 else
10484
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents: 10480
diff changeset
4013 {
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents: 10480
diff changeset
4014 #ifdef FEAT_FOLDING
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4015 // Relative line addressing, need to adjust for folded lines
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4016 // now, but only do it after the first address.
10484
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents: 10480
diff changeset
4017 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
4018 && address_count >= 2)
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents: 10480
diff changeset
4019 (void)hasFolding(lnum, NULL, &lnum);
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents: 10480
diff changeset
4020 #endif
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents: 10480
diff changeset
4021 if (i == '-')
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents: 10480
diff changeset
4022 lnum -= n;
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents: 10480
diff changeset
4023 else
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents: 10480
diff changeset
4024 lnum += n;
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents: 10480
diff changeset
4025 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4026 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4027 } while (*cmd == '/' || *cmd == '?');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4028
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4029 error:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4030 *ptr = cmd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4031 return lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4032 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4033
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4034 /*
21939
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4035 * Set eap->line1 and eap->line2 to the whole range.
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4036 * Used for commands with the EX_DFLALL flag and no range given.
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4037 */
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4038 static void
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4039 address_default_all(exarg_T *eap)
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4040 {
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4041 eap->line1 = 1;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4042 switch (eap->addr_type)
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4043 {
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4044 case ADDR_LINES:
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4045 case ADDR_OTHER:
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4046 eap->line2 = curbuf->b_ml.ml_line_count;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4047 break;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4048 case ADDR_LOADED_BUFFERS:
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4049 {
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4050 buf_T *buf = firstbuf;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4051
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4052 while (buf->b_next != NULL && buf->b_ml.ml_mfp == NULL)
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4053 buf = buf->b_next;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4054 eap->line1 = buf->b_fnum;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4055 buf = lastbuf;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4056 while (buf->b_prev != NULL && buf->b_ml.ml_mfp == NULL)
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4057 buf = buf->b_prev;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4058 eap->line2 = buf->b_fnum;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4059 }
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4060 break;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4061 case ADDR_BUFFERS:
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4062 eap->line1 = firstbuf->b_fnum;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4063 eap->line2 = lastbuf->b_fnum;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4064 break;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4065 case ADDR_WINDOWS:
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4066 eap->line2 = LAST_WIN_NR;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4067 break;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4068 case ADDR_TABS:
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4069 eap->line2 = LAST_TAB_NR;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4070 break;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4071 case ADDR_TABS_RELATIVE:
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4072 eap->line2 = 1;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4073 break;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4074 case ADDR_ARGUMENTS:
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4075 if (ARGCOUNT == 0)
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4076 eap->line1 = eap->line2 = 0;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4077 else
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4078 eap->line2 = ARGCOUNT;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4079 break;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4080 case ADDR_QUICKFIX_VALID:
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4081 #ifdef FEAT_QUICKFIX
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4082 eap->line2 = qf_get_valid_size(eap);
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4083 if (eap->line2 == 0)
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4084 eap->line2 = 1;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4085 #endif
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4086 break;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4087 case ADDR_NONE:
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4088 case ADDR_UNSIGNED:
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4089 case ADDR_QUICKFIX:
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4090 iemsg(_("INTERNAL: Cannot use EX_DFLALL with ADDR_NONE, ADDR_UNSIGNED or ADDR_QUICKFIX"));
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4091 break;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4092 }
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4093 }
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4094
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4095
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4096 /*
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
4097 * Get flags from an Ex command argument.
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
4098 */
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
4099 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
4100 get_flags(exarg_T *eap)
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
4101 {
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
4102 while (vim_strchr((char_u *)"lp#", *eap->arg) != NULL)
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
4103 {
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
4104 if (*eap->arg == 'l')
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
4105 eap->flags |= EXFLAG_LIST;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
4106 else if (*eap->arg == 'p')
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
4107 eap->flags |= EXFLAG_PRINT;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
4108 else
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
4109 eap->flags |= EXFLAG_NR;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
4110 eap->arg = skipwhite(eap->arg + 1);
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
4111 }
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
4112 }
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
4113
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
4114 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4115 * Function called for command which is Not Implemented. NI!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4116 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4117 void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
4118 ex_ni(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4119 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4120 if (!eap->skip)
21459
a422bd80b434 patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents: 21413
diff changeset
4121 eap->errmsg =
a422bd80b434 patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents: 21413
diff changeset
4122 _("E319: Sorry, the command is not available in this version");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4123 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4124
1315
0868e4e53fb2 updated for version 7.1-029
vimboss
parents: 1305
diff changeset
4125 #ifdef HAVE_EX_SCRIPT_NI
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4126 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4127 * Function called for script command which is Not Implemented. NI!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4128 * Skips over ":perl <<EOF" constructs.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4129 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4130 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
4131 ex_script_ni(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4132 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4133 if (!eap->skip)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4134 ex_ni(eap);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4135 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4136 vim_free(script_get(eap, eap->arg));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4137 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4138 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4139
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4140 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4141 * Check range in Ex command for validity.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4142 * Return NULL when valid, error message when invalid.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4143 */
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
4144 static char *
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
4145 invalid_range(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4146 {
6472
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4147 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
4148
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4149 if ( eap->line1 < 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4150 || eap->line2 < 0
6472
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4151 || 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
4152 return _(e_invrange);
6472
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4153
17336
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
4154 if (eap->argt & EX_RANGE)
6472
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4155 {
16475
854fb0ad4be6 patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents: 16451
diff changeset
4156 switch (eap->addr_type)
6472
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4157 {
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4158 case ADDR_LINES:
16475
854fb0ad4be6 patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents: 16451
diff changeset
4159 if (eap->line2 > curbuf->b_ml.ml_line_count
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4160 #ifdef FEAT_DIFF
6472
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4161 + (eap->cmdidx == CMD_diffget)
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4162 #endif
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4163 )
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
4164 return _(e_invrange);
6472
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4165 break;
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4166 case ADDR_ARGUMENTS:
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4167 // add 1 if ARGCOUNT is 0
6581
05202d6ba0ef updated for version 7.4.617
Bram Moolenaar <bram@vim.org>
parents: 6506
diff changeset
4168 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
4169 return _(e_invrange);
6472
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4170 break;
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4171 case ADDR_BUFFERS:
17823
7e6b7a4f13bc patch 8.1.1908: every popup window consumes a buffer number
Bram Moolenaar <Bram@vim.org>
parents: 17817
diff changeset
4172 // Only a boundary check, not whether the buffers actually
7e6b7a4f13bc patch 8.1.1908: every popup window consumes a buffer number
Bram Moolenaar <Bram@vim.org>
parents: 17817
diff changeset
4173 // exist.
7e6b7a4f13bc patch 8.1.1908: every popup window consumes a buffer number
Bram Moolenaar <Bram@vim.org>
parents: 17817
diff changeset
4174 if (eap->line1 < 1 || eap->line2 > get_highest_fnum())
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
4175 return _(e_invrange);
6472
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4176 break;
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4177 case ADDR_LOADED_BUFFERS:
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4178 buf = firstbuf;
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4179 while (buf->b_ml.ml_mfp == NULL)
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4180 {
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4181 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
4182 return _(e_invrange);
6472
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4183 buf = buf->b_next;
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4184 }
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4185 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
4186 return _(e_invrange);
6472
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4187 buf = lastbuf;
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4188 while (buf->b_ml.ml_mfp == NULL)
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4189 {
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4190 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
4191 return _(e_invrange);
6472
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4192 buf = buf->b_prev;
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4193 }
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4194 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
4195 return _(e_invrange);
6472
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4196 break;
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4197 case ADDR_WINDOWS:
6480
747cbac7047b updated for version 7.4.568
Bram Moolenaar <bram@vim.org>
parents: 6472
diff changeset
4198 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
4199 return _(e_invrange);
6472
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4200 break;
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4201 case ADDR_TABS:
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4202 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
4203 return _(e_invrange);
6472
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4204 break;
10739
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
4205 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
4206 case ADDR_OTHER:
854fb0ad4be6 patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents: 16451
diff changeset
4207 // 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
4208 break;
16479
7dcf301d1432 patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents: 16475
diff changeset
4209 case ADDR_QUICKFIX:
7105
f4456e686406 commit https://github.com/vim/vim/commit/e906c502079770ae0e0071c74cefb802689ff193
Christian Brabandt <cb@256bit.org>
parents: 7092
diff changeset
4210 #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
4211 // 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
4212 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
4213 return _(e_invrange);
16479
7dcf301d1432 patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents: 16475
diff changeset
4214 #endif
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7007
diff changeset
4215 break;
16515
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
4216 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
4217 #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
4218 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
4219 || 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
4220 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
4221 #endif
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
4222 break;
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
4223 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
4224 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
4225 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
4226 break;
16475
854fb0ad4be6 patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents: 16451
diff changeset
4227 case ADDR_NONE:
854fb0ad4be6 patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents: 16451
diff changeset
4228 // 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
4229 break;
6472
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4230 }
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4231 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4232 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4233 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4234
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4235 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4236 * Correct the range for zero line number, if required.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4237 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4238 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
4239 correct_range(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4240 {
17336
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
4241 if (!(eap->argt & EX_ZEROR)) // zero in range not allowed
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4242 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4243 if (eap->line1 == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4244 eap->line1 = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4245 if (eap->line2 == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4246 eap->line2 = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4247 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4248 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4249
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4250 #ifdef FEAT_QUICKFIX
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4251 /*
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4252 * For a ":vimgrep" or ":vimgrepadd" command return a pointer past the
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4253 * pattern. Otherwise return eap->arg.
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4254 */
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4255 static char_u *
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
4256 skip_grep_pat(exarg_T *eap)
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4257 {
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4258 char_u *p = eap->arg;
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4259
655
7566e1cda7bf updated for version 7.0193
vimboss
parents: 649
diff changeset
4260 if (*p != NUL && (eap->cmdidx == CMD_vimgrep || eap->cmdidx == CMD_lvimgrep
7566e1cda7bf updated for version 7.0193
vimboss
parents: 649
diff changeset
4261 || eap->cmdidx == CMD_vimgrepadd
7566e1cda7bf updated for version 7.0193
vimboss
parents: 649
diff changeset
4262 || eap->cmdidx == CMD_lvimgrepadd
7566e1cda7bf updated for version 7.0193
vimboss
parents: 649
diff changeset
4263 || grep_internal(eap->cmdidx)))
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4264 {
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4265 p = skip_vimgrep_pat(p, NULL, NULL);
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4266 if (p == NULL)
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4267 p = eap->arg;
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4268 }
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4269 return p;
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4270 }
344
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4271
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4272 /*
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4273 * For the ":make" and ":grep" commands insert the 'makeprg'/'grepprg' option
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4274 * in the command line, so that things like % get expanded.
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4275 */
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4276 static char_u *
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
4277 replace_makeprg(exarg_T *eap, char_u *p, char_u **cmdlinep)
344
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4278 {
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4279 char_u *new_cmdline;
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4280 char_u *program;
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4281 char_u *pos;
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4282 char_u *ptr;
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4283 int len;
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4284 int i;
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4285
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4286 /*
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4287 * Don't do it when ":vimgrep" is used for ":grep".
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4288 */
655
7566e1cda7bf updated for version 7.0193
vimboss
parents: 649
diff changeset
4289 if ((eap->cmdidx == CMD_make || eap->cmdidx == CMD_lmake
7566e1cda7bf updated for version 7.0193
vimboss
parents: 649
diff changeset
4290 || eap->cmdidx == CMD_grep || eap->cmdidx == CMD_lgrep
7566e1cda7bf updated for version 7.0193
vimboss
parents: 649
diff changeset
4291 || eap->cmdidx == CMD_grepadd
7566e1cda7bf updated for version 7.0193
vimboss
parents: 649
diff changeset
4292 || eap->cmdidx == CMD_lgrepadd)
344
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4293 && !grep_internal(eap->cmdidx))
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4294 {
655
7566e1cda7bf updated for version 7.0193
vimboss
parents: 649
diff changeset
4295 if (eap->cmdidx == CMD_grep || eap->cmdidx == CMD_lgrep
7566e1cda7bf updated for version 7.0193
vimboss
parents: 649
diff changeset
4296 || eap->cmdidx == CMD_grepadd || eap->cmdidx == CMD_lgrepadd)
344
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4297 {
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4298 if (*curbuf->b_p_gp == NUL)
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4299 program = p_gp;
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4300 else
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4301 program = curbuf->b_p_gp;
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4302 }
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4303 else
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4304 {
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4305 if (*curbuf->b_p_mp == NUL)
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4306 program = p_mp;
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4307 else
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4308 program = curbuf->b_p_mp;
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4309 }
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4310
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4311 p = skipwhite(p);
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4312
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4313 if ((pos = (char_u *)strstr((char *)program, "$*")) != NULL)
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4314 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4315 // replace $* by given arguments
344
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4316 i = 1;
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4317 while ((pos = (char_u *)strstr((char *)pos + 2, "$*")) != NULL)
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4318 ++i;
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4319 len = (int)STRLEN(p);
16782
fc58fee685e2 patch 8.1.1393: unnecessary type casts
Bram Moolenaar <Bram@vim.org>
parents: 16780
diff changeset
4320 new_cmdline = alloc(STRLEN(program) + i * (len - 2) + 1);
344
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4321 if (new_cmdline == NULL)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4322 return NULL; // out of memory
344
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4323 ptr = new_cmdline;
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4324 while ((pos = (char_u *)strstr((char *)program, "$*")) != NULL)
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4325 {
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4326 i = (int)(pos - program);
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4327 STRNCPY(ptr, program, i);
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4328 STRCPY(ptr += i, p);
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4329 ptr += len;
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4330 program = pos + 2;
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4331 }
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4332 STRCPY(ptr, program);
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4333 }
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4334 else
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4335 {
16782
fc58fee685e2 patch 8.1.1393: unnecessary type casts
Bram Moolenaar <Bram@vim.org>
parents: 16780
diff changeset
4336 new_cmdline = alloc(STRLEN(program) + STRLEN(p) + 2);
344
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4337 if (new_cmdline == NULL)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4338 return NULL; // out of memory
344
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4339 STRCPY(new_cmdline, program);
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4340 STRCAT(new_cmdline, " ");
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4341 STRCAT(new_cmdline, p);
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4342 }
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4343 msg_make(p);
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4344
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4345 // 'eap->cmd' is not set here, because it is not used at CMD_make
344
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4346 vim_free(*cmdlinep);
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4347 *cmdlinep = new_cmdline;
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4348 p = new_cmdline;
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4349 }
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4350 return p;
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4351 }
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4352 #endif
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4353
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4354 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4355 * 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
4356 * When an error is detected, "errormsgp" is set to a non-NULL pointer.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4357 * Return FAIL for failure, OK otherwise.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4358 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4359 int
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
4360 expand_filename(
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
4361 exarg_T *eap,
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
4362 char_u **cmdlinep,
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
4363 char **errormsgp)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4364 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4365 int has_wildcards; // need to expand wildcards
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4366 char_u *repl;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4367 int srclen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4368 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4369 int n;
1098
5a1d8468d1fa updated for version 7.0-224
vimboss
parents: 1090
diff changeset
4370 int escaped;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4371
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4372 #ifdef FEAT_QUICKFIX
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4373 // Skip a regexp pattern for ":vimgrep[add] pat file..."
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4374 p = skip_grep_pat(eap);
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4375 #else
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4376 p = eap->arg;
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4377 #endif
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4378
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4379 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4380 * Decide to expand wildcards *before* replacing '%', '#', etc. If
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4381 * the file name contains a wildcard it should not cause expanding.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4382 * (it will be expanded anyway if there is a wildcard before replacing).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4383 */
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4384 has_wildcards = mch_has_wildcard(p);
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4385 while (*p != NUL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4386 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 8
diff changeset
4387 #ifdef FEAT_EVAL
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4388 // Skip over `=expr`, wildcards in it are not expanded.
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 8
diff changeset
4389 if (p[0] == '`' && p[1] == '=')
4102fb4ea781 updated for version 7.0002
vimboss
parents: 8
diff changeset
4390 {
4102fb4ea781 updated for version 7.0002
vimboss
parents: 8
diff changeset
4391 p += 2;
4102fb4ea781 updated for version 7.0002
vimboss
parents: 8
diff changeset
4392 (void)skip_expr(&p);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 8
diff changeset
4393 if (*p == '`')
4102fb4ea781 updated for version 7.0002
vimboss
parents: 8
diff changeset
4394 ++p;
4102fb4ea781 updated for version 7.0002
vimboss
parents: 8
diff changeset
4395 continue;
4102fb4ea781 updated for version 7.0002
vimboss
parents: 8
diff changeset
4396 }
4102fb4ea781 updated for version 7.0002
vimboss
parents: 8
diff changeset
4397 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4398 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4399 * Quick check if this cannot be the start of a special string.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4400 * Also removes backslash before '%', '#' and '<'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4401 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4402 if (vim_strchr((char_u *)"%#<", *p) == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4403 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4404 ++p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4405 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4406 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4407
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4408 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4409 * Try to find a match at this position.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4410 */
1098
5a1d8468d1fa updated for version 7.0-224
vimboss
parents: 1090
diff changeset
4411 repl = eval_vars(p, eap->arg, &srclen, &(eap->do_ecmd_lnum),
5a1d8468d1fa updated for version 7.0-224
vimboss
parents: 1090
diff changeset
4412 errormsgp, &escaped);
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4413 if (*errormsgp != NULL) // error detected
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4414 return FAIL;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4415 if (repl == NULL) // no match found
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4416 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4417 p += srclen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4418 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4419 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4420
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4421 // Wildcards won't be expanded below, the replacement is taken
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4422 // literally. But do expand "~/file", "~user/file" and "$HOME/file".
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
4423 if (vim_strchr(repl, '$') != NULL || vim_strchr(repl, '~') != NULL)
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
4424 {
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
4425 char_u *l = repl;
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
4426
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
4427 repl = expand_env_save(repl);
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
4428 vim_free(l);
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
4429 }
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
4430
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4431 // Need to escape white space et al. with a backslash.
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4432 // Don't do this for:
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4433 // - replacement that already has been escaped: "##"
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4434 // - shell commands (may have to use quotes instead).
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4435 // - non-unix systems when there is a single argument (spaces don't
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4436 // separate arguments then).
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4437 if (!eap->usefilter
1098
5a1d8468d1fa updated for version 7.0-224
vimboss
parents: 1090
diff changeset
4438 && !escaped
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4439 && eap->cmdidx != CMD_bang
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4440 && 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
4441 && eap->cmdidx != CMD_grepadd
1c1cb1e9b7b3 patch 8.0.0785: wildcards are not expanded for :terminal
Christian Brabandt <cb@256bit.org>
parents: 11757
diff changeset
4442 && eap->cmdidx != CMD_hardcopy
655
7566e1cda7bf updated for version 7.0193
vimboss
parents: 649
diff changeset
4443 && eap->cmdidx != CMD_lgrep
7566e1cda7bf updated for version 7.0193
vimboss
parents: 649
diff changeset
4444 && 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
4445 && eap->cmdidx != CMD_lmake
1c1cb1e9b7b3 patch 8.0.0785: wildcards are not expanded for :terminal
Christian Brabandt <cb@256bit.org>
parents: 11757
diff changeset
4446 && eap->cmdidx != CMD_make
1c1cb1e9b7b3 patch 8.0.0785: wildcards are not expanded for :terminal
Christian Brabandt <cb@256bit.org>
parents: 11757
diff changeset
4447 && eap->cmdidx != CMD_terminal
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4448 #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
4449 && !(eap->argt & EX_NOSPC)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4450 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4451 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4452 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4453 char_u *l;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4454 #ifdef BACKSLASH_IN_FILENAME
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4455 // Don't escape a backslash here, because rem_backslash() doesn't
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4456 // remove it later.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4457 static char_u *nobslash = (char_u *)" \t\"|";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4458 # define ESCAPE_CHARS nobslash
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4459 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4460 # define ESCAPE_CHARS escape_chars
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4461 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4462
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4463 for (l = repl; *l; ++l)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4464 if (vim_strchr(ESCAPE_CHARS, *l) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4465 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4466 l = vim_strsave_escaped(repl, ESCAPE_CHARS);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4467 if (l != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4468 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4469 vim_free(repl);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4470 repl = l;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4471 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4472 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4473 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4474 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4475
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4476 // 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
4477 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
4478 || eap->cmdidx == CMD_terminal)
5778
22a1d5762ba3 updated for version 7.4.233
Bram Moolenaar <bram@vim.org>
parents: 5776
diff changeset
4479 && vim_strpbrk(repl, (char_u *)"!") != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4480 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4481 char_u *l;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4482
5778
22a1d5762ba3 updated for version 7.4.233
Bram Moolenaar <bram@vim.org>
parents: 5776
diff changeset
4483 l = vim_strsave_escaped(repl, (char_u *)"!");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4484 if (l != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4485 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4486 vim_free(repl);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4487 repl = l;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4488 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4489 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4490
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4491 p = repl_cmdline(eap, p, srclen, repl, cmdlinep);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4492 vim_free(repl);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4493 if (p == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4494 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4495 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4496
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4497 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4498 * One file argument: Expand wildcards.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4499 * Don't do this with ":r !command" or ":w !command".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4500 */
17336
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
4501 if ((eap->argt & EX_NOSPC) && !eap->usefilter)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4502 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4503 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4504 * May do this twice:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4505 * 1. Replace environment variables.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4506 * 2. Replace any other wildcards, remove backslashes.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4507 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4508 for (n = 1; n <= 2; ++n)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4509 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4510 if (n == 2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4511 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4512 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4513 * Halve the number of backslashes (this is Vi compatible).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4514 * For Unix and OS/2, when wildcards are expanded, this is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4515 * done by ExpandOne() below.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4516 */
7408
1886f2863437 commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents: 7262
diff changeset
4517 #if defined(UNIX)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4518 if (!has_wildcards)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4519 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4520 backslash_halve(eap->arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4521 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4522
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4523 if (has_wildcards)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4524 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4525 if (n == 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4526 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4527 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4528 * First loop: May expand environment variables. This
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4529 * can be done much faster with expand_env() than with
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4530 * something else (e.g., calling a shell).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4531 * After expanding environment variables, check again
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4532 * if there are still wildcards present.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4533 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4534 if (vim_strchr(eap->arg, '$') != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4535 || vim_strchr(eap->arg, '~') != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4536 {
372
a698eb686ded updated for version 7.0096
vimboss
parents: 358
diff changeset
4537 expand_env_esc(eap->arg, NameBuff, MAXPATHL,
1408
db8309865794 updated for version 7.1-123
vimboss
parents: 1369
diff changeset
4538 TRUE, TRUE, NULL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4539 has_wildcards = mch_has_wildcard(NameBuff);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4540 p = NameBuff;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4541 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4542 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4543 p = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4544 }
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4545 else // n == 2
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4546 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4547 expand_T xpc;
18386
105c6cf8b266 patch 8.1.2187: error for bad regexp even though regexp is not used
Bram Moolenaar <Bram@vim.org>
parents: 18358
diff changeset
4548 int options = WILD_LIST_NOTFOUND
105c6cf8b266 patch 8.1.2187: error for bad regexp even though regexp is not used
Bram Moolenaar <Bram@vim.org>
parents: 18358
diff changeset
4549 | WILD_NOERROR | WILD_ADD_SLASH;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4550
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4551 ExpandInit(&xpc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4552 xpc.xp_context = EXPAND_FILES;
2652
b2a7d143abe2 updated for version 7.3.072
Bram Moolenaar <bram@vim.org>
parents: 2645
diff changeset
4553 if (p_wic)
b2a7d143abe2 updated for version 7.3.072
Bram Moolenaar <bram@vim.org>
parents: 2645
diff changeset
4554 options += WILD_ICASE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4555 p = ExpandOne(&xpc, eap->arg, NULL,
2652
b2a7d143abe2 updated for version 7.3.072
Bram Moolenaar <bram@vim.org>
parents: 2645
diff changeset
4556 options, WILD_EXPAND_FREE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4557 if (p == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4558 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4559 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4560 if (p != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4561 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4562 (void)repl_cmdline(eap, eap->arg, (int)STRLEN(eap->arg),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4563 p, cmdlinep);
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4564 if (n == 2) // p came from ExpandOne()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4565 vim_free(p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4566 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4567 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4568 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4569 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4570 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4571 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4572
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4573 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4574 * Replace part of the command line, keeping eap->cmd, eap->arg and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4575 * eap->nextcmd correct.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4576 * "src" points to the part that is to be replaced, of length "srclen".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4577 * "repl" is the replacement string.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4578 * Returns a pointer to the character after the replaced string.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4579 * Returns NULL for failure.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4580 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4581 static char_u *
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
4582 repl_cmdline(
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
4583 exarg_T *eap,
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
4584 char_u *src,
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
4585 int srclen,
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
4586 char_u *repl,
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
4587 char_u **cmdlinep)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4588 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4589 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4590 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4591 char_u *new_cmdline;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4592
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4593 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4594 * The new command line is build in new_cmdline[].
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4595 * First allocate it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4596 * Careful: a "+cmd" argument may have been NUL terminated.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4597 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4598 len = (int)STRLEN(repl);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4599 i = (int)(src - *cmdlinep) + (int)STRLEN(src + srclen) + len + 3;
698
e402b0af6083 updated for version 7.0211
vimboss
parents: 694
diff changeset
4600 if (eap->nextcmd != NULL)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4601 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
4602 if ((new_cmdline = alloc(i)) == NULL)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4603 return NULL; // out of memory!
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4604
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4605 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4606 * Copy the stuff before the expanded part.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4607 * Copy the expanded stuff.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4608 * Copy what came after the expanded part.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4609 * Copy the next commands, if there are any.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4610 */
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4611 i = (int)(src - *cmdlinep); // length of part before match
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4612 mch_memmove(new_cmdline, *cmdlinep, (size_t)i);
434
9595cf1d80a7 updated for version 7.0112
vimboss
parents: 416
diff changeset
4613
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4614 mch_memmove(new_cmdline + i, repl, (size_t)len);
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4615 i += len; // remember the end of the string
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4616 STRCPY(new_cmdline + i, src + srclen);
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4617 src = new_cmdline + i; // remember where to continue
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4618
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4619 if (eap->nextcmd != NULL) // append next command
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4620 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4621 i = (int)STRLEN(new_cmdline) + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4622 STRCPY(new_cmdline + i, eap->nextcmd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4623 eap->nextcmd = new_cmdline + i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4624 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4625 eap->cmd = new_cmdline + (eap->cmd - *cmdlinep);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4626 eap->arg = new_cmdline + (eap->arg - *cmdlinep);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4627 if (eap->do_ecmd_cmd != NULL && eap->do_ecmd_cmd != dollar_command)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4628 eap->do_ecmd_cmd = new_cmdline + (eap->do_ecmd_cmd - *cmdlinep);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4629 vim_free(*cmdlinep);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4630 *cmdlinep = new_cmdline;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4631
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4632 return src;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4633 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4634
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4635 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4636 * Check for '|' to separate commands and '"' to start comments.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4637 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4638 void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
4639 separate_nextcmd(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4640 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4641 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4642
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4643 #ifdef FEAT_QUICKFIX
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4644 p = skip_grep_pat(eap);
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4645 #else
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 40
diff changeset
4646 p = eap->arg;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 40
diff changeset
4647 #endif
f529edb9bab3 updated for version 7.0025
vimboss
parents: 40
diff changeset
4648
11127
506f5d8b7d8b patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 11010
diff changeset
4649 for ( ; *p; MB_PTR_ADV(p))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4650 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4651 if (*p == Ctrl_V)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4652 {
17336
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
4653 if (eap->argt & (EX_CTRLV | EX_XFILE))
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4654 ++p; // skip CTRL-V and next char
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4655 else
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4656 // remove CTRL-V and skip next char
1619
b9740fb41986 updated for version 7.2a
vimboss
parents: 1613
diff changeset
4657 STRMOVE(p, p + 1);
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4658 if (*p == NUL) // stop at NUL after CTRL-V
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4659 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4660 }
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 8
diff changeset
4661
4102fb4ea781 updated for version 7.0002
vimboss
parents: 8
diff changeset
4662 #ifdef FEAT_EVAL
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4663 // 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
4664 else if (p[0] == '`' && p[1] == '=' && (eap->argt & EX_XFILE))
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 8
diff changeset
4665 {
4102fb4ea781 updated for version 7.0002
vimboss
parents: 8
diff changeset
4666 p += 2;
4102fb4ea781 updated for version 7.0002
vimboss
parents: 8
diff changeset
4667 (void)skip_expr(&p);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 8
diff changeset
4668 }
4102fb4ea781 updated for version 7.0002
vimboss
parents: 8
diff changeset
4669 #endif
4102fb4ea781 updated for version 7.0002
vimboss
parents: 8
diff changeset
4670
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4671 // Check for '"': start of comment or '|': next command
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4672 // :@" and :*" do not start a comment!
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4673 // :redir @" doesn't either.
21353
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
4674 else if ((*p == '"'
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
4675 #ifdef FEAT_EVAL
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
4676 && !in_vim9script()
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
4677 #endif
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
4678 && !(eap->argt & EX_NOTRLCOM)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4679 && ((eap->cmdidx != CMD_at && eap->cmdidx != CMD_star)
21353
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
4680 || p != eap->arg)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4681 && (eap->cmdidx != CMD_redir
21353
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
4682 || p != eap->arg + 1 || p[-1] != '@'))
20079
336483164ca6 patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents: 20075
diff changeset
4683 #ifdef FEAT_EVAL
21353
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
4684 || (*p == '#'
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
4685 && in_vim9script()
21893
f19ac9b8b011 patch 8.2.1496: Vim9: cannot use " #" in a mapping
Bram Moolenaar <Bram@vim.org>
parents: 21885
diff changeset
4686 && !(eap->argt & EX_NOTRLCOM)
21353
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
4687 && p[1] != '{'
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
4688 && p > eap->cmd && VIM_ISWHITE(p[-1]))
20079
336483164ca6 patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents: 20075
diff changeset
4689 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4690 || *p == '|' || *p == '\n')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4691 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4692 /*
17336
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
4693 * We remove the '\' before the '|', unless EX_CTRLV is used
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4694 * AND 'b' is present in 'cpoptions'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4695 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4696 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
4697 || !(eap->argt & EX_CTRLV)) && *(p - 1) == '\\')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4698 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4699 STRMOVE(p - 1, p); // remove the '\'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4700 --p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4701 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4702 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4703 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4704 eap->nextcmd = check_nextcmd(p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4705 *p = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4706 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4707 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4708 }
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 40
diff changeset
4709 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 40
diff changeset
4710
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4711 if (!(eap->argt & EX_NOTRLCOM)) // remove trailing spaces
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4712 del_trailing_spaces(eap->arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4713 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4714
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4715 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4716 * get + command from ex argument
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4717 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4718 static char_u *
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
4719 getargcmd(char_u **argp)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4720 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4721 char_u *arg = *argp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4722 char_u *command = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4723
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4724 if (*arg == '+') // +[command]
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4725 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4726 ++arg;
5790
98bfec9ea760 updated for version 7.4.239
Bram Moolenaar <bram@vim.org>
parents: 5778
diff changeset
4727 if (vim_isspace(*arg) || *arg == NUL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4728 command = dollar_command;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4729 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4730 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4731 command = arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4732 arg = skip_cmd_arg(command, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4733 if (*arg != NUL)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4734 *arg++ = NUL; // terminate command with NUL
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4735 }
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4736
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4737 arg = skipwhite(arg); // skip over spaces
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4738 *argp = arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4739 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4740 return command;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4741 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4742
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4743 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4744 * Find end of "+command" argument. Skip over "\ " and "\\".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4745 */
17835
fd6c8dc33152 patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents: 17823
diff changeset
4746 char_u *
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
4747 skip_cmd_arg(
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
4748 char_u *p,
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4749 int rembs) // TRUE to halve the number of backslashes
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4750 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4751 while (*p && !vim_isspace(*p))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4752 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4753 if (*p == '\\' && p[1] != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4754 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4755 if (rembs)
1619
b9740fb41986 updated for version 7.2a
vimboss
parents: 1613
diff changeset
4756 STRMOVE(p, p + 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4757 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4758 ++p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4759 }
11127
506f5d8b7d8b patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 11010
diff changeset
4760 MB_PTR_ADV(p);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4761 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4762 return p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4763 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4764
13575
4df23d9bad47 patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents: 13553
diff changeset
4765 int
4df23d9bad47 patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents: 13553
diff changeset
4766 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
4767 {
4df23d9bad47 patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents: 13553
diff changeset
4768 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
4769 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
4770 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
4771 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
4772 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
4773 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
4774 else
c1ead25ed819 patch 8.1.0043: ++bad argument of :edit does not work properly
Christian Brabandt <cb@256bit.org>
parents: 14035
diff changeset
4775 return FAIL;
c1ead25ed819 patch 8.1.0043: ++bad argument of :edit does not work properly
Christian Brabandt <cb@256bit.org>
parents: 14035
diff changeset
4776 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
4777 }
4df23d9bad47 patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents: 13553
diff changeset
4778
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4779 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4780 * Get "++opt=arg" argument.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4781 * Return FAIL or OK.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4782 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4783 static int
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
4784 getargopt(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4785 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4786 char_u *arg = eap->arg + 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4787 int *pp = NULL;
2168
99b00399c7b4 updated for version 7.2.435
Bram Moolenaar <bram@vim.org>
parents: 2148
diff changeset
4788 int bad_char_idx;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4789 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4790
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4791 // ":edit ++[no]bin[ary] file"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4792 if (STRNCMP(arg, "bin", 3) == 0 || STRNCMP(arg, "nobin", 5) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4793 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4794 if (*arg == 'n')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4795 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4796 arg += 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4797 eap->force_bin = FORCE_NOBIN;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4798 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4799 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4800 eap->force_bin = FORCE_BIN;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4801 if (!checkforcmd(&arg, "binary", 3))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4802 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4803 eap->arg = skipwhite(arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4804 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4805 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4806
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4807 // ":read ++edit file"
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 815
diff changeset
4808 if (STRNCMP(arg, "edit", 4) == 0)
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 815
diff changeset
4809 {
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 815
diff changeset
4810 eap->read_edit = TRUE;
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 815
diff changeset
4811 eap->arg = skipwhite(arg + 4);
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 815
diff changeset
4812 return OK;
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 815
diff changeset
4813 }
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 815
diff changeset
4814
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4815 if (STRNCMP(arg, "ff", 2) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4816 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4817 arg += 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4818 pp = &eap->force_ff;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4819 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4820 else if (STRNCMP(arg, "fileformat", 10) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4821 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4822 arg += 10;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4823 pp = &eap->force_ff;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4824 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4825 else if (STRNCMP(arg, "enc", 3) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4826 {
3208
0a9d7cf90f94 updated for version 7.3.374
Bram Moolenaar <bram@vim.org>
parents: 3151
diff changeset
4827 if (STRNCMP(arg, "encoding", 8) == 0)
0a9d7cf90f94 updated for version 7.3.374
Bram Moolenaar <bram@vim.org>
parents: 3151
diff changeset
4828 arg += 8;
0a9d7cf90f94 updated for version 7.3.374
Bram Moolenaar <bram@vim.org>
parents: 3151
diff changeset
4829 else
0a9d7cf90f94 updated for version 7.3.374
Bram Moolenaar <bram@vim.org>
parents: 3151
diff changeset
4830 arg += 3;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4831 pp = &eap->force_enc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4832 }
595
fea48f63efc8 updated for version 7.0169
vimboss
parents: 588
diff changeset
4833 else if (STRNCMP(arg, "bad", 3) == 0)
fea48f63efc8 updated for version 7.0169
vimboss
parents: 588
diff changeset
4834 {
fea48f63efc8 updated for version 7.0169
vimboss
parents: 588
diff changeset
4835 arg += 3;
2168
99b00399c7b4 updated for version 7.2.435
Bram Moolenaar <bram@vim.org>
parents: 2148
diff changeset
4836 pp = &bad_char_idx;
595
fea48f63efc8 updated for version 7.0169
vimboss
parents: 588
diff changeset
4837 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4838
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4839 if (pp == NULL || *arg != '=')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4840 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4841
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4842 ++arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4843 *pp = (int)(arg - eap->cmd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4844 arg = skip_cmd_arg(arg, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4845 eap->arg = skipwhite(arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4846 *arg = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4847
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4848 if (pp == &eap->force_ff)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4849 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4850 if (check_ff_value(eap->cmd + eap->force_ff) == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4851 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
4852 eap->force_ff = eap->cmd[eap->force_ff];
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4853 }
595
fea48f63efc8 updated for version 7.0169
vimboss
parents: 588
diff changeset
4854 else if (pp == &eap->force_enc)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4855 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4856 // Make 'fileencoding' lower case.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4857 for (p = eap->cmd + eap->force_enc; *p != NUL; ++p)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4858 *p = TOLOWER_ASC(*p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4859 }
595
fea48f63efc8 updated for version 7.0169
vimboss
parents: 588
diff changeset
4860 else
fea48f63efc8 updated for version 7.0169
vimboss
parents: 588
diff changeset
4861 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4862 // Check ++bad= argument. Must be a single-byte character, "keep" or
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4863 // "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
4864 if (get_bad_opt(eap->cmd + bad_char_idx, eap) == FAIL)
595
fea48f63efc8 updated for version 7.0169
vimboss
parents: 588
diff changeset
4865 return FAIL;
fea48f63efc8 updated for version 7.0169
vimboss
parents: 588
diff changeset
4866 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4867
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4868 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4869 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4870
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4871 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
4872 ex_autocmd(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4873 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4874 /*
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
4875 * Disallow autocommands from .exrc and .vimrc in current
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4876 * directory for security reasons.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4877 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4878 if (secure)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4879 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4880 secure = 2;
21459
a422bd80b434 patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents: 21413
diff changeset
4881 eap->errmsg = _(e_curdir);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4882 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4883 else if (eap->cmdidx == CMD_autocmd)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4884 do_autocmd(eap->arg, eap->forceit);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4885 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4886 do_augroup(eap->arg, eap->forceit);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4887 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4888
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4889 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4890 * ":doautocmd": Apply the automatic commands to the current buffer.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4891 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4892 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
4893 ex_doautocmd(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4894 {
3350
198ec1fff71a updated for version 7.3.442
Bram Moolenaar <bram@vim.org>
parents: 3304
diff changeset
4895 char_u *arg = eap->arg;
198ec1fff71a updated for version 7.3.442
Bram Moolenaar <bram@vim.org>
parents: 3304
diff changeset
4896 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
4897 int did_aucmd;
ac8180818504 commit https://github.com/vim/vim/commit/1610d052413e0ed664498853a47acc2d677a22d1
Christian Brabandt <cb@256bit.org>
parents: 9230
diff changeset
4898
ac8180818504 commit https://github.com/vim/vim/commit/1610d052413e0ed664498853a47acc2d677a22d1
Christian Brabandt <cb@256bit.org>
parents: 9230
diff changeset
4899 (void)do_doautocmd(arg, TRUE, &did_aucmd);
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4900 // Only when there is no <nomodeline>.
9260
ac8180818504 commit https://github.com/vim/vim/commit/1610d052413e0ed664498853a47acc2d677a22d1
Christian Brabandt <cb@256bit.org>
parents: 9230
diff changeset
4901 if (call_do_modelines && did_aucmd)
3350
198ec1fff71a updated for version 7.3.442
Bram Moolenaar <bram@vim.org>
parents: 3304
diff changeset
4902 do_modelines(0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4903 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4904
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4905 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4906 * :[N]bunload[!] [N] [bufname] unload buffer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4907 * :[N]bdelete[!] [N] [bufname] delete buffer from buffer list
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4908 * :[N]bwipeout[!] [N] [bufname] delete buffer really
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4909 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4910 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
4911 ex_bunload(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4912 {
19271
ebeeb4b4a1fa patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents: 19261
diff changeset
4913 if (ERROR_IF_ANY_POPUP_WINDOW)
16874
da5f5836e90c patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
4914 return;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4915 eap->errmsg = do_bufdel(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4916 eap->cmdidx == CMD_bdelete ? DOBUF_DEL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4917 : eap->cmdidx == CMD_bwipeout ? DOBUF_WIPE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4918 : DOBUF_UNLOAD, eap->arg,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4919 eap->addr_count, (int)eap->line1, (int)eap->line2, eap->forceit);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4920 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4921
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4922 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4923 * :[N]buffer [N] to buffer N
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4924 * :[N]sbuffer [N] to buffer N
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4925 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4926 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
4927 ex_buffer(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4928 {
19271
ebeeb4b4a1fa patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents: 19261
diff changeset
4929 if (ERROR_IF_ANY_POPUP_WINDOW)
16874
da5f5836e90c patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
4930 return;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4931 if (*eap->arg)
21459
a422bd80b434 patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents: 21413
diff changeset
4932 eap->errmsg = ex_errmsg(e_trailing_arg, eap->arg);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4933 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4934 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4935 if (eap->addr_count == 0) // default is current buffer
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4936 goto_buffer(eap, DOBUF_CURRENT, FORWARD, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4937 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4938 goto_buffer(eap, DOBUF_FIRST, FORWARD, (int)eap->line2);
6230
7c9abc70ffc1 updated for version 7.4.450
Bram Moolenaar <bram@vim.org>
parents: 6191
diff changeset
4939 if (eap->do_ecmd_cmd != NULL)
7c9abc70ffc1 updated for version 7.4.450
Bram Moolenaar <bram@vim.org>
parents: 6191
diff changeset
4940 do_cmdline_cmd(eap->do_ecmd_cmd);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4941 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4942 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4943
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4944 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4945 * :[N]bmodified [N] to next mod. buffer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4946 * :[N]sbmodified [N] to next mod. buffer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4947 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4948 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
4949 ex_bmodified(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4950 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4951 goto_buffer(eap, DOBUF_MOD, FORWARD, (int)eap->line2);
6230
7c9abc70ffc1 updated for version 7.4.450
Bram Moolenaar <bram@vim.org>
parents: 6191
diff changeset
4952 if (eap->do_ecmd_cmd != NULL)
7c9abc70ffc1 updated for version 7.4.450
Bram Moolenaar <bram@vim.org>
parents: 6191
diff changeset
4953 do_cmdline_cmd(eap->do_ecmd_cmd);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4954 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4955
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4956 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4957 * :[N]bnext [N] to next buffer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4958 * :[N]sbnext [N] split and to next buffer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4959 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4960 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
4961 ex_bnext(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4962 {
19271
ebeeb4b4a1fa patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents: 19261
diff changeset
4963 if (ERROR_IF_ANY_POPUP_WINDOW)
19135
17722555af22 patch 8.2.0127: some buffer commands work in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 19131
diff changeset
4964 return;
17722555af22 patch 8.2.0127: some buffer commands work in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 19131
diff changeset
4965
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4966 goto_buffer(eap, DOBUF_CURRENT, FORWARD, (int)eap->line2);
6230
7c9abc70ffc1 updated for version 7.4.450
Bram Moolenaar <bram@vim.org>
parents: 6191
diff changeset
4967 if (eap->do_ecmd_cmd != NULL)
7c9abc70ffc1 updated for version 7.4.450
Bram Moolenaar <bram@vim.org>
parents: 6191
diff changeset
4968 do_cmdline_cmd(eap->do_ecmd_cmd);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4969 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4970
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4971 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4972 * :[N]bNext [N] to previous buffer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4973 * :[N]bprevious [N] to previous buffer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4974 * :[N]sbNext [N] split and to previous buffer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4975 * :[N]sbprevious [N] split and to previous buffer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4976 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4977 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
4978 ex_bprevious(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4979 {
19271
ebeeb4b4a1fa patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents: 19261
diff changeset
4980 if (ERROR_IF_ANY_POPUP_WINDOW)
19135
17722555af22 patch 8.2.0127: some buffer commands work in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 19131
diff changeset
4981 return;
17722555af22 patch 8.2.0127: some buffer commands work in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 19131
diff changeset
4982
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4983 goto_buffer(eap, DOBUF_CURRENT, BACKWARD, (int)eap->line2);
6230
7c9abc70ffc1 updated for version 7.4.450
Bram Moolenaar <bram@vim.org>
parents: 6191
diff changeset
4984 if (eap->do_ecmd_cmd != NULL)
7c9abc70ffc1 updated for version 7.4.450
Bram Moolenaar <bram@vim.org>
parents: 6191
diff changeset
4985 do_cmdline_cmd(eap->do_ecmd_cmd);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4986 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4987
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4988 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4989 * :brewind to first buffer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4990 * :bfirst to first buffer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4991 * :sbrewind split and to first buffer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4992 * :sbfirst split and to first buffer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4993 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4994 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
4995 ex_brewind(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4996 {
19271
ebeeb4b4a1fa patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents: 19261
diff changeset
4997 if (ERROR_IF_ANY_POPUP_WINDOW)
19135
17722555af22 patch 8.2.0127: some buffer commands work in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 19131
diff changeset
4998 return;
17722555af22 patch 8.2.0127: some buffer commands work in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 19131
diff changeset
4999
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5000 goto_buffer(eap, DOBUF_FIRST, FORWARD, 0);
6230
7c9abc70ffc1 updated for version 7.4.450
Bram Moolenaar <bram@vim.org>
parents: 6191
diff changeset
5001 if (eap->do_ecmd_cmd != NULL)
7c9abc70ffc1 updated for version 7.4.450
Bram Moolenaar <bram@vim.org>
parents: 6191
diff changeset
5002 do_cmdline_cmd(eap->do_ecmd_cmd);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5003 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5004
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5005 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5006 * :blast to last buffer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5007 * :sblast split and to last buffer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5008 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5009 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5010 ex_blast(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5011 {
19271
ebeeb4b4a1fa patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents: 19261
diff changeset
5012 if (ERROR_IF_ANY_POPUP_WINDOW)
19135
17722555af22 patch 8.2.0127: some buffer commands work in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 19131
diff changeset
5013 return;
17722555af22 patch 8.2.0127: some buffer commands work in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 19131
diff changeset
5014
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5015 goto_buffer(eap, DOBUF_LAST, BACKWARD, 0);
6230
7c9abc70ffc1 updated for version 7.4.450
Bram Moolenaar <bram@vim.org>
parents: 6191
diff changeset
5016 if (eap->do_ecmd_cmd != NULL)
7c9abc70ffc1 updated for version 7.4.450
Bram Moolenaar <bram@vim.org>
parents: 6191
diff changeset
5017 do_cmdline_cmd(eap->do_ecmd_cmd);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5018 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5019
20059
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20027
diff changeset
5020 /*
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20027
diff changeset
5021 * Check if "c" ends an Ex command.
20075
516b10943fdb patch 8.2.0593: finding a user command is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 20063
diff changeset
5022 * In Vim9 script does not check for white space before # or #{.
20059
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20027
diff changeset
5023 */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5024 int
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5025 ends_excmd(int c)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5026 {
21353
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
5027 int comment_char = '"';
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
5028
20027
23a4aef4f923 patch 8.2.0569: build failure with tiny version
Bram Moolenaar <Bram@vim.org>
parents: 20023
diff changeset
5029 #ifdef FEAT_EVAL
21353
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
5030 if (in_vim9script())
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
5031 comment_char = '#';
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
5032 #endif
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
5033 return (c == NUL || c == '|' || c == comment_char || c == '\n');
20059
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20027
diff changeset
5034 }
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20027
diff changeset
5035
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20027
diff changeset
5036 /*
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20027
diff changeset
5037 * Like ends_excmd() but checks that a # in Vim9 script either has "cmd" equal
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20027
diff changeset
5038 * to "cmd_start" or has a white space character before it.
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20027
diff changeset
5039 */
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20027
diff changeset
5040 int
20063
cc146cde0b4d patch 8.2.0587: compiler warning for unused variable
Bram Moolenaar <Bram@vim.org>
parents: 20059
diff changeset
5041 ends_excmd2(char_u *cmd_start UNUSED, char_u *cmd)
20059
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20027
diff changeset
5042 {
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20027
diff changeset
5043 int c = *cmd;
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20027
diff changeset
5044
21353
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
5045 if (c == NUL || c == '|' || c == '\n')
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
5046 return TRUE;
20059
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20027
diff changeset
5047 #ifdef FEAT_EVAL
21353
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
5048 if (in_vim9script())
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
5049 return c == '#' && cmd[1] != '{'
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
5050 && (cmd == cmd_start || VIM_ISWHITE(cmd[-1]));
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
5051 #endif
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
5052 return c == '"';
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5053 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5054
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5055 #if defined(FEAT_SYN_HL) || defined(FEAT_SEARCH_EXTRA) || defined(FEAT_EVAL) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5056 || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5057 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5058 * Return the next command, after the first '|' or '\n'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5059 * Return NULL if not found.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5060 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5061 char_u *
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5062 find_nextcmd(char_u *p)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5063 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5064 while (*p != '|' && *p != '\n')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5065 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5066 if (*p == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5067 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5068 ++p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5069 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5070 return (p + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5071 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5072 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5073
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5074 /*
10383
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
5075 * 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
5076 * Return NULL if it isn't, the following character if it is.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5077 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5078 char_u *
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5079 check_nextcmd(char_u *p)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5080 {
10383
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
5081 char_u *s = skipwhite(p);
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
5082
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
5083 if (*s == '|' || *s == '\n')
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
5084 return (s + 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5085 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5086 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5087 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5088
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5089 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5090 * - if there are more files to edit
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5091 * - and this is the last window
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5092 * - and forceit not used
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5093 * - and not repeated twice on a row
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5094 * return FAIL and give error message if 'message' TRUE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5095 * return OK otherwise
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5096 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5097 static int
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5098 check_more(
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5099 int message, // when FALSE check only, no messages
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5100 int forceit)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5101 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5102 int n = ARGCOUNT - curwin->w_arg_idx - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5103
672
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
5104 if (!forceit && only_one_window()
21845
0e6ee11977b3 patch 8.2.1472: ":argdel" does not work like ":.argdel" as documented
Bram Moolenaar <Bram@vim.org>
parents: 21821
diff changeset
5105 && ARGCOUNT > 1 && !arg_had_last && n > 0 && quitmore == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5106 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5107 if (message)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5108 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5109 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5110 if ((p_confirm || cmdmod.confirm) && curbuf->b_fname != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5111 {
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
5112 char_u buff[DIALOG_MSG_SIZE];
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5113
14585
c8f07e8b273e patch 8.1.0306: plural messages are not translated properly
Christian Brabandt <cb@256bit.org>
parents: 14550
diff changeset
5114 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
5115 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
5116 "%d more files to edit. Quit anyway?", n), n);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5117 if (vim_dialog_yesno(VIM_QUESTION, NULL, buff, 1) == VIM_YES)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5118 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5119 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5120 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5121 #endif
15490
98c35d312987 patch 8.1.0753: printf format not checked for semsg()
Bram Moolenaar <Bram@vim.org>
parents: 15488
diff changeset
5122 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
5123 "E173: %d more files to edit", n), n);
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5124 quitmore = 2; // next try to quit is allowed
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5125 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5126 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5127 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5128 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5129 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5130
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5131 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5132 * Function given to ExpandGeneric() to obtain the list of command names.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5133 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5134 char_u *
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5135 get_command_name(expand_T *xp UNUSED, int idx)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5136 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5137 if (idx >= (int)CMD_SIZE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5138 return get_user_command_name(idx);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5139 return cmdnames[idx].cmd_name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5140 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5141
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5142 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5143 ex_colorscheme(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5144 {
2142
c60d231453cf updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents: 2097
diff changeset
5145 if (*eap->arg == NUL)
c60d231453cf updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents: 2097
diff changeset
5146 {
c60d231453cf updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents: 2097
diff changeset
5147 #ifdef FEAT_EVAL
c60d231453cf updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents: 2097
diff changeset
5148 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
5149 char_u *p = NULL;
c60d231453cf updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents: 2097
diff changeset
5150
c60d231453cf updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents: 2097
diff changeset
5151 if (expr != NULL)
c60d231453cf updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents: 2097
diff changeset
5152 {
c60d231453cf updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents: 2097
diff changeset
5153 ++emsg_off;
20996
3af71cbcfdbe patch 8.2.1049: Vim9: leaking memory when using continuation line
Bram Moolenaar <Bram@vim.org>
parents: 20982
diff changeset
5154 p = eval_to_string(expr, FALSE);
2142
c60d231453cf updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents: 2097
diff changeset
5155 --emsg_off;
c60d231453cf updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents: 2097
diff changeset
5156 vim_free(expr);
c60d231453cf updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents: 2097
diff changeset
5157 }
c60d231453cf updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents: 2097
diff changeset
5158 if (p != NULL)
c60d231453cf updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents: 2097
diff changeset
5159 {
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15510
diff changeset
5160 msg((char *)p);
2142
c60d231453cf updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents: 2097
diff changeset
5161 vim_free(p);
c60d231453cf updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents: 2097
diff changeset
5162 }
c60d231453cf updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents: 2097
diff changeset
5163 else
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15510
diff changeset
5164 msg("default");
2142
c60d231453cf updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents: 2097
diff changeset
5165 #else
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15510
diff changeset
5166 msg(_("unknown"));
2142
c60d231453cf updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents: 2097
diff changeset
5167 #endif
c60d231453cf updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents: 2097
diff changeset
5168 }
c60d231453cf updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents: 2097
diff changeset
5169 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
5170 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
5171
61448894376e patch 8.1.0839: when using VTP wrong colors after a color scheme change
Bram Moolenaar <Bram@vim.org>
parents: 15643
diff changeset
5172 #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
5173 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
5174 {
61448894376e patch 8.1.0839: when using VTP wrong colors after a color scheme change
Bram Moolenaar <Bram@vim.org>
parents: 15643
diff changeset
5175 // 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
5176 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
5177 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
5178 }
61448894376e patch 8.1.0839: when using VTP wrong colors after a color scheme change
Bram Moolenaar <Bram@vim.org>
parents: 15643
diff changeset
5179 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5180 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5181
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5182 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5183 ex_highlight(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5184 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5185 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
5186 msg(_("Greetings, Vim user!"));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5187 do_highlight(eap->arg, eap->forceit, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5188 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5189
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5190
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5191 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5192 * Call this function if we thought we were going to exit, but we won't
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5193 * (because of an error). May need to restore the terminal mode.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5194 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5195 void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5196 not_exiting(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5197 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5198 exiting = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5199 settmode(TMODE_RAW);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5200 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5201
13442
94e638936d3e patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents: 13435
diff changeset
5202 static int
94e638936d3e patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents: 13435
diff changeset
5203 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
5204 {
94e638936d3e patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents: 13435
diff changeset
5205 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
5206
18406
fa6efc49d71f patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents: 18402
diff changeset
5207 // Bail out when autocommands closed the window.
fa6efc49d71f patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents: 18402
diff changeset
5208 // Refuse to quit when the buffer in the last window is being closed (can
fa6efc49d71f patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents: 18402
diff changeset
5209 // only happen in autocommands).
13442
94e638936d3e patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents: 13435
diff changeset
5210 if (!win_valid(wp)
94e638936d3e patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents: 13435
diff changeset
5211 || curbuf_locked()
94e638936d3e patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents: 13435
diff changeset
5212 || (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
5213 return TRUE;
94e638936d3e patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents: 13435
diff changeset
5214
94e638936d3e patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents: 13435
diff changeset
5215 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
5216 {
94e638936d3e patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents: 13435
diff changeset
5217 apply_autocmds(EVENT_EXITPRE, NULL, NULL, FALSE, curbuf);
18406
fa6efc49d71f patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents: 18402
diff changeset
5218 // Refuse to quit when locked or when the window was closed or the
fa6efc49d71f patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents: 18402
diff changeset
5219 // buffer in the last window is being closed (can only happen in
fa6efc49d71f patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents: 18402
diff changeset
5220 // autocommands).
fa6efc49d71f patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents: 18402
diff changeset
5221 if (!win_valid(wp) || curbuf_locked()
13442
94e638936d3e patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents: 13435
diff changeset
5222 || (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
5223 return TRUE;
94e638936d3e patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents: 13435
diff changeset
5224 }
94e638936d3e patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents: 13435
diff changeset
5225
94e638936d3e patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents: 13435
diff changeset
5226 return FALSE;
94e638936d3e patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents: 13435
diff changeset
5227 }
94e638936d3e patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents: 13435
diff changeset
5228
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5229 /*
6409
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
5230 * ":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
5231 * ":{nr}quit": quit window {nr}
18402
527b7084c556 patch 8.1.2195: Vim does not exit when the terminal window is last window
Bram Moolenaar <Bram@vim.org>
parents: 18386
diff changeset
5232 * Also used when closing a terminal window that's the last one.
527b7084c556 patch 8.1.2195: Vim does not exit when the terminal window is last window
Bram Moolenaar <Bram@vim.org>
parents: 18386
diff changeset
5233 */
527b7084c556 patch 8.1.2195: Vim does not exit when the terminal window is last window
Bram Moolenaar <Bram@vim.org>
parents: 18386
diff changeset
5234 void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5235 ex_quit(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5236 {
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5237 win_T *wp;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5238
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5239 #ifdef FEAT_CMDWIN
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5240 if (cmdwin_type != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5241 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5242 cmdwin_result = Ctrl_C;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5243 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5244 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5245 #endif
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5246 // Don't quit while editing the command line.
633
7437be625546 updated for version 7.0183
vimboss
parents: 631
diff changeset
5247 if (text_locked())
7437be625546 updated for version 7.0183
vimboss
parents: 631
diff changeset
5248 {
7437be625546 updated for version 7.0183
vimboss
parents: 631
diff changeset
5249 text_locked_msg();
631
68a196b7504d updated for version 7.0182
vimboss
parents: 625
diff changeset
5250 return;
68a196b7504d updated for version 7.0182
vimboss
parents: 625
diff changeset
5251 }
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5252 if (eap->addr_count > 0)
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5253 {
6409
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
5254 int wnr = eap->line2;
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
5255
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
5256 for (wp = firstwin; wp->w_next != NULL; wp = wp->w_next)
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
5257 if (--wnr <= 0)
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5258 break;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5259 }
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5260 else
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5261 wp = curwin;
6409
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
5262
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5263 // Refuse to quit when locked.
12652
272ecbaf1b4f patch 8.0.1204: a QuitPre autocommand may get the wrong file name
Christian Brabandt <cb@256bit.org>
parents: 12624
diff changeset
5264 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
5265 return;
13442
94e638936d3e patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents: 13435
diff changeset
5266
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5267 // Trigger QuitPre and maybe ExitPre
13442
94e638936d3e patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents: 13435
diff changeset
5268 if (before_quit_autocmds(wp, FALSE, eap->forceit))
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 815
diff changeset
5269 return;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5270
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5271 #ifdef FEAT_NETBEANS_INTG
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5272 netbeansForcedQuit = eap->forceit;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5273 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5274
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5275 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5276 * If there are more files or windows we won't exit.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5277 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5278 if (check_more(FALSE, eap->forceit) == OK && only_one_window())
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5279 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
5280 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
5281 && check_changed(wp->w_buffer, (p_awa ? CCGD_AW : 0)
5464
9c777e2c7024 updated for version 7.4.082
Bram Moolenaar <bram@vim.org>
parents: 5458
diff changeset
5282 | (eap->forceit ? CCGD_FORCEIT : 0)
9c777e2c7024 updated for version 7.4.082
Bram Moolenaar <bram@vim.org>
parents: 5458
diff changeset
5283 | CCGD_EXCMD))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5284 || 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
5285 || (only_one_window() && check_changed_any(eap->forceit, TRUE)))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5286 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5287 not_exiting();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5288 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5289 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5290 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5291 // quit last window
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5292 // Note: only_one_window() returns true, even so a help window is
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5293 // still open. In that case only quit, if no address has been
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5294 // specified. Example:
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5295 // :h|wincmd w|1q - don't quit
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5296 // :h|wincmd w|q - quit
10349
cf988222b150 commit https://github.com/vim/vim/commit/a1f4cb93ba50ea9e40cd4b1f5592b8a6d1398660
Christian Brabandt <cb@256bit.org>
parents: 10275
diff changeset
5297 if (only_one_window() && (ONE_WINDOW || eap->addr_count == 0))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5298 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
5299 not_exiting();
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
5300 #ifdef FEAT_GUI
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5301 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
5302 #endif
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5303 // 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
5304 win_close(wp, !buf_hide(wp->w_buffer) || eap->forceit);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5305 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5306 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5307
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5308 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5309 * ":cquit".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5310 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5311 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5312 ex_cquit(exarg_T *eap UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5313 {
19069
e14feba578f1 patch 8.2.0095: cannot specify exit code for :cquit
Bram Moolenaar <Bram@vim.org>
parents: 18991
diff changeset
5314 // this does not always pass on the exit code to the Manx compiler. why?
e14feba578f1 patch 8.2.0095: cannot specify exit code for :cquit
Bram Moolenaar <Bram@vim.org>
parents: 18991
diff changeset
5315 getout(eap->addr_count > 0 ? (int)eap->line2 : EXIT_FAILURE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5316 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5317
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5318 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5319 * ":qall": try to quit all windows
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5320 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5321 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5322 ex_quit_all(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5323 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5324 # ifdef FEAT_CMDWIN
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5325 if (cmdwin_type != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5326 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5327 if (eap->forceit)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5328 cmdwin_result = K_XF1; // ex_window() takes care of this
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5329 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5330 cmdwin_result = K_XF2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5331 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5332 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5333 # endif
631
68a196b7504d updated for version 7.0182
vimboss
parents: 625
diff changeset
5334
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5335 // Don't quit while editing the command line.
633
7437be625546 updated for version 7.0183
vimboss
parents: 631
diff changeset
5336 if (text_locked())
7437be625546 updated for version 7.0183
vimboss
parents: 631
diff changeset
5337 {
7437be625546 updated for version 7.0183
vimboss
parents: 631
diff changeset
5338 text_locked_msg();
631
68a196b7504d updated for version 7.0182
vimboss
parents: 625
diff changeset
5339 return;
68a196b7504d updated for version 7.0182
vimboss
parents: 625
diff changeset
5340 }
13442
94e638936d3e patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents: 13435
diff changeset
5341
94e638936d3e patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents: 13435
diff changeset
5342 if (before_quit_autocmds(curwin, TRUE, eap->forceit))
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 815
diff changeset
5343 return;
631
68a196b7504d updated for version 7.0182
vimboss
parents: 625
diff changeset
5344
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5345 exiting = TRUE;
7469
15eefe1b0dad commit https://github.com/vim/vim/commit/027387f70c671f62e3e08e0bdd09ec05b0232735
Christian Brabandt <cb@256bit.org>
parents: 7465
diff changeset
5346 if (eap->forceit || !check_changed_any(FALSE, FALSE))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5347 getout(0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5348 not_exiting();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5349 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5350
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5351 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5352 * ":close": close current window, unless it is the last one
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5353 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5354 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5355 ex_close(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5356 {
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5357 win_T *win;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5358 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
5359 #ifdef FEAT_CMDWIN
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5360 if (cmdwin_type != 0)
2839
e1c5f69de95b updated for version 7.3.193
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
5361 cmdwin_result = Ctrl_C;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5362 else
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
5363 #endif
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13288
diff changeset
5364 if (!text_locked() && !curbuf_locked())
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5365 {
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5366 if (eap->addr_count == 0)
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5367 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
5368 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
5369 {
9649
fd9727ae3c49 commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents: 9538
diff changeset
5370 FOR_ALL_WINDOWS(win)
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5371 {
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5372 winnr++;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5373 if (winnr == eap->line2)
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5374 break;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5375 }
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5376 if (win == NULL)
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5377 win = lastwin;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5378 ex_win_close(eap->forceit, win, NULL);
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5379 }
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5380 }
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
5381 }
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
5382
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
5383 #ifdef FEAT_QUICKFIX
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
5384 /*
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
5385 * ":pclose": Close any preview window.
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
5386 */
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
5387 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5388 ex_pclose(exarg_T *eap)
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
5389 {
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
5390 win_T *win;
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
5391
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17336
diff changeset
5392 // First close any normal window.
9649
fd9727ae3c49 commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents: 9538
diff changeset
5393 FOR_ALL_WINDOWS(win)
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
5394 if (win->w_p_pvw)
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
5395 {
671
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5396 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
5397 return;
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17336
diff changeset
5398 }
18763
49b78d6465e5 patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents: 18715
diff changeset
5399 # ifdef FEAT_PROP_POPUP
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17336
diff changeset
5400 // Also when 'previewpopup' is empty, it might have been cleared.
17817
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17781
diff changeset
5401 popup_close_preview();
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17336
diff changeset
5402 # endif
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
5403 }
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
5404 #endif
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
5405
671
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5406 /*
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5407 * Close window "win" and take care of handling closing the last window for a
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5408 * modified buffer.
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5409 */
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5410 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5411 ex_win_close(
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5412 int forceit,
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5413 win_T *win,
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5414 tabpage_T *tp) // NULL or the tab page "win" is in
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5415 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5416 int need_hide;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5417 buf_T *buf = win->w_buffer;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5418
21016
0738c44504cb patch 8.2.1059: crash when using :tabonly in an autocommand
Bram Moolenaar <Bram@vim.org>
parents: 20996
diff changeset
5419 // Never close the autocommand window.
0738c44504cb patch 8.2.1059: crash when using :tabonly in an autocommand
Bram Moolenaar <Bram@vim.org>
parents: 20996
diff changeset
5420 if (win == aucmd_win)
0738c44504cb patch 8.2.1059: crash when using :tabonly in an autocommand
Bram Moolenaar <Bram@vim.org>
parents: 20996
diff changeset
5421 {
0738c44504cb patch 8.2.1059: crash when using :tabonly in an autocommand
Bram Moolenaar <Bram@vim.org>
parents: 20996
diff changeset
5422 emsg(_(e_autocmd_close));
0738c44504cb patch 8.2.1059: crash when using :tabonly in an autocommand
Bram Moolenaar <Bram@vim.org>
parents: 20996
diff changeset
5423 return;
0738c44504cb patch 8.2.1059: crash when using :tabonly in an autocommand
Bram Moolenaar <Bram@vim.org>
parents: 20996
diff changeset
5424 }
0738c44504cb patch 8.2.1059: crash when using :tabonly in an autocommand
Bram Moolenaar <Bram@vim.org>
parents: 20996
diff changeset
5425
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5426 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
5427 if (need_hide && !buf_hide(buf) && !forceit)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5428 {
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
5429 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5430 if ((p_confirm || cmdmod.confirm) && p_write)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5431 {
9487
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9460
diff changeset
5432 bufref_T bufref;
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9460
diff changeset
5433
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9460
diff changeset
5434 set_bufref(&bufref, buf);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5435 dialog_changed(buf, FALSE);
9487
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9460
diff changeset
5436 if (bufref_valid(&bufref) && bufIsChanged(buf))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5437 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5438 need_hide = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5439 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5440 else
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
5441 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5442 {
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
5443 no_write_message();
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5444 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5445 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5446 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5447
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
5448 #ifdef FEAT_GUI
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5449 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
5450 #endif
671
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5451
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5452 // free buffer when not hiding it or when it's a scratch buffer
671
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5453 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
5454 win_close(win, !need_hide && !buf_hide(buf));
671
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5455 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
5456 win_close_othertab(win, !need_hide && !buf_hide(buf), tp);
671
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5457 }
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5458
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5459 /*
10741
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5460 * 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
5461 * Returns a tabpage number.
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5462 * 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
5463 */
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5464 static int
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5465 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
5466 {
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5467 int tab_number;
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5468 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
5469
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5470 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
5471 {
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5472 char_u *p = eap->arg;
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5473 char_u *p_save;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5474 int relative = 0; // argument +N/-N means: go to N places to the
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5475 // right/left relative to the current position.
10741
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5476
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5477 if (*p == '-')
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5478 {
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5479 relative = -1;
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5480 p++;
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5481 }
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5482 else if (*p == '+')
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5483 {
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5484 relative = 1;
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5485 p++;
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5486 }
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5487
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5488 p_save = p;
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5489 tab_number = getdigits(&p);
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5490
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5491 if (relative == 0)
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5492 {
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5493 if (STRCMP(p, "$") == 0)
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5494 tab_number = LAST_TAB_NR;
21727
860cad58f557 patch 8.2.1413: previous tab page not usable from an Ex command
Bram Moolenaar <Bram@vim.org>
parents: 21664
diff changeset
5495 else if (STRCMP(p, "#") == 0)
860cad58f557 patch 8.2.1413: previous tab page not usable from an Ex command
Bram Moolenaar <Bram@vim.org>
parents: 21664
diff changeset
5496 if (valid_tabpage(lastused_tabpage))
860cad58f557 patch 8.2.1413: previous tab page not usable from an Ex command
Bram Moolenaar <Bram@vim.org>
parents: 21664
diff changeset
5497 tab_number = tabpage_index(lastused_tabpage);
860cad58f557 patch 8.2.1413: previous tab page not usable from an Ex command
Bram Moolenaar <Bram@vim.org>
parents: 21664
diff changeset
5498 else
860cad58f557 patch 8.2.1413: previous tab page not usable from an Ex command
Bram Moolenaar <Bram@vim.org>
parents: 21664
diff changeset
5499 {
860cad58f557 patch 8.2.1413: previous tab page not usable from an Ex command
Bram Moolenaar <Bram@vim.org>
parents: 21664
diff changeset
5500 eap->errmsg = ex_errmsg(e_invargval, eap->arg);
860cad58f557 patch 8.2.1413: previous tab page not usable from an Ex command
Bram Moolenaar <Bram@vim.org>
parents: 21664
diff changeset
5501 tab_number = 0;
860cad58f557 patch 8.2.1413: previous tab page not usable from an Ex command
Bram Moolenaar <Bram@vim.org>
parents: 21664
diff changeset
5502 goto theend;
860cad58f557 patch 8.2.1413: previous tab page not usable from an Ex command
Bram Moolenaar <Bram@vim.org>
parents: 21664
diff changeset
5503 }
10741
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5504 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
5505 || tab_number > LAST_TAB_NR)
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5506 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5507 // No numbers as argument.
21459
a422bd80b434 patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents: 21413
diff changeset
5508 eap->errmsg = ex_errmsg(e_invarg2, eap->arg);
10741
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5509 goto theend;
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5510 }
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5511 }
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5512 else
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5513 {
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5514 if (*p_save == NUL)
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5515 tab_number = 1;
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5516 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
5517 || tab_number == 0)
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5518 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5519 // No numbers as argument.
21459
a422bd80b434 patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents: 21413
diff changeset
5520 eap->errmsg = ex_errmsg(e_invarg2, eap->arg);
10741
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5521 goto theend;
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5522 }
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5523 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
5524 if (!unaccept_arg0 && relative == -1)
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5525 --tab_number;
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5526 }
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5527 if (tab_number < unaccept_arg0 || tab_number > LAST_TAB_NR)
21459
a422bd80b434 patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents: 21413
diff changeset
5528 eap->errmsg = ex_errmsg(e_invarg2, eap->arg);
10741
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5529 }
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5530 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
5531 {
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5532 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
5533 {
21459
a422bd80b434 patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents: 21413
diff changeset
5534 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
5535 tab_number = 0;
4961e7acdd8c patch 8.0.0266: compiler warning for using uninitialized variable
Christian Brabandt <cb@256bit.org>
parents: 10741
diff changeset
5536 }
10741
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5537 else
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5538 {
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5539 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
5540 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
5541 {
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5542 --tab_number;
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5543 if (tab_number < unaccept_arg0)
21459
a422bd80b434 patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents: 21413
diff changeset
5544 eap->errmsg = _(e_invrange);
10741
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5545 }
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5546 }
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5547 }
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5548 else
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5549 {
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5550 switch (eap->cmdidx)
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5551 {
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5552 case CMD_tabnext:
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5553 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
5554 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
5555 tab_number = 1;
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5556 break;
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5557 case CMD_tabmove:
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5558 tab_number = LAST_TAB_NR;
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5559 break;
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5560 default:
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5561 tab_number = tabpage_index(curtab);
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5562 }
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5563 }
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5564
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5565 theend:
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5566 return tab_number;
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5567 }
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5568
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
5569 /*
671
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5570 * ":tabclose": close current tab page, unless it is the last one.
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5571 * ":tabclose N": close tab page N.
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
5572 */
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
5573 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5574 ex_tabclose(exarg_T *eap)
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
5575 {
671
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5576 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
5577 int tab_number;
671
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5578
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
5579 # ifdef FEAT_CMDWIN
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
5580 if (cmdwin_type != 0)
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
5581 cmdwin_result = K_IGNORE;
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
5582 else
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
5583 # endif
671
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5584 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
5585 emsg(_("E784: Cannot close last tab page"));
671
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5586 else
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5587 {
10739
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
5588 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
5589 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
5590 {
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
5591 tp = find_tabpage(tab_number);
671
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5592 if (tp == NULL)
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5593 {
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5594 beep_flush();
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5595 return;
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5596 }
674
4b8583e82cb8 updated for version 7.0201
vimboss
parents: 672
diff changeset
5597 if (tp != curtab)
671
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5598 {
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5599 tabpage_close_other(tp, eap->forceit);
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5600 return;
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5601 }
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13288
diff changeset
5602 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
5603 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
5604 }
671
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5605 }
672
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
5606 }
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
5607
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
5608 /*
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
5609 * ":tabonly": close all tab pages except the current one
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
5610 */
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
5611 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5612 ex_tabonly(exarg_T *eap)
672
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
5613 {
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
5614 tabpage_T *tp;
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
5615 int done;
10739
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
5616 int tab_number;
672
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
5617
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
5618 # ifdef FEAT_CMDWIN
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
5619 if (cmdwin_type != 0)
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
5620 cmdwin_result = K_IGNORE;
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
5621 else
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
5622 # endif
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
5623 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
5624 msg(_("Already only one tab page"));
672
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
5625 else
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
5626 {
10739
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
5627 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
5628 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
5629 {
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
5630 goto_tabpage(tab_number);
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5631 // Repeat this up to a 1000 times, because autocommands may
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5632 // mess up the lists.
10739
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
5633 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
5634 {
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
5635 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
5636 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
5637 {
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
5638 tabpage_close_other(tp, eap->forceit);
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5639 // if we failed to close it quit
10739
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
5640 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
5641 done = 1000;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5642 // start over, "tp" is now invalid
10739
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
5643 break;
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
5644 }
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
5645 if (first_tabpage->tp_next == NULL)
672
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
5646 break;
10739
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
5647 }
672
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
5648 }
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
5649 }
671
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5650 }
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5651
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5652 /*
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5653 * Close the current tab page.
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5654 */
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5655 void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5656 tabpage_close(int forceit)
671
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5657 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5658 // First close all the windows but the current one. If that worked then
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5659 // 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
5660 if (!ONE_WINDOW)
675
51794dc170f7 updated for version 7.0202
vimboss
parents: 674
diff changeset
5661 close_others(TRUE, forceit);
10357
59d01e335858 commit https://github.com/vim/vim/commit/459ca563128f2edb7e3bb190090bbb755a56dd55
Christian Brabandt <cb@256bit.org>
parents: 10349
diff changeset
5662 if (ONE_WINDOW)
671
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5663 ex_win_close(forceit, curwin, NULL);
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5664 # ifdef FEAT_GUI
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5665 need_mouse_correct = TRUE;
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5666 # endif
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5667 }
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5668
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5669 /*
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5670 * Close tab page "tp", which is not the current tab page.
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5671 * Note that autocommands may make "tp" invalid.
971
a9ffa7c7db77 updated for version 7.0-097
vimboss
parents: 944
diff changeset
5672 * Also takes care of the tab pages line disappearing when closing the
a9ffa7c7db77 updated for version 7.0-097
vimboss
parents: 944
diff changeset
5673 * last-but-one tab page.
671
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5674 */
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5675 void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5676 tabpage_close_other(tabpage_T *tp, int forceit)
671
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5677 {
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5678 int done = 0;
672
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
5679 win_T *wp;
971
a9ffa7c7db77 updated for version 7.0-097
vimboss
parents: 944
diff changeset
5680 int h = tabline_height();
671
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5681
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5682 // Limit to 1000 windows, autocommands may add a window while we close
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5683 // one. OK, so I'm paranoid...
671
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5684 while (++done < 1000)
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5685 {
672
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
5686 wp = tp->tp_firstwin;
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
5687 ex_win_close(forceit, wp, tp);
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
5688
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5689 // Autocommands may delete the tab page under our fingers and we may
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5690 // fail to close a window with a modified buffer.
672
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
5691 if (!valid_tabpage(tp) || tp->tp_firstwin == wp)
671
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5692 break;
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5693 }
971
a9ffa7c7db77 updated for version 7.0-097
vimboss
parents: 944
diff changeset
5694
9649
fd9727ae3c49 commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents: 9538
diff changeset
5695 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
5696
672
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
5697 redraw_tabline = TRUE;
971
a9ffa7c7db77 updated for version 7.0-097
vimboss
parents: 944
diff changeset
5698 if (h != tabline_height())
a9ffa7c7db77 updated for version 7.0-097
vimboss
parents: 944
diff changeset
5699 shell_new_rows();
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
5700 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5701
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5702 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5703 * ":only".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5704 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5705 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5706 ex_only(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5707 {
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5708 win_T *wp;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5709 int wnr;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5710 # ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5711 need_mouse_correct = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5712 # endif
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5713 if (eap->addr_count > 0)
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5714 {
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5715 wnr = eap->line2;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5716 for (wp = firstwin; --wnr > 0; )
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5717 {
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5718 if (wp->w_next == NULL)
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5719 break;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5720 else
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5721 wp = wp->w_next;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5722 }
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5723 win_goto(wp);
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5724 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5725 close_others(TRUE, eap->forceit);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5726 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5727
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5728 static void
10492
b2cd5a71f4bb commit https://github.com/vim/vim/commit/5e1e6d265d26ee2952c4a018a5ff72c950d2d700
Christian Brabandt <cb@256bit.org>
parents: 10490
diff changeset
5729 ex_hide(exarg_T *eap UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5730 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5731 // ":hide" or ":hide | cmd": hide current window
10383
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
5732 if (!eap->skip)
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
5733 {
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
5734 #ifdef FEAT_GUI
10383
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
5735 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
5736 #endif
10383
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
5737 if (eap->addr_count == 0)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5738 win_close(curwin, FALSE); // don't free buffer
10383
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
5739 else
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
5740 {
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
5741 int winnr = 0;
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
5742 win_T *win;
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
5743
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
5744 FOR_ALL_WINDOWS(win)
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
5745 {
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
5746 winnr++;
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
5747 if (winnr == eap->line2)
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
5748 break;
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
5749 }
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
5750 if (win == NULL)
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
5751 win = lastwin;
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
5752 win_close(win, FALSE);
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
5753 }
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
5754 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5755 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5756
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5757 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5758 * ":stop" and ":suspend": Suspend Vim.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5759 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5760 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5761 ex_stop(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5762 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5763 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5764 * Disallow suspending for "rvim".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5765 */
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10240
diff changeset
5766 if (!check_restricted())
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5767 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5768 if (!eap->forceit)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5769 autowrite_all();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5770 windgoto((int)Rows - 1, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5771 out_char('\n');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5772 out_flush();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5773 stoptermcap();
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5774 out_flush(); // needed for SUN to restore xterm buffer
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5775 #ifdef FEAT_TITLE
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5776 mch_restore_title(SAVE_RESTORE_BOTH); // restore window titles
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5777 #endif
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5778 ui_suspend(); // call machine specific function
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5779 #ifdef FEAT_TITLE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5780 maketitle();
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5781 resettitle(); // force updating the title
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5782 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5783 starttermcap();
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5784 scroll_start(); // scroll screen before redrawing
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5785 redraw_later_clear();
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5786 shell_resized(); // may have resized window
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5787 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5788 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5789
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5790 /*
13442
94e638936d3e patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents: 13435
diff changeset
5791 * ":exit", ":xit" and ":wq": Write file and quite the current window.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5792 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5793 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5794 ex_exit(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5795 {
21518
0b448762ebbd patch 8.2.1309: build failure with tiny version
Bram Moolenaar <Bram@vim.org>
parents: 21516
diff changeset
5796 #ifdef FEAT_EVAL
21516
c7b2ce90c2de patch 8.2.1308: Vim9: accidentally using "x" causes Vim to exit
Bram Moolenaar <Bram@vim.org>
parents: 21493
diff changeset
5797 if (not_in_vim9(eap) == FAIL)
c7b2ce90c2de patch 8.2.1308: Vim9: accidentally using "x" causes Vim to exit
Bram Moolenaar <Bram@vim.org>
parents: 21493
diff changeset
5798 return;
21518
0b448762ebbd patch 8.2.1309: build failure with tiny version
Bram Moolenaar <Bram@vim.org>
parents: 21516
diff changeset
5799 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5800 #ifdef FEAT_CMDWIN
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5801 if (cmdwin_type != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5802 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5803 cmdwin_result = Ctrl_C;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5804 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5805 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5806 #endif
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5807 // Don't quit while editing the command line.
633
7437be625546 updated for version 7.0183
vimboss
parents: 631
diff changeset
5808 if (text_locked())
7437be625546 updated for version 7.0183
vimboss
parents: 631
diff changeset
5809 {
7437be625546 updated for version 7.0183
vimboss
parents: 631
diff changeset
5810 text_locked_msg();
631
68a196b7504d updated for version 7.0182
vimboss
parents: 625
diff changeset
5811 return;
68a196b7504d updated for version 7.0182
vimboss
parents: 625
diff changeset
5812 }
13442
94e638936d3e patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents: 13435
diff changeset
5813
94e638936d3e patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents: 13435
diff changeset
5814 if (before_quit_autocmds(curwin, FALSE, eap->forceit))
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 815
diff changeset
5815 return;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5816
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5817 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5818 * if more files or windows we won't exit
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5819 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5820 if (check_more(FALSE, eap->forceit) == OK && only_one_window())
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5821 exiting = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5822 if ( ((eap->cmdidx == CMD_wq
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5823 || curbufIsChanged())
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5824 && do_write(eap) == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5825 || 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
5826 || (only_one_window() && check_changed_any(eap->forceit, FALSE)))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5827 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5828 not_exiting();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5829 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5830 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5831 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5832 if (only_one_window()) // quit last window, exit Vim
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5833 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
5834 not_exiting();
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5835 # ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5836 need_mouse_correct = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5837 # endif
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5838 // 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
5839 win_close(curwin, !buf_hide(curwin->w_buffer));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5840 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5841 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5842
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5843 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5844 * ":print", ":list", ":number".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5845 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5846 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5847 ex_print(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5848 {
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
5849 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
5850 emsg(_(e_emptybuf));
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
5851 else
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
5852 {
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
5853 for ( ;!got_int; ui_breakcheck())
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
5854 {
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
5855 print_line(eap->line1,
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
5856 (eap->cmdidx == CMD_number || eap->cmdidx == CMD_pound
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
5857 || (eap->flags & EXFLAG_NR)),
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
5858 eap->cmdidx == CMD_list || (eap->flags & EXFLAG_LIST));
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
5859 if (++eap->line1 > eap->line2)
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
5860 break;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5861 out_flush(); // show one line at a time
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
5862 }
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
5863 setpcmark();
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5864 // put cursor at last line
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
5865 curwin->w_cursor.lnum = eap->line2;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
5866 beginline(BL_SOL | BL_FIX);
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
5867 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5868
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5869 ex_no_reprint = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5870 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5871
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5872 #ifdef FEAT_BYTEOFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5873 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5874 ex_goto(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5875 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5876 goto_byte(eap->line2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5877 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5878 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5879
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5880 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5881 * ":shell".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5882 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5883 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5884 ex_shell(exarg_T *eap UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5885 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5886 do_shell(NULL, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5887 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5888
14428
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
5889 #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
5890
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
5891 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
5892 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
5893 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
5894 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
5895 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
5896 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
5897
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
5898 static void
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
5899 handle_drop_internal(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5900 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5901 exarg_T ea;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5902 int save_msg_scroll = msg_scroll;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5903
14428
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
5904 // 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
5905 // 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
5906 drop_busy = TRUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5907
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5908 // Check whether the current buffer is changed. If so, we will need
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5909 // to split the current window or data could be lost.
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5910 // We don't need to check if the 'hidden' option is set, as in this
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5911 // case the buffer won't be lost.
14428
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
5912 if (!buf_hide(curbuf) && !drop_split)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5913 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5914 ++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
5915 drop_split = check_changed(curbuf, CCGD_AW);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5916 --emsg_off;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5917 }
14428
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
5918 if (drop_split)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5919 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5920 if (win_split(0, 0) == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5921 return;
2583
7c2e6ba1d702 updated for version 7.3.008
Bram Moolenaar <bram@vim.org>
parents: 2575
diff changeset
5922 RESET_BINDING(curwin);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5923
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5924 // When splitting the window, create a new alist. Otherwise the
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5925 // existing one is overwritten.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5926 alist_unlink(curwin->w_alist);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5927 alist_new();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5928 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5929
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5930 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5931 * Set up the new argument list.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5932 */
14428
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
5933 alist_set(ALIST(curwin), drop_filec, drop_filev, FALSE, NULL, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5934
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5935 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5936 * Move to the first file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5937 */
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5938 // Fake up a minimal "next" command for do_argfile()
20007
aadd1cae2ff5 patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents: 19892
diff changeset
5939 CLEAR_FIELD(ea);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5940 ea.cmd = (char_u *)"next";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5941 do_argfile(&ea, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5942
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5943 // do_ecmd() may set need_start_insertmode, but since we never left Insert
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5944 // mode that is not needed here.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5945 need_start_insertmode = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5946
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5947 // Restore msg_scroll, otherwise a following command may cause scrolling
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5948 // unexpectedly. The screen will be redrawn by the caller, thus
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5949 // msg_scroll being set by displaying a message is irrelevant.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5950 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
5951
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
5952 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
5953 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
5954
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
5955 drop_filev = NULL;
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
5956 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
5957 }
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
5958
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
5959 /*
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
5960 * 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
5961 * :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
5962 * 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
5963 * 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
5964 * 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
5965 *
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
5966 * 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
5967 * 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
5968 * list.
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
5969 */
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
5970 void
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
5971 handle_drop(
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
5972 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
5973 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
5974 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
5975 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
5976 // list
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
5977 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
5978 {
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
5979 // 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
5980 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
5981 {
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
5982 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
5983 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
5984 return;
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
5985 }
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
5986
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
5987 // 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
5988 // one.
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
5989 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
5990 {
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
5991 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
5992 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
5993 }
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
5994
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
5995 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
5996 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
5997 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
5998 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
5999 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
6000
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6001 // 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
6002 // - 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
6003 // - 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
6004 // - 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
6005 // 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
6006 // 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
6007 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
6008 return;
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6009
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6010 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
6011 }
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6012
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6013 /*
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6014 * 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
6015 * 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
6016 */
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6017 void
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6018 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
6019 {
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6020 if (!drop_busy && drop_filev != NULL
20229
06a1dd50463e patch 8.2.0670: cannot change window when evaluating 'completefunc'
Bram Moolenaar <Bram@vim.org>
parents: 20185
diff changeset
6021 && !text_locked() && !curbuf_locked() && !updating_screen)
14428
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6022 handle_drop_internal();
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6023 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6024 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6025
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6026 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6027 * ":preserve".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6028 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6029 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
6030 ex_preserve(exarg_T *eap UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6031 {
164
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 161
diff changeset
6032 curbuf->b_flags |= BF_PRESERVED;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6033 ml_preserve(curbuf, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6034 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6035
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6036 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6037 * ":recover".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6038 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6039 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
6040 ex_recover(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6041 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6042 // Set recoverymode right away to avoid the ATTENTION prompt.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6043 recoverymode = TRUE;
5464
9c777e2c7024 updated for version 7.4.082
Bram Moolenaar <bram@vim.org>
parents: 5458
diff changeset
6044 if (!check_changed(curbuf, (p_awa ? CCGD_AW : 0)
9c777e2c7024 updated for version 7.4.082
Bram Moolenaar <bram@vim.org>
parents: 5458
diff changeset
6045 | CCGD_MULTWIN
9c777e2c7024 updated for version 7.4.082
Bram Moolenaar <bram@vim.org>
parents: 5458
diff changeset
6046 | (eap->forceit ? CCGD_FORCEIT : 0)
9c777e2c7024 updated for version 7.4.082
Bram Moolenaar <bram@vim.org>
parents: 5458
diff changeset
6047 | CCGD_EXCMD)
9c777e2c7024 updated for version 7.4.082
Bram Moolenaar <bram@vim.org>
parents: 5458
diff changeset
6048
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6049 && (*eap->arg == NUL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6050 || 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
6051 ml_recover(TRUE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6052 recoverymode = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6053 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6054
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6055 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6056 * Command modifier used in a wrong way.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6057 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6058 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
6059 ex_wrongmodifier(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6060 {
21821
0deb6f96a5a3 patch 8.2.1460: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 21789
diff changeset
6061 eap->errmsg = _(e_invalid_command);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6062 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6063
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6064 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6065 * :sview [+command] file split window with new file, read-only
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6066 * :split [[+command] file] split window with current or new file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6067 * :vsplit [[+command] file] split window vertically with current or new file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6068 * :new [[+command] file] split window with no or new file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6069 * :vnew [[+command] file] split vertically window with no or new file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6070 * :sfind [+command] file split window with file in 'path'
675
51794dc170f7 updated for version 7.0202
vimboss
parents: 674
diff changeset
6071 *
51794dc170f7 updated for version 7.0202
vimboss
parents: 674
diff changeset
6072 * :tabedit open new Tab page with empty window
51794dc170f7 updated for version 7.0202
vimboss
parents: 674
diff changeset
6073 * :tabedit [+command] file open new Tab page and edit "file"
51794dc170f7 updated for version 7.0202
vimboss
parents: 674
diff changeset
6074 * :tabnew [[+command] file] just like :tabedit
51794dc170f7 updated for version 7.0202
vimboss
parents: 674
diff changeset
6075 * :tabfind [+command] file open new Tab page and find "file"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6076 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6077 void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
6078 ex_splitview(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6079 {
675
51794dc170f7 updated for version 7.0202
vimboss
parents: 674
diff changeset
6080 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
6081 #if defined(FEAT_SEARCHPATH) || defined(FEAT_BROWSE)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6082 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
6083 #endif
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
6084 #ifdef FEAT_BROWSE
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6085 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
6086 #endif
14155
da09e29e59d9 patch 8.1.0095: dialog for ":browse tabnew" says "new window"
Christian Brabandt <cb@256bit.org>
parents: 14059
diff changeset
6087 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
6088 || 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
6089 || 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
6090
19271
ebeeb4b4a1fa patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents: 19261
diff changeset
6091 if (ERROR_IF_ANY_POPUP_WINDOW)
16874
da5f5836e90c patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
6092 return;
da5f5836e90c patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
6093
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
6094 #ifdef FEAT_GUI
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6095 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
6096 #endif
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
6097
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
6098 #ifdef FEAT_QUICKFIX
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6099 // A ":split" in the quickfix window works like ":new". Don't want two
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6100 // quickfix windows. But it's OK when doing ":tab split".
1661
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
6101 if (bt_quickfix(curbuf) && cmdmod.tab == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6102 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6103 if (eap->cmdidx == CMD_split)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6104 eap->cmdidx = CMD_new;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6105 if (eap->cmdidx == CMD_vsplit)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6106 eap->cmdidx = CMD_vnew;
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6107 }
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
6108 #endif
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
6109
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
6110 #ifdef FEAT_SEARCHPATH
675
51794dc170f7 updated for version 7.0202
vimboss
parents: 674
diff changeset
6111 if (eap->cmdidx == CMD_sfind || eap->cmdidx == CMD_tabfind)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6112 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6113 fname = find_file_in_path(eap->arg, (int)STRLEN(eap->arg),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6114 FNAME_MESS, TRUE, curbuf->b_ffname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6115 if (fname == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6116 goto theend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6117 eap->arg = fname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6118 }
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
6119 # ifdef FEAT_BROWSE
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6120 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6121 # endif
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
6122 #endif
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
6123 #ifdef FEAT_BROWSE
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6124 if (cmdmod.browse
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6125 && eap->cmdidx != CMD_vnew
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6126 && eap->cmdidx != CMD_new)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6127 {
461
f98374445f66 updated for version 7.0123
vimboss
parents: 446
diff changeset
6128 if (
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13288
diff changeset
6129 # ifdef FEAT_GUI
461
f98374445f66 updated for version 7.0123
vimboss
parents: 446
diff changeset
6130 !gui.in_use &&
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13288
diff changeset
6131 # endif
461
f98374445f66 updated for version 7.0123
vimboss
parents: 446
diff changeset
6132 au_has_group((char_u *)"FileExplorer"))
f98374445f66 updated for version 7.0123
vimboss
parents: 446
diff changeset
6133 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6134 // No browsing supported but we do have the file explorer:
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6135 // Edit the directory.
461
f98374445f66 updated for version 7.0123
vimboss
parents: 446
diff changeset
6136 if (*eap->arg == NUL || !mch_isdir(eap->arg))
f98374445f66 updated for version 7.0123
vimboss
parents: 446
diff changeset
6137 eap->arg = (char_u *)".";
f98374445f66 updated for version 7.0123
vimboss
parents: 446
diff changeset
6138 }
f98374445f66 updated for version 7.0123
vimboss
parents: 446
diff changeset
6139 else
f98374445f66 updated for version 7.0123
vimboss
parents: 446
diff changeset
6140 {
14155
da09e29e59d9 patch 8.1.0095: dialog for ":browse tabnew" says "new window"
Christian Brabandt <cb@256bit.org>
parents: 14059
diff changeset
6141 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
6142 ? _("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
6143 : _("Edit File in new window")),
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6144 eap->arg, NULL, NULL, NULL, curbuf);
461
f98374445f66 updated for version 7.0123
vimboss
parents: 446
diff changeset
6145 if (fname == NULL)
f98374445f66 updated for version 7.0123
vimboss
parents: 446
diff changeset
6146 goto theend;
f98374445f66 updated for version 7.0123
vimboss
parents: 446
diff changeset
6147 eap->arg = fname;
f98374445f66 updated for version 7.0123
vimboss
parents: 446
diff changeset
6148 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6149 }
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6150 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
6151 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6152
675
51794dc170f7 updated for version 7.0202
vimboss
parents: 674
diff changeset
6153 /*
51794dc170f7 updated for version 7.0202
vimboss
parents: 674
diff changeset
6154 * Either open new tab page or split the window.
51794dc170f7 updated for version 7.0202
vimboss
parents: 674
diff changeset
6155 */
14155
da09e29e59d9 patch 8.1.0095: dialog for ":browse tabnew" says "new window"
Christian Brabandt <cb@256bit.org>
parents: 14059
diff changeset
6156 if (use_tab)
675
51794dc170f7 updated for version 7.0202
vimboss
parents: 674
diff changeset
6157 {
820
57c7403f6599 updated for version 7.0c11
vimboss
parents: 819
diff changeset
6158 if (win_new_tabpage(cmdmod.tab != 0 ? cmdmod.tab
57c7403f6599 updated for version 7.0c11
vimboss
parents: 819
diff changeset
6159 : eap->addr_count == 0 ? 0
57c7403f6599 updated for version 7.0c11
vimboss
parents: 819
diff changeset
6160 : (int)eap->line2 + 1) != FAIL)
675
51794dc170f7 updated for version 7.0202
vimboss
parents: 674
diff changeset
6161 {
1498
4845822f6a6c updated for version 7.1-213
vimboss
parents: 1496
diff changeset
6162 do_exedit(eap, old_curwin);
675
51794dc170f7 updated for version 7.0202
vimboss
parents: 674
diff changeset
6163
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6164 // set the alternate buffer for the window we came from
675
51794dc170f7 updated for version 7.0202
vimboss
parents: 674
diff changeset
6165 if (curwin != old_curwin
51794dc170f7 updated for version 7.0202
vimboss
parents: 674
diff changeset
6166 && win_valid(old_curwin)
51794dc170f7 updated for version 7.0202
vimboss
parents: 674
diff changeset
6167 && old_curwin->w_buffer != curbuf
51794dc170f7 updated for version 7.0202
vimboss
parents: 674
diff changeset
6168 && !cmdmod.keepalt)
51794dc170f7 updated for version 7.0202
vimboss
parents: 674
diff changeset
6169 old_curwin->w_alt_fnum = curbuf->b_fnum;
51794dc170f7 updated for version 7.0202
vimboss
parents: 674
diff changeset
6170 }
51794dc170f7 updated for version 7.0202
vimboss
parents: 674
diff changeset
6171 }
51794dc170f7 updated for version 7.0202
vimboss
parents: 674
diff changeset
6172 else if (win_split(eap->addr_count > 0 ? (int)eap->line2 : 0,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6173 *eap->cmd == 'v' ? WSP_VERT : 0) != FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6174 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6175 // Reset 'scrollbind' when editing another file, but keep it when
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6176 // doing ":split" without arguments.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6177 if (*eap->arg != NUL
13384
6740c499de13 patch 8.0.1566: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13380
diff changeset
6178 # ifdef FEAT_BROWSE
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6179 || cmdmod.browse
13384
6740c499de13 patch 8.0.1566: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13380
diff changeset
6180 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6181 )
2583
7c2e6ba1d702 updated for version 7.3.008
Bram Moolenaar <bram@vim.org>
parents: 2575
diff changeset
6182 RESET_BINDING(curwin);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6183 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6184 do_check_scrollbind(FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6185 do_exedit(eap, old_curwin);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6186 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6187
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6188 # ifdef FEAT_BROWSE
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6189 cmdmod.browse = browse_flag;
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6190 # endif
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6191
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6192 # if defined(FEAT_SEARCHPATH) || defined(FEAT_BROWSE)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6193 theend:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6194 vim_free(fname);
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6195 # endif
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6196 }
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6197
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6198 /*
682
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
6199 * Open a new tab page.
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6200 */
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6201 void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
6202 tabpage_new(void)
682
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
6203 {
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
6204 exarg_T ea;
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
6205
20007
aadd1cae2ff5 patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents: 19892
diff changeset
6206 CLEAR_FIELD(ea);
682
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
6207 ea.cmdidx = CMD_tabnew;
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
6208 ea.cmd = (char_u *)"tabn";
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
6209 ea.arg = (char_u *)"";
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
6210 ex_splitview(&ea);
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
6211 }
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
6212
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
6213 /*
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
6214 * :tabnext command
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
6215 */
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
6216 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
6217 ex_tabnext(exarg_T *eap)
682
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
6218 {
10739
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6219 int tab_number;
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6220
17111
af861fccc309 patch 8.1.1555: NOT_IN_POPUP_WINDOW is confusing
Bram Moolenaar <Bram@vim.org>
parents: 17095
diff changeset
6221 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
6222 return;
685
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 682
diff changeset
6223 switch (eap->cmdidx)
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 682
diff changeset
6224 {
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 682
diff changeset
6225 case CMD_tabfirst:
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 682
diff changeset
6226 case CMD_tabrewind:
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 682
diff changeset
6227 goto_tabpage(1);
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 682
diff changeset
6228 break;
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 682
diff changeset
6229 case CMD_tablast:
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 682
diff changeset
6230 goto_tabpage(9999);
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 682
diff changeset
6231 break;
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 682
diff changeset
6232 case CMD_tabprevious:
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 682
diff changeset
6233 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
6234 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
6235 {
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6236 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
6237 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
6238
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6239 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
6240 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
6241 || tab_number == 0)
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6242 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6243 // No numbers as argument.
21459
a422bd80b434 patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents: 21413
diff changeset
6244 eap->errmsg = ex_errmsg(e_invarg2, eap->arg);
10739
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6245 return;
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6246 }
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6247 }
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6248 else
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6249 {
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6250 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
6251 tab_number = 1;
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6252 else
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6253 {
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6254 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
6255 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
6256 {
21459
a422bd80b434 patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents: 21413
diff changeset
6257 eap->errmsg = _(e_invrange);
10739
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6258 return;
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6259 }
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6260 }
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6261 }
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6262 goto_tabpage(-tab_number);
685
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 682
diff changeset
6263 break;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6264 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
6265 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
6266 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
6267 goto_tabpage(tab_number);
685
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 682
diff changeset
6268 break;
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 682
diff changeset
6269 }
682
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
6270 }
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
6271
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
6272 /*
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
6273 * :tabmove command
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
6274 */
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
6275 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
6276 ex_tabmove(exarg_T *eap)
682
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
6277 {
6775
c0bc9b60fb8a patch 7.4.709
Bram Moolenaar <bram@vim.org>
parents: 6739
diff changeset
6278 int tab_number;
3662
e5b925ae56e3 updated for version 7.3.591
Bram Moolenaar <bram@vim.org>
parents: 3570
diff changeset
6279
10739
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6280 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
6281 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
6282 tabpage_move(tab_number);
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6283 }
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6284
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6285 /*
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6286 * :tabs command: List tabs and their contents.
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6287 */
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6288 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
6289 ex_tabs(exarg_T *eap UNUSED)
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6290 {
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6291 tabpage_T *tp;
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6292 win_T *wp;
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6293 int tabcount = 1;
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6294
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6295 msg_start();
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6296 msg_scroll = TRUE;
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6297 for (tp = first_tabpage; tp != NULL && !got_int; tp = tp->tp_next)
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6298 {
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6299 msg_putchar('\n');
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6300 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
6301 msg_outtrans_attr(IObuff, HL_ATTR(HLF_T));
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6302 out_flush(); // output one line at a time
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6303 ui_breakcheck();
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6304
678
93a1bf1cb633 updated for version 7.0203
vimboss
parents: 675
diff changeset
6305 if (tp == curtab)
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6306 wp = firstwin;
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6307 else
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6308 wp = tp->tp_firstwin;
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6309 for ( ; wp != NULL && !got_int; wp = wp->w_next)
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6310 {
682
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
6311 msg_putchar('\n');
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
6312 msg_putchar(wp == curwin ? '>' : ' ');
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
6313 msg_putchar(' ');
672
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
6314 msg_putchar(bufIsChanged(wp->w_buffer) ? '+' : ' ');
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
6315 msg_putchar(' ');
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6316 if (buf_spname(wp->w_buffer) != NULL)
3839
8115f449a574 updated for version 7.3.677
Bram Moolenaar <bram@vim.org>
parents: 3810
diff changeset
6317 vim_strncpy(IObuff, buf_spname(wp->w_buffer), IOSIZE - 1);
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6318 else
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6319 home_replace(wp->w_buffer, wp->w_buffer->b_fname,
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6320 IObuff, IOSIZE, TRUE);
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6321 msg_outtrans(IObuff);
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6322 out_flush(); // output one line at a time
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6323 ui_breakcheck();
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6324 }
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6325 }
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6326 }
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6327
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6328 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6329 * ":mode": Set screen mode.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6330 * If no argument given, just get the screen size and redraw.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6331 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6332 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
6333 ex_mode(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6334 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6335 if (*eap->arg == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6336 shell_resized();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6337 else
19131
1fe99999625c patch 8.2.0125: :mode no longer works for any system
Bram Moolenaar <Bram@vim.org>
parents: 19075
diff changeset
6338 emsg(_(e_screenmode));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6339 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6340
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6341 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6342 * ":resize".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6343 * set, increment or decrement current window height
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6344 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6345 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
6346 ex_resize(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6347 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6348 int n;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6349 win_T *wp = curwin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6350
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6351 if (eap->addr_count > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6352 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6353 n = eap->line2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6354 for (wp = firstwin; wp->w_next != NULL && --n > 0; wp = wp->w_next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6355 ;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6356 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6357
8643
24b43dd167eb commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents: 8577
diff changeset
6358 # ifdef FEAT_GUI
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6359 need_mouse_correct = TRUE;
8643
24b43dd167eb commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents: 8577
diff changeset
6360 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6361 n = atol((char *)eap->arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6362 if (cmdmod.split & WSP_VERT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6363 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6364 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
6365 n += curwin->w_width;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6366 else if (n == 0 && eap->arg[0] == NUL) // default is very wide
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6367 n = 9999;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6368 win_setwidth_win((int)n, wp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6369 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6370 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6371 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6372 if (*eap->arg == '-' || *eap->arg == '+')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6373 n += curwin->w_height;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6374 else if (n == 0 && eap->arg[0] == NUL) // default is very high
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6375 n = 9999;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6376 win_setheight_win((int)n, wp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6377 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6378 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6379
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6380 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6381 * ":find [+command] <file>" command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6382 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6383 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
6384 ex_find(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6385 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6386 #ifdef FEAT_SEARCHPATH
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6387 char_u *fname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6388 int count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6389
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6390 fname = find_file_in_path(eap->arg, (int)STRLEN(eap->arg), FNAME_MESS,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6391 TRUE, curbuf->b_ffname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6392 if (eap->addr_count > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6393 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6394 // Repeat finding the file "count" times. This matters when it
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6395 // appears several times in the path.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6396 count = eap->line2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6397 while (fname != NULL && --count > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6398 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6399 vim_free(fname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6400 fname = find_file_in_path(NULL, 0, FNAME_MESS,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6401 FALSE, curbuf->b_ffname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6402 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6403 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6404
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6405 if (fname != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6406 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6407 eap->arg = fname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6408 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6409 do_exedit(eap, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6410 #ifdef FEAT_SEARCHPATH
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6411 vim_free(fname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6412 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6413 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6414 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6415
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6416 /*
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6417 * ":open" simulation: for now just work like ":visual".
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6418 */
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6419 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
6420 ex_open(exarg_T *eap)
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6421 {
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6422 regmatch_T regmatch;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6423 char_u *p;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6424
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6425 curwin->w_cursor.lnum = eap->line2;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6426 beginline(BL_SOL | BL_FIX);
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6427 if (*eap->arg == '/')
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6428 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6429 // ":open /pattern/": put cursor in column found with pattern
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6430 ++eap->arg;
19892
5feb426d2ea1 patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19685
diff changeset
6431 p = skip_regexp(eap->arg, '/', p_magic);
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6432 *p = NUL;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6433 regmatch.regprog = vim_regcomp(eap->arg, p_magic ? RE_MAGIC : 0);
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6434 if (regmatch.regprog != NULL)
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6435 {
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6436 regmatch.rm_ic = p_ic;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6437 p = ml_get_curline();
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6438 if (vim_regexec(&regmatch, p, (colnr_T)0))
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 827
diff changeset
6439 curwin->w_cursor.col = (colnr_T)(regmatch.startp[0] - p);
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6440 else
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
6441 emsg(_(e_nomatch));
4805
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4803
diff changeset
6442 vim_regfree(regmatch.regprog);
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6443 }
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6444 // Move to the NUL, ignore any other arguments.
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6445 eap->arg += STRLEN(eap->arg);
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6446 }
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6447 check_cursor();
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6448
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6449 eap->cmdidx = CMD_visual;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6450 do_exedit(eap, NULL);
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6451 }
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6452
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6453 /*
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6454 * ":edit", ":badd", ":visual".
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6455 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6456 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
6457 ex_edit(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6458 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6459 do_exedit(eap, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6460 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6461
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6462 /*
19195
2ef19eed524a patch 8.2.0156: various typos in source files and tests
Bram Moolenaar <Bram@vim.org>
parents: 19191
diff changeset
6463 * ":edit <file>" command and alike.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6464 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6465 void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
6466 do_exedit(
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
6467 exarg_T *eap,
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6468 win_T *old_curwin) // curwin before doing a split or NULL
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6469 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6470 int n;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6471 int need_hide;
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6472 int exmode_was = exmode_active;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6473
19271
ebeeb4b4a1fa patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents: 19261
diff changeset
6474 if ((eap->cmdidx != CMD_pedit && ERROR_IF_POPUP_WINDOW)
ebeeb4b4a1fa patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents: 19261
diff changeset
6475 || ERROR_IF_TERM_POPUP_WINDOW)
16874
da5f5836e90c patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
6476 return;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6477 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6478 * ":vi" command ends Ex mode.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6479 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6480 if (exmode_active && (eap->cmdidx == CMD_visual
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6481 || eap->cmdidx == CMD_view))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6482 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6483 exmode_active = FALSE;
20897
213fb059e02e patch 8.2.1000: get error when leaving Ex mode with :visual
Bram Moolenaar <Bram@vim.org>
parents: 20711
diff changeset
6484 ex_pressedreturn = FALSE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6485 if (*eap->arg == NUL)
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6486 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6487 // Special case: ":global/pat/visual\NLvi-commands"
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6488 if (global_busy)
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6489 {
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6490 int rd = RedrawingDisabled;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6491 int nwr = no_wait_return;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6492 int ms = msg_scroll;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6493 #ifdef FEAT_GUI
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6494 int he = hold_gui_events;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6495 #endif
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6496
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6497 if (eap->nextcmd != NULL)
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6498 {
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6499 stuffReadbuff(eap->nextcmd);
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6500 eap->nextcmd = NULL;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6501 }
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6502
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6503 if (exmode_was != EXMODE_VIM)
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6504 settmode(TMODE_RAW);
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6505 RedrawingDisabled = 0;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6506 no_wait_return = 0;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6507 need_wait_return = FALSE;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6508 msg_scroll = 0;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6509 #ifdef FEAT_GUI
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6510 hold_gui_events = 0;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6511 #endif
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6512 must_redraw = CLEAR;
19433
af9d5585cfbf patch 8.2.0274: hang with combination of feedkeys(), Ex mode and :global
Bram Moolenaar <Bram@vim.org>
parents: 19415
diff changeset
6513 pending_exmode_active = TRUE;
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6514
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6515 main_loop(FALSE, TRUE);
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6516
19433
af9d5585cfbf patch 8.2.0274: hang with combination of feedkeys(), Ex mode and :global
Bram Moolenaar <Bram@vim.org>
parents: 19415
diff changeset
6517 pending_exmode_active = FALSE;
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6518 RedrawingDisabled = rd;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6519 no_wait_return = nwr;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6520 msg_scroll = ms;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6521 #ifdef FEAT_GUI
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6522 hold_gui_events = he;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6523 #endif
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6524 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6525 return;
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6526 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6527 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6528
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6529 if ((eap->cmdidx == CMD_new
675
51794dc170f7 updated for version 7.0202
vimboss
parents: 674
diff changeset
6530 || eap->cmdidx == CMD_tabnew
51794dc170f7 updated for version 7.0202
vimboss
parents: 674
diff changeset
6531 || 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
6532 || eap->cmdidx == CMD_vnew) && *eap->arg == NUL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6533 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6534 // ":new" or ":tabnew" without argument: edit an new empty buffer
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6535 setpcmark();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6536 (void)do_ecmd(0, NULL, NULL, eap, ECMD_ONE,
1743
734d5bdae499 updated for version 7.2-041
vimboss
parents: 1733
diff changeset
6537 ECMD_HIDE + (eap->forceit ? ECMD_FORCEIT : 0),
734d5bdae499 updated for version 7.2-041
vimboss
parents: 1733
diff changeset
6538 old_curwin == NULL ? curwin : NULL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6539 }
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
6540 else if ((eap->cmdidx != CMD_split && eap->cmdidx != CMD_vsplit)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6541 || *eap->arg != NUL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6542 #ifdef FEAT_BROWSE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6543 || cmdmod.browse
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6544 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6545 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6546 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6547 // Can't edit another file when "curbuf_lock" is set. Only ":edit"
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6548 // can bring us here, others are stopped earlier.
822
45fad0f590d0 updated for version 7.0c12
vimboss
parents: 820
diff changeset
6549 if (*eap->arg != NUL && curbuf_locked())
45fad0f590d0 updated for version 7.0c12
vimboss
parents: 820
diff changeset
6550 return;
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13288
diff changeset
6551
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6552 n = readonlymode;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6553 if (eap->cmdidx == CMD_view || eap->cmdidx == CMD_sview)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6554 readonlymode = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6555 else if (eap->cmdidx == CMD_enew)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6556 readonlymode = FALSE; // 'readonly' doesn't make sense in an
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6557 // empty buffer
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6558 setpcmark();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6559 if (do_ecmd(0, (eap->cmdidx == CMD_enew ? NULL : eap->arg),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6560 NULL, eap,
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6561 // ":edit" goes to first line if Vi compatible
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6562 (*eap->arg == NUL && eap->do_ecmd_lnum == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6563 && vim_strchr(p_cpo, CPO_GOTO1) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6564 ? 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
6565 (buf_hide(curbuf) ? ECMD_HIDE : 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6566 + (eap->forceit ? ECMD_FORCEIT : 0)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6567 // after a split we can use an existing buffer
5741
f069a3a0f844 updated for version 7.4.215
Bram Moolenaar <bram@vim.org>
parents: 5737
diff changeset
6568 + (old_curwin != NULL ? ECMD_OLDBUF : 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6569 + (eap->cmdidx == CMD_badd ? ECMD_ADDBUF : 0 )
1743
734d5bdae499 updated for version 7.2-041
vimboss
parents: 1733
diff changeset
6570 , old_curwin == NULL ? curwin : NULL) == FAIL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6571 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6572 // Editing the file failed. If the window was split, close it.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6573 if (old_curwin != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6574 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6575 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
6576 if (!need_hide || buf_hide(curbuf))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6577 {
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13288
diff changeset
6578 #if defined(FEAT_EVAL)
24
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 23
diff changeset
6579 cleanup_T cs;
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 23
diff changeset
6580
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6581 // Reset the error/interrupt/exception state here so that
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6582 // aborting() returns FALSE when closing a window.
24
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 23
diff changeset
6583 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
6584 #endif
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
6585 #ifdef FEAT_GUI
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6586 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
6587 #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
6588 win_close(curwin, !need_hide && !buf_hide(curbuf));
24
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 23
diff changeset
6589
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13288
diff changeset
6590 #if defined(FEAT_EVAL)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6591 // Restore the error/interrupt/exception state if not
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6592 // discarded by a new aborting error, interrupt, or
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6593 // uncaught exception.
24
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 23
diff changeset
6594 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
6595 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6596 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6597 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6598 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6599 else if (readonlymode && curbuf->b_nwindows == 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6600 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6601 // When editing an already visited buffer, 'readonly' won't be set
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6602 // but the previous value is kept. With ":view" and ":sview" we
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6603 // want the file to be readonly, except when another window is
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6604 // editing the same buffer.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6605 curbuf->b_p_ro = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6606 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6607 readonlymode = n;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6608 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6609 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6610 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6611 if (eap->do_ecmd_cmd != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6612 do_cmdline_cmd(eap->do_ecmd_cmd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6613 #ifdef FEAT_TITLE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6614 n = curwin->w_arg_idx_invalid;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6615 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6616 check_arg_idx(curwin);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6617 #ifdef FEAT_TITLE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6618 if (n != curwin->w_arg_idx_invalid)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6619 maketitle();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6620 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6621 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6622
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6623 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6624 * if ":split file" worked, set alternate file name in old window to new
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6625 * file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6626 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6627 if (old_curwin != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6628 && *eap->arg != NUL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6629 && curwin != old_curwin
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6630 && win_valid(old_curwin)
22
cc049b00ee70 updated for version 7.0014
vimboss
parents: 17
diff changeset
6631 && old_curwin->w_buffer != curbuf
cc049b00ee70 updated for version 7.0014
vimboss
parents: 17
diff changeset
6632 && !cmdmod.keepalt)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6633 old_curwin->w_alt_fnum = curbuf->b_fnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6634
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6635 ex_no_reprint = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6636 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6637
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6638 #ifndef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6639 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6640 * ":gui" and ":gvim" when there is no GUI.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6641 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6642 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
6643 ex_nogui(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6644 {
21459
a422bd80b434 patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents: 21413
diff changeset
6645 eap->errmsg = _(e_nogvim);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6646 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6647 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6648
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15866
diff changeset
6649 #if defined(FEAT_GUI_MSWIN) && defined(FEAT_MENU) && defined(FEAT_TEAROFF)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6650 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
6651 ex_tearoff(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6652 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6653 gui_make_tearoff(eap->arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6654 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6655 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6656
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
6657 #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
6658 || defined(FEAT_TERM_POPUP_MENU)) && defined(FEAT_MENU)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6659 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
6660 ex_popup(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6661 {
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
6662 # 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
6663 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
6664 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
6665 # 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
6666 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
6667 # 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
6668 # 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
6669 # 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
6670 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
6671 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6672 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6673 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6674
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6675 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
6676 ex_swapname(exarg_T *eap UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6677 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6678 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
6679 msg(_("No swap file"));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6680 else
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15510
diff changeset
6681 msg((char *)curbuf->b_ml.ml_mfp->mf_fname);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6682 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6683
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6684 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6685 * ":syncbind" forces all 'scrollbind' windows to have the same relative
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6686 * offset.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6687 * (1998-11-02 16:21:01 R. Edward Ralston <eralston@computer.org>)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6688 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6689 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
6690 ex_syncbind(exarg_T *eap UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6691 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6692 win_T *wp;
5566
4b23119cb584 updated for version 7.4.131
Bram Moolenaar <bram@vim.org>
parents: 5545
diff changeset
6693 win_T *save_curwin = curwin;
4b23119cb584 updated for version 7.4.131
Bram Moolenaar <bram@vim.org>
parents: 5545
diff changeset
6694 buf_T *save_curbuf = curbuf;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6695 long topline;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6696 long y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6697 linenr_T old_linenr = curwin->w_cursor.lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6698
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6699 setpcmark();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6700
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6701 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6702 * determine max topline
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6703 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6704 if (curwin->w_p_scb)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6705 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6706 topline = curwin->w_topline;
9649
fd9727ae3c49 commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents: 9538
diff changeset
6707 FOR_ALL_WINDOWS(wp)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6708 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6709 if (wp->w_p_scb && wp->w_buffer)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6710 {
15713
ad8b2c109b22 patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents: 15663
diff changeset
6711 y = wp->w_buffer->b_ml.ml_line_count - get_scrolloff_value();
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6712 if (topline > y)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6713 topline = y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6714 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6715 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6716 if (topline < 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6717 topline = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6718 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6719 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6720 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6721 topline = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6722 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6723
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6724
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6725 /*
5566
4b23119cb584 updated for version 7.4.131
Bram Moolenaar <bram@vim.org>
parents: 5545
diff changeset
6726 * Set all scrollbind windows to the same topline.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6727 */
9649
fd9727ae3c49 commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents: 9538
diff changeset
6728 FOR_ALL_WINDOWS(curwin)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6729 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6730 if (curwin->w_p_scb)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6731 {
5566
4b23119cb584 updated for version 7.4.131
Bram Moolenaar <bram@vim.org>
parents: 5545
diff changeset
6732 curbuf = curwin->w_buffer;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6733 y = topline - curwin->w_topline;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6734 if (y > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6735 scrollup(y, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6736 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6737 scrolldown(-y, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6738 curwin->w_scbind_pos = topline;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6739 redraw_later(VALID);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6740 cursor_correct();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6741 curwin->w_redr_status = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6742 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6743 }
5566
4b23119cb584 updated for version 7.4.131
Bram Moolenaar <bram@vim.org>
parents: 5545
diff changeset
6744 curwin = save_curwin;
4b23119cb584 updated for version 7.4.131
Bram Moolenaar <bram@vim.org>
parents: 5545
diff changeset
6745 curbuf = save_curbuf;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6746 if (curwin->w_p_scb)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6747 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6748 did_syncbind = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6749 checkpcmark();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6750 if (old_linenr != curwin->w_cursor.lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6751 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6752 char_u ctrl_o[2];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6753
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6754 ctrl_o[0] = Ctrl_O;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6755 ctrl_o[1] = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6756 ins_typebuf(ctrl_o, REMAP_NONE, 0, TRUE, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6757 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6758 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6759 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6760
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6761
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6762 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
6763 ex_read(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6764 {
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6765 int i;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6766 int empty = (curbuf->b_ml.ml_flags & ML_EMPTY);
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6767 linenr_T lnum;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6768
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6769 if (eap->usefilter) // :r!cmd
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6770 do_bang(1, eap, FALSE, FALSE, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6771 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6772 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6773 if (u_save(eap->line2, (linenr_T)(eap->line2 + 1)) == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6774 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6775
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6776 #ifdef FEAT_BROWSE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6777 if (cmdmod.browse)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6778 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6779 char_u *browseFile;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6780
28
726bdc53fa49 updated for version 7.0018
vimboss
parents: 24
diff changeset
6781 browseFile = do_browse(0, (char_u *)_("Append File"), eap->arg,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6782 NULL, NULL, NULL, curbuf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6783 if (browseFile != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6784 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6785 i = readfile(browseFile, NULL,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6786 eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6787 vim_free(browseFile);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6788 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6789 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6790 i = OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6791 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6792 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6793 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6794 if (*eap->arg == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6795 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6796 if (check_fname() == FAIL) // check for no file name
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6797 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6798 i = readfile(curbuf->b_ffname, curbuf->b_fname,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6799 eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6800 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6801 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6802 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6803 if (vim_strchr(p_cpo, CPO_ALTREAD) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6804 (void)setaltfname(eap->arg, eap->arg, (linenr_T)1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6805 i = readfile(eap->arg, NULL,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6806 eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6807
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6808 }
10575
01a5f64a7a20 patch 8.0.0177: BufEnter autocommand not fired for a directory
Christian Brabandt <cb@256bit.org>
parents: 10520
diff changeset
6809 if (i != OK)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6810 {
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13288
diff changeset
6811 #if defined(FEAT_EVAL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6812 if (!aborting())
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6813 #endif
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
6814 semsg(_(e_notopen), eap->arg);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6815 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6816 else
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6817 {
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6818 if (empty && exmode_active)
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6819 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6820 // Delete the empty line that remains. Historically ex does
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6821 // this but vi doesn't.
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6822 if (eap->line2 == 0)
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6823 lnum = curbuf->b_ml.ml_line_count;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6824 else
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6825 lnum = 1;
573
c85bf6a4999b updated for version 7.0163
vimboss
parents: 557
diff changeset
6826 if (*ml_get(lnum) == NUL && u_savedel(lnum, 1L) == OK)
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6827 {
20599
d571231175b4 patch 8.2.0853: ml_delete() often called with FALSE argument
Bram Moolenaar <Bram@vim.org>
parents: 20575
diff changeset
6828 ml_delete(lnum);
573
c85bf6a4999b updated for version 7.0163
vimboss
parents: 557
diff changeset
6829 if (curwin->w_cursor.lnum > 1
c85bf6a4999b updated for version 7.0163
vimboss
parents: 557
diff changeset
6830 && curwin->w_cursor.lnum >= lnum)
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6831 --curwin->w_cursor.lnum;
1929
9230c45fdde6 updated for version 7.2-226
vimboss
parents: 1926
diff changeset
6832 deleted_lines_mark(lnum, 1L);
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6833 }
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6834 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6835 redraw_curbuf_later(VALID);
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6836 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6837 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6838 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6839
358
e111db373ca4 updated for version 7.0093
vimboss
parents: 355
diff changeset
6840 static char_u *prev_dir = NULL;
e111db373ca4 updated for version 7.0093
vimboss
parents: 355
diff changeset
6841
e111db373ca4 updated for version 7.0093
vimboss
parents: 355
diff changeset
6842 #if defined(EXITFREE) || defined(PROTO)
e111db373ca4 updated for version 7.0093
vimboss
parents: 355
diff changeset
6843 void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
6844 free_cd_dir(void)
358
e111db373ca4 updated for version 7.0093
vimboss
parents: 355
diff changeset
6845 {
13244
ac42c4b11dbc patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents: 13221
diff changeset
6846 VIM_CLEAR(prev_dir);
ac42c4b11dbc patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents: 13221
diff changeset
6847 VIM_CLEAR(globaldir);
358
e111db373ca4 updated for version 7.0093
vimboss
parents: 355
diff changeset
6848 }
e111db373ca4 updated for version 7.0093
vimboss
parents: 355
diff changeset
6849 #endif
e111db373ca4 updated for version 7.0093
vimboss
parents: 355
diff changeset
6850
4704
542af01979be updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents: 4435
diff changeset
6851 /*
20711
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
6852 * Get the previous directory for the given chdir scope.
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
6853 */
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
6854 static char_u *
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
6855 get_prevdir(cdscope_T scope)
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
6856 {
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
6857 if (scope == CDSCOPE_WINDOW)
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
6858 return curwin->w_prevdir;
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
6859 else if (scope == CDSCOPE_TABPAGE)
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
6860 return curtab->tp_prevdir;
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
6861 return prev_dir;
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
6862 }
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
6863
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
6864 /*
4704
542af01979be updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents: 4435
diff changeset
6865 * 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
6866 * 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
6867 * 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
6868 */
542af01979be updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents: 4435
diff changeset
6869 void
16576
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6870 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
6871 {
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6872 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
6873 // 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
6874 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
6875 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
6876 if (scope != CDSCOPE_GLOBAL)
4704
542af01979be updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents: 4435
diff changeset
6877 {
20711
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
6878 char_u *pdir = get_prevdir(scope);
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
6879
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
6880 // If still in the global directory, need to remember current
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
6881 // directory as the global directory.
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
6882 if (globaldir == NULL && pdir != NULL)
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
6883 globaldir = vim_strsave(pdir);
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
6884
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6885 // Remember this local directory for the window.
4704
542af01979be updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents: 4435
diff changeset
6886 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
6887 {
16576
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6888 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
6889 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
6890 else
8c3a1bd270bb patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents: 16411
diff changeset
6891 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
6892 }
4704
542af01979be updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents: 4435
diff changeset
6893 }
542af01979be updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents: 4435
diff changeset
6894 else
542af01979be updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents: 4435
diff changeset
6895 {
20711
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
6896 // We are now in the global directory, no need to remember its name.
13244
ac42c4b11dbc patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents: 13221
diff changeset
6897 VIM_CLEAR(globaldir);
4704
542af01979be updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents: 4435
diff changeset
6898 }
542af01979be updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents: 4435
diff changeset
6899
542af01979be updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents: 4435
diff changeset
6900 shorten_fnames(TRUE);
542af01979be updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents: 4435
diff changeset
6901 }
542af01979be updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents: 4435
diff changeset
6902
16576
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6903 /*
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6904 * Change directory function used by :cd/:tcd/:lcd Ex commands and the
20645
b60bb094af52 patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents: 20599
diff changeset
6905 * chdir() function.
b60bb094af52 patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents: 20599
diff changeset
6906 * scope == CDSCOPE_WINDOW: changes the window-local directory
b60bb094af52 patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents: 20599
diff changeset
6907 * scope == CDSCOPE_TABPAGE: changes the tab-local directory
b60bb094af52 patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents: 20599
diff changeset
6908 * Otherwise: changes the global directory
16576
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6909 * 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
6910 */
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6911 int
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6912 changedir_func(
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6913 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
6914 int forceit,
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6915 cdscope_T scope)
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6916 {
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6917 char_u *tofree;
20711
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
6918 char_u *pdir = NULL;
16576
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6919 int dir_differs;
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6920 int retval = FALSE;
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6921
19261
a20c66f13a6e patch 8.2.0189: cd() with NULL argument crashes
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
6922 if (new_dir == NULL || allbuf_locked())
16576
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6923 return FALSE;
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6924
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6925 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
6926 {
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6927 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
6928 return FALSE;
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6929 }
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6930
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6931 // ":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
6932 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
6933 {
20711
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
6934 pdir = get_prevdir(scope);
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
6935 if (pdir == NULL)
16576
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6936 {
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6937 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
6938 return FALSE;
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6939 }
20711
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
6940 new_dir = pdir;
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
6941 }
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
6942
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
6943 // Free the previous directory
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
6944 tofree = get_prevdir(scope);
16576
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6945
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6946 // 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
6947 if (mch_dirname(NameBuff, MAXPATHL) == OK)
20711
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
6948 pdir = vim_strsave(NameBuff);
16576
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6949 else
20711
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
6950 pdir = NULL;
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
6951 if (scope == CDSCOPE_WINDOW)
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
6952 curwin->w_prevdir = pdir;
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
6953 else if (scope == CDSCOPE_TABPAGE)
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
6954 curtab->tp_prevdir = pdir;
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
6955 else
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
6956 prev_dir = pdir;
16576
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6957
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6958 #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
6959 // 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
6960 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
6961 {
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6962 // 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
6963 # ifdef VMS
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6964 char_u *p;
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6965
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6966 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
6967 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
6968 NameBuff[0] = NUL;
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6969 else
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6970 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
6971 # else
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6972 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
6973 # endif
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6974 new_dir = NameBuff;
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6975 }
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6976 #endif
20711
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
6977 dir_differs = new_dir == NULL || pdir == NULL
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
6978 || pathcmp((char *)pdir, (char *)new_dir, -1) != 0;
16576
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6979 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
6980 emsg(_(e_failed));
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6981 else
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6982 {
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6983 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
6984
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6985 post_chdir(scope);
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6986
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6987 if (dir_differs)
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6988 {
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6989 if (scope == CDSCOPE_WINDOW)
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6990 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
6991 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
6992 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
6993 else
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6994 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
6995 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
6996 curbuf);
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6997 }
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6998 retval = TRUE;
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
6999 }
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7000 vim_free(tofree);
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7001
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7002 return retval;
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7003 }
358
e111db373ca4 updated for version 7.0093
vimboss
parents: 355
diff changeset
7004
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7005 /*
16427
8c3a1bd270bb patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents: 16411
diff changeset
7006 * ":cd", ":tcd", ":lcd", ":chdir" ":tchdir" and ":lchdir".
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7007 */
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1408
diff changeset
7008 void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
7009 ex_cd(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7010 {
15184
90ab2d3ce11d patch 8.1.0602: DirChanged is also triggered when directory didn't change
Bram Moolenaar <Bram@vim.org>
parents: 15152
diff changeset
7011 char_u *new_dir;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7012
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7013 new_dir = eap->arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7014 #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
7015 // for non-UNIX ":cd" means: print current directory
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7016 if (*new_dir == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7017 ex_pwd(NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7018 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7019 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7020 {
16576
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7021 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
7022
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7023 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
7024 scope = CDSCOPE_WINDOW;
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7025 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
7026 scope = CDSCOPE_TABPAGE;
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7027
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7028 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
7029 {
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7030 // Echo the new current directory if the command was typed.
1930
89d1e8ed6c1d updated for version 7.2-227
vimboss
parents: 1929
diff changeset
7031 if (KeyTyped || p_verbose >= 5)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7032 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
7033 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7034 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7035 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7036
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7037 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7038 * ":pwd".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7039 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7040 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
7041 ex_pwd(exarg_T *eap UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7042 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7043 if (mch_dirname(NameBuff, MAXPATHL) == OK)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7044 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7045 #ifdef BACKSLASH_IN_FILENAME
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7046 slash_adjust(NameBuff);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7047 #endif
20645
b60bb094af52 patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents: 20599
diff changeset
7048 if (p_verbose > 0)
b60bb094af52 patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents: 20599
diff changeset
7049 {
b60bb094af52 patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents: 20599
diff changeset
7050 char *context = "global";
b60bb094af52 patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents: 20599
diff changeset
7051
b60bb094af52 patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents: 20599
diff changeset
7052 if (curwin->w_localdir != NULL)
b60bb094af52 patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents: 20599
diff changeset
7053 context = "window";
b60bb094af52 patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents: 20599
diff changeset
7054 else if (curtab->tp_localdir != NULL)
b60bb094af52 patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents: 20599
diff changeset
7055 context = "tabpage";
b60bb094af52 patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents: 20599
diff changeset
7056 smsg("[%s] %s", context, (char *)NameBuff);
b60bb094af52 patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents: 20599
diff changeset
7057 }
b60bb094af52 patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents: 20599
diff changeset
7058 else
b60bb094af52 patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents: 20599
diff changeset
7059 msg((char *)NameBuff);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7060 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7061 else
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
7062 emsg(_("E187: Unknown"));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7063 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7064
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7065 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7066 * ":=".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7067 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7068 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
7069 ex_equal(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7070 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
7071 smsg("%ld", (long)eap->line2);
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7072 ex_may_print(eap);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7073 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7074
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7075 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
7076 ex_sleep(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7077 {
236
4707450c2b33 updated for version 7.0066
vimboss
parents: 198
diff changeset
7078 int n;
4707450c2b33 updated for version 7.0066
vimboss
parents: 198
diff changeset
7079 long len;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7080
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7081 if (cursor_valid())
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7082 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7083 n = W_WINROW(curwin) + curwin->w_wrow - msg_scrolled;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7084 if (n >= 0)
12513
3ca08bf99396 patch 8.0.1135: W_WINCOL() is always the same
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
7085 windgoto((int)n, curwin->w_wincol + curwin->w_wcol);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7086 }
236
4707450c2b33 updated for version 7.0066
vimboss
parents: 198
diff changeset
7087
4707450c2b33 updated for version 7.0066
vimboss
parents: 198
diff changeset
7088 len = eap->line2;
4707450c2b33 updated for version 7.0066
vimboss
parents: 198
diff changeset
7089 switch (*eap->arg)
4707450c2b33 updated for version 7.0066
vimboss
parents: 198
diff changeset
7090 {
4707450c2b33 updated for version 7.0066
vimboss
parents: 198
diff changeset
7091 case 'm': break;
4707450c2b33 updated for version 7.0066
vimboss
parents: 198
diff changeset
7092 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
7093 default: semsg(_(e_invarg2), eap->arg); return;
236
4707450c2b33 updated for version 7.0066
vimboss
parents: 198
diff changeset
7094 }
4707450c2b33 updated for version 7.0066
vimboss
parents: 198
diff changeset
7095 do_sleep(len);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7096 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7097
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7098 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7099 * Sleep for "msec" milliseconds, but keep checking for a CTRL-C every second.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7100 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7101 void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
7102 do_sleep(long msec)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7103 {
17712
316ae5631c1d patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents: 17708
diff changeset
7104 long done = 0;
8577
63dc856bd13d commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents: 8524
diff changeset
7105 long wait_now;
17712
316ae5631c1d patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents: 17708
diff changeset
7106 # ifdef ELAPSED_FUNC
316ae5631c1d patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents: 17708
diff changeset
7107 elapsed_T start_tv;
316ae5631c1d patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents: 17708
diff changeset
7108
316ae5631c1d patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents: 17708
diff changeset
7109 // 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
7110 // 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
7111 ELAPSED_INIT(start_tv);
316ae5631c1d patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents: 17708
diff changeset
7112 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7113
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7114 cursor_on();
14860
ac5d0d27aef9 patch 8.1.0442: GUI: cursor not drawn after ":redraw | sleep"
Christian Brabandt <cb@256bit.org>
parents: 14760
diff changeset
7115 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
7116 while (!got_int && done < msec)
8577
63dc856bd13d commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents: 8524
diff changeset
7117 {
63dc856bd13d commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents: 8524
diff changeset
7118 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
7119 #ifdef FEAT_TIMERS
63dc856bd13d commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents: 8524
diff changeset
7120 {
63dc856bd13d commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents: 8524
diff changeset
7121 long due_time = check_due_timer();
63dc856bd13d commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents: 8524
diff changeset
7122
63dc856bd13d commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents: 8524
diff changeset
7123 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
7124 wait_now = due_time;
63dc856bd13d commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents: 8524
diff changeset
7125 }
63dc856bd13d commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents: 8524
diff changeset
7126 #endif
10240
175b1116f96a commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents: 10184
diff changeset
7127 #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
7128 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
7129 wait_now = 20L;
10696f279e20 patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents: 17652
diff changeset
7130 #endif
10696f279e20 patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents: 17652
diff changeset
7131 #ifdef FEAT_SOUND
10696f279e20 patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents: 17652
diff changeset
7132 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
7133 wait_now = 20L;
10240
175b1116f96a commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents: 10184
diff changeset
7134 #endif
8577
63dc856bd13d commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents: 8524
diff changeset
7135 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
7136
10240
175b1116f96a commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents: 10184
diff changeset
7137 #ifdef FEAT_JOB_CHANNEL
175b1116f96a commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents: 10184
diff changeset
7138 if (has_any_channel())
175b1116f96a commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents: 10184
diff changeset
7139 ui_breakcheck_force(TRUE);
175b1116f96a commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents: 10184
diff changeset
7140 else
175b1116f96a commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents: 10184
diff changeset
7141 #endif
175b1116f96a commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents: 10184
diff changeset
7142 ui_breakcheck();
7109
fa95595fbc52 commit https://github.com/vim/vim/commit/93c88e0f6a4a8f7634ed84721daf4af46fc0d5db
Christian Brabandt <cb@256bit.org>
parents: 7105
diff changeset
7143 #ifdef MESSAGE_QUEUE
17712
316ae5631c1d patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents: 17708
diff changeset
7144 // 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
7145 // 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
7146 // 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
7147 parse_queued_messages();
3151
af76a61a7f79 updated for version 7.3.346
Bram Moolenaar <bram@vim.org>
parents: 3116
diff changeset
7148 #endif
17712
316ae5631c1d patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents: 17708
diff changeset
7149
316ae5631c1d patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents: 17708
diff changeset
7150 # ifdef ELAPSED_FUNC
316ae5631c1d patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents: 17708
diff changeset
7151 // actual time passed
316ae5631c1d patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents: 17708
diff changeset
7152 done = ELAPSED_FUNC(start_tv);
316ae5631c1d patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents: 17708
diff changeset
7153 # else
316ae5631c1d patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents: 17708
diff changeset
7154 // 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
7155 done += wait_now;
316ae5631c1d patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents: 17708
diff changeset
7156 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7157 }
14284
7cd8298c4c04 patch 8.1.0158: GUI: input() fails if CTRL-C was pressed before
Christian Brabandt <cb@256bit.org>
parents: 14266
diff changeset
7158
7cd8298c4c04 patch 8.1.0158: GUI: input() fails if CTRL-C was pressed before
Christian Brabandt <cb@256bit.org>
parents: 14266
diff changeset
7159 // 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
7160 // 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
7161 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
7162 (void)vpeekc();
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7163 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7164
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7165 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7166 * ":winsize" command (obsolete).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7167 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7168 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
7169 ex_winsize(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7170 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7171 int w, h;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7172 char_u *arg = eap->arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7173 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7174
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7175 w = getdigits(&arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7176 arg = skipwhite(arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7177 p = arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7178 h = getdigits(&arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7179 if (*p != NUL && *arg == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7180 set_shellsize(w, h, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7181 else
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
7182 emsg(_("E465: :winsize requires two number arguments"));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7183 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7184
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7185 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
7186 ex_wincmd(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7187 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7188 int xchar = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7189 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7190
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7191 if (*eap->arg == 'g' || *eap->arg == Ctrl_G)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7192 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7193 // CTRL-W g and CTRL-W CTRL-G have an extra command character
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7194 if (eap->arg[1] == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7195 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
7196 emsg(_(e_invarg));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7197 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7198 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7199 xchar = eap->arg[1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7200 p = eap->arg + 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7201 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7202 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7203 p = eap->arg + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7204
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7205 eap->nextcmd = check_nextcmd(p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7206 p = skipwhite(p);
21353
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
7207 if (*p != NUL && *p != (
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
7208 #ifdef FEAT_EVAL
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
7209 in_vim9script() ? '#' :
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
7210 #endif
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
7211 '"')
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
7212 && eap->nextcmd == NULL)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
7213 emsg(_(e_invarg));
2887
15705b520c29 updated for version 7.3.217
Bram Moolenaar <bram@vim.org>
parents: 2853
diff changeset
7214 else if (!eap->skip)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7215 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7216 // Pass flags on for ":vertical wincmd ]".
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7217 postponed_split_flags = cmdmod.split;
1090
9a3b65713280 updated for version 7.0-216
vimboss
parents: 1088
diff changeset
7218 postponed_split_tab = cmdmod.tab;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7219 do_window(*eap->arg, eap->addr_count > 0 ? eap->line2 : 0L, xchar);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7220 postponed_split_flags = 0;
1090
9a3b65713280 updated for version 7.0-216
vimboss
parents: 1088
diff changeset
7221 postponed_split_tab = 0;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7222 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7223 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7224
11
4424b47a0797 updated for version 7.0003
vimboss
parents: 9
diff changeset
7225 #if defined(FEAT_GUI) || defined(UNIX) || defined(VMS) || defined(MSWIN)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7226 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7227 * ":winpos".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7228 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7229 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
7230 ex_winpos(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7231 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7232 int x, y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7233 char_u *arg = eap->arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7234 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7235
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7236 if (*arg == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7237 {
11
4424b47a0797 updated for version 7.0003
vimboss
parents: 9
diff changeset
7238 # 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
7239 # 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
7240 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
7241 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
7242 # elif defined(FEAT_GUI)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7243 if (gui.in_use && gui_mch_get_winpos(&x, &y) != FAIL)
11
4424b47a0797 updated for version 7.0003
vimboss
parents: 9
diff changeset
7244 # else
4424b47a0797 updated for version 7.0003
vimboss
parents: 9
diff changeset
7245 if (mch_get_winpos(&x, &y) != FAIL)
4424b47a0797 updated for version 7.0003
vimboss
parents: 9
diff changeset
7246 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7247 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7248 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
7249 msg((char *)IObuff);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7250 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7251 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7252 # endif
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
7253 emsg(_("E188: Obtaining window position not implemented for this platform"));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7254 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7255 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7256 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7257 x = getdigits(&arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7258 arg = skipwhite(arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7259 p = arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7260 y = getdigits(&arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7261 if (*p == NUL || *arg != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7262 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
7263 emsg(_("E466: :winpos requires two number arguments"));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7264 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7265 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7266 # ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7267 if (gui.in_use)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7268 gui_mch_set_winpos(x, y);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7269 else if (gui.starting)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7270 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7271 // Remember the coordinates for when the window is opened.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7272 gui_win_x = x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7273 gui_win_y = y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7274 }
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
7275 # if defined(HAVE_TGETENT) || defined(VIMDLL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7276 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7277 # 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
7278 # 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
7279 # if defined(MSWIN) && (!defined(FEAT_GUI) || defined(VIMDLL))
11
4424b47a0797 updated for version 7.0003
vimboss
parents: 9
diff changeset
7280 mch_set_winpos(x, y);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7281 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7282 # ifdef HAVE_TGETENT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7283 if (*T_CWP)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7284 term_set_winpos(x, y);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7285 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7286 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7287 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7288 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7289
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7290 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7291 * Handle command that work like operators: ":delete", ":yank", ":>" and ":<".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7292 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7293 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
7294 ex_operators(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7295 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7296 oparg_T oa;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7297
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7298 clear_oparg(&oa);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7299 oa.regname = eap->regname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7300 oa.start.lnum = eap->line1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7301 oa.end.lnum = eap->line2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7302 oa.line_count = eap->line2 - eap->line1 + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7303 oa.motion_type = MLINE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7304 virtual_op = FALSE;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7305 if (eap->cmdidx != CMD_yank) // position cursor for undo
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7306 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7307 setpcmark();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7308 curwin->w_cursor.lnum = eap->line1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7309 beginline(BL_SOL | BL_FIX);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7310 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7311
5498
79a8bac614c0 updated for version 7.4.098
Bram Moolenaar <bram@vim.org>
parents: 5467
diff changeset
7312 if (VIsual_active)
79a8bac614c0 updated for version 7.4.098
Bram Moolenaar <bram@vim.org>
parents: 5467
diff changeset
7313 end_visual_mode();
79a8bac614c0 updated for version 7.4.098
Bram Moolenaar <bram@vim.org>
parents: 5467
diff changeset
7314
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7315 switch (eap->cmdidx)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7316 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7317 case CMD_delete:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7318 oa.op_type = OP_DELETE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7319 op_delete(&oa);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7320 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7321
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7322 case CMD_yank:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7323 oa.op_type = OP_YANK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7324 (void)op_yank(&oa, FALSE, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7325 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7326
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7327 default: // CMD_rshift or CMD_lshift
4889
25d64a4edc0b updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents: 4857
diff changeset
7328 if (
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7329 #ifdef FEAT_RIGHTLEFT
4889
25d64a4edc0b updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents: 4857
diff changeset
7330 (eap->cmdidx == CMD_rshift) ^ curwin->w_p_rl
25d64a4edc0b updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents: 4857
diff changeset
7331 #else
25d64a4edc0b updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents: 4857
diff changeset
7332 eap->cmdidx == CMD_rshift
25d64a4edc0b updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents: 4857
diff changeset
7333 #endif
25d64a4edc0b updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents: 4857
diff changeset
7334 )
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7335 oa.op_type = OP_RSHIFT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7336 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7337 oa.op_type = OP_LSHIFT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7338 op_shift(&oa, FALSE, eap->amount);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7339 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7340 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7341 virtual_op = MAYBE;
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7342 ex_may_print(eap);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7343 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7344
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7345 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7346 * ":put".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7347 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7348 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
7349 ex_put(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7350 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7351 // ":0put" works like ":1put!".
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7352 if (eap->line2 == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7353 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7354 eap->line2 = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7355 eap->forceit = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7356 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7357 curwin->w_cursor.lnum = eap->line2;
22176
6941d3205be9 patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents: 21939
diff changeset
7358 do_put(eap->regname, NULL, eap->forceit ? BACKWARD : FORWARD, 1L,
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7359 PUT_LINE|PUT_CURSLINE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7360 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7361
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7362 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7363 * Handle ":copy" and ":move".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7364 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7365 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
7366 ex_copymove(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7367 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7368 long n;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7369
21592
7d721e95dc51 patch 8.2.1346: small build fails
Bram Moolenaar <Bram@vim.org>
parents: 21584
diff changeset
7370 #ifdef FEAT_EVAL
21584
d0c76ce48326 patch 8.2.1342: Vim9: accidentally using "t" gives a confusing error
Bram Moolenaar <Bram@vim.org>
parents: 21544
diff changeset
7371 if (not_in_vim9(eap) == FAIL)
d0c76ce48326 patch 8.2.1342: Vim9: accidentally using "t" gives a confusing error
Bram Moolenaar <Bram@vim.org>
parents: 21544
diff changeset
7372 return;
21592
7d721e95dc51 patch 8.2.1346: small build fails
Bram Moolenaar <Bram@vim.org>
parents: 21584
diff changeset
7373 #endif
14760
fd69edd2c67e patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents: 14700
diff changeset
7374 n = get_address(eap, &eap->arg, eap->addr_type, FALSE, FALSE, FALSE, 1);
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7375 if (eap->arg == NULL) // error detected
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7376 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7377 eap->nextcmd = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7378 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7379 }
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7380 get_flags(eap);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7381
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7382 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7383 * move or copy lines from 'eap->line1'-'eap->line2' to below line 'n'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7384 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7385 if (n == MAXLNUM || n < 0 || n > curbuf->b_ml.ml_line_count)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7386 {
17650
a1437b8f2fac patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
7387 emsg(_(e_invrange));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7388 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7389 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7390
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7391 if (eap->cmdidx == CMD_move)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7392 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7393 if (do_move(eap->line1, eap->line2, n) == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7394 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7395 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7396 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7397 ex_copy(eap->line1, eap->line2, n);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7398 u_clearline();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7399 beginline(BL_SOL | BL_FIX);
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7400 ex_may_print(eap);
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7401 }
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7402
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7403 /*
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7404 * Print the current line if flags were given to the Ex command.
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7405 */
5776
845608965bd9 updated for version 7.4.232
Bram Moolenaar <bram@vim.org>
parents: 5741
diff changeset
7406 void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
7407 ex_may_print(exarg_T *eap)
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7408 {
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7409 if (eap->flags != 0)
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7410 {
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7411 print_line(curwin->w_cursor.lnum, (eap->flags & EXFLAG_NR),
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7412 (eap->flags & EXFLAG_LIST));
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7413 ex_no_reprint = TRUE;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7414 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7415 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7416
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7417 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7418 * ":smagic" and ":snomagic".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7419 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7420 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
7421 ex_submagic(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7422 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7423 int magic_save = p_magic;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7424
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7425 p_magic = (eap->cmdidx == CMD_smagic);
21773
2f2e528c5782 patch 8.2.1436: function implementing :substitute has unexpected name
Bram Moolenaar <Bram@vim.org>
parents: 21727
diff changeset
7426 ex_substitute(eap);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7427 p_magic = magic_save;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7428 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7429
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7430 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7431 * ":join".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7432 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7433 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
7434 ex_join(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7435 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7436 curwin->w_cursor.lnum = eap->line1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7437 if (eap->line1 == eap->line2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7438 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7439 if (eap->addr_count >= 2) // :2,2join does nothing
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7440 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7441 if (eap->line2 == curbuf->b_ml.ml_line_count)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7442 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7443 beep_flush();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7444 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7445 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7446 ++eap->line2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7447 }
5848
75f222d67cea updated for version 7.4.267
Bram Moolenaar <bram@vim.org>
parents: 5790
diff changeset
7448 (void)do_join(eap->line2 - eap->line1 + 1, !eap->forceit, TRUE, TRUE, TRUE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7449 beginline(BL_WHITE | BL_FIX);
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7450 ex_may_print(eap);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7451 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7452
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7453 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7454 * ":[addr]@r" or ":[addr]*r": execute register
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7455 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7456 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
7457 ex_at(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7458 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7459 int c;
1973
1e52efdc900c updated for version 7.2-270
vimboss
parents: 1968
diff changeset
7460 int prev_len = typebuf.tb_len;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7461
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7462 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
7463 check_cursor_col();
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7464
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7465 #ifdef USE_ON_FLY_SCROLL
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7466 dont_scroll = TRUE; // disallow scrolling here
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7467 #endif
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7468
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7469 // get the register name. No name means to use the previous one
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7470 c = *eap->arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7471 if (c == NUL || (c == '*' && *eap->cmd == '*'))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7472 c = '@';
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7473 // Put the register in the typeahead buffer with the "silent" flag.
1034
98d1c149be76 updated for version 7.0-160
vimboss
parents: 1021
diff changeset
7474 if (do_execreg(c, TRUE, vim_strchr(p_cpo, CPO_EXECBUF) != NULL, TRUE)
98d1c149be76 updated for version 7.0-160
vimboss
parents: 1021
diff changeset
7475 == FAIL)
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7476 {
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7477 beep_flush();
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7478 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7479 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7480 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7481 int save_efr = exec_from_reg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7482
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7483 exec_from_reg = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7484
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7485 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7486 * Execute from the typeahead buffer.
1973
1e52efdc900c updated for version 7.2-270
vimboss
parents: 1968
diff changeset
7487 * Continue until the stuff buffer is empty and all added characters
1e52efdc900c updated for version 7.2-270
vimboss
parents: 1968
diff changeset
7488 * have been consumed.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7489 */
1973
1e52efdc900c updated for version 7.2-270
vimboss
parents: 1968
diff changeset
7490 while (!stuff_empty() || typebuf.tb_len > prev_len)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7491 (void)do_cmdline(NULL, getexline, NULL, DOCMD_NOWAIT|DOCMD_VERBOSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7492
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7493 exec_from_reg = save_efr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7494 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7495 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7496
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7497 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7498 * ":!".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7499 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7500 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
7501 ex_bang(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7502 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7503 do_bang(eap->addr_count, eap, eap->forceit, TRUE, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7504 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7505
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7506 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7507 * ":undo".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7508 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7509 static void
8368
db2a07b710ed commit https://github.com/vim/vim/commit/f1d2501ebe33e148886c2914acd33140e20ee222
Christian Brabandt <cb@256bit.org>
parents: 8281
diff changeset
7510 ex_undo(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7511 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7512 if (eap->addr_count == 1) // :undo 123
2281
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2276
diff changeset
7513 undo_time(eap->line2, FALSE, FALSE, TRUE);
771
c0f1b710ce07 updated for version 7.0226
vimboss
parents: 756
diff changeset
7514 else
c0f1b710ce07 updated for version 7.0226
vimboss
parents: 756
diff changeset
7515 u_undo(1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7516 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7517
2214
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2210
diff changeset
7518 #ifdef FEAT_PERSISTENT_UNDO
2340
99c1eba60b2d Make automatic prototype generation work with more interfaces.
Bram Moolenaar <bram@vim.org>
parents: 2333
diff changeset
7519 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
7520 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
7521 {
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2210
diff changeset
7522 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
7523
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2210
diff changeset
7524 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
7525 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
7526 }
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2210
diff changeset
7527
2340
99c1eba60b2d Make automatic prototype generation work with more interfaces.
Bram Moolenaar <bram@vim.org>
parents: 2333
diff changeset
7528 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
7529 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
7530 {
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2210
diff changeset
7531 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
7532
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2210
diff changeset
7533 u_compute_hash(hash);
2238
3d0a7beb0d75 Made reading/writing undo info a bit more robust.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
7534 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
7535 }
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2210
diff changeset
7536 #endif
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2210
diff changeset
7537
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7538 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7539 * ":redo".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7540 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7541 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
7542 ex_redo(exarg_T *eap UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7543 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7544 u_redo(1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7545 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7546
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7547 /*
756
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
7548 * ":earlier" and ":later".
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
7549 */
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
7550 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
7551 ex_later(exarg_T *eap)
756
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
7552 {
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
7553 long count = 0;
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
7554 int sec = FALSE;
2281
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2276
diff changeset
7555 int file = FALSE;
756
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
7556 char_u *p = eap->arg;
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
7557
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
7558 if (*p == NUL)
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
7559 count = 1;
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
7560 else if (isdigit(*p))
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
7561 {
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
7562 count = getdigits(&p);
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
7563 switch (*p)
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
7564 {
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
7565 case 's': ++p; sec = TRUE; break;
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
7566 case 'm': ++p; sec = TRUE; count *= 60; break;
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
7567 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
7568 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
7569 case 'f': ++p; file = TRUE; break;
756
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
7570 }
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
7571 }
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
7572
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
7573 if (*p != NUL)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
7574 semsg(_(e_invarg2), eap->arg);
756
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
7575 else
2281
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2276
diff changeset
7576 undo_time(eap->cmdidx == CMD_earlier ? -count : count,
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2276
diff changeset
7577 sec, file, FALSE);
756
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
7578 }
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
7579
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
7580 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7581 * ":redir": start/stop redirection.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7582 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7583 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
7584 ex_redir(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7585 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7586 char *mode;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7587 char_u *fname;
122
56eb9755174b updated for version 7.0043
vimboss
parents: 111
diff changeset
7588 char_u *arg = eap->arg;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7589
9440
73c0d07cc15e commit https://github.com/vim/vim/commit/ba768495c2e6bae74e49d22d489fbf211ecad55e
Christian Brabandt <cb@256bit.org>
parents: 9438
diff changeset
7590 #ifdef FEAT_EVAL
9454
9da0cb39cbee commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents: 9440
diff changeset
7591 if (redir_execute)
9da0cb39cbee commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents: 9440
diff changeset
7592 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
7593 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
7594 return;
7897b1e4f3e7 commit https://github.com/vim/vim/commit/245a7cb6d33e556415c9fcaa874b784a6d8f0ef3
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
7595 }
9440
73c0d07cc15e commit https://github.com/vim/vim/commit/ba768495c2e6bae74e49d22d489fbf211ecad55e
Christian Brabandt <cb@256bit.org>
parents: 9438
diff changeset
7596 #endif
9438
7897b1e4f3e7 commit https://github.com/vim/vim/commit/245a7cb6d33e556415c9fcaa874b784a6d8f0ef3
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
7597
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7598 if (STRICMP(eap->arg, "END") == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7599 close_redir();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7600 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7601 {
122
56eb9755174b updated for version 7.0043
vimboss
parents: 111
diff changeset
7602 if (*arg == '>')
56eb9755174b updated for version 7.0043
vimboss
parents: 111
diff changeset
7603 {
56eb9755174b updated for version 7.0043
vimboss
parents: 111
diff changeset
7604 ++arg;
56eb9755174b updated for version 7.0043
vimboss
parents: 111
diff changeset
7605 if (*arg == '>')
56eb9755174b updated for version 7.0043
vimboss
parents: 111
diff changeset
7606 {
56eb9755174b updated for version 7.0043
vimboss
parents: 111
diff changeset
7607 ++arg;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7608 mode = "a";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7609 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7610 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7611 mode = "w";
122
56eb9755174b updated for version 7.0043
vimboss
parents: 111
diff changeset
7612 arg = skipwhite(arg);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7613
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7614 close_redir();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7615
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7616 // Expand environment variables and "~/".
122
56eb9755174b updated for version 7.0043
vimboss
parents: 111
diff changeset
7617 fname = expand_env_save(arg);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7618 if (fname == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7619 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7620 #ifdef FEAT_BROWSE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7621 if (cmdmod.browse)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7622 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7623 char_u *browseFile;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7624
28
726bdc53fa49 updated for version 7.0018
vimboss
parents: 24
diff changeset
7625 browseFile = do_browse(BROWSE_SAVE,
726bdc53fa49 updated for version 7.0018
vimboss
parents: 24
diff changeset
7626 (char_u *)_("Save Redirection"),
13802
378f9f8e6d8f patch 8.0.1773: dialog messages are not translated
Christian Brabandt <cb@256bit.org>
parents: 13792
diff changeset
7627 fname, NULL, NULL,
378f9f8e6d8f patch 8.0.1773: dialog messages are not translated
Christian Brabandt <cb@256bit.org>
parents: 13792
diff changeset
7628 (char_u *)_(BROWSE_FILTER_ALL_FILES), curbuf);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7629 if (browseFile == NULL)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7630 return; // operation cancelled
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7631 vim_free(fname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7632 fname = browseFile;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7633 eap->forceit = TRUE; // since dialog already asked
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7634 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7635 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7636
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7637 redir_fd = open_exfile(fname, eap->forceit, mode);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7638 vim_free(fname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7639 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7640 #ifdef FEAT_EVAL
122
56eb9755174b updated for version 7.0043
vimboss
parents: 111
diff changeset
7641 else if (*arg == '@')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7642 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7643 // redirect to a register a-z (resp. A-Z for appending)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7644 close_redir();
122
56eb9755174b updated for version 7.0043
vimboss
parents: 111
diff changeset
7645 ++arg;
56eb9755174b updated for version 7.0043
vimboss
parents: 111
diff changeset
7646 if (ASCII_ISALPHA(*arg)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7647 # ifdef FEAT_CLIPBOARD
122
56eb9755174b updated for version 7.0043
vimboss
parents: 111
diff changeset
7648 || *arg == '*'
1038
777d5460622d updated for version 7.0-164
vimboss
parents: 1034
diff changeset
7649 || *arg == '+'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7650 # endif
122
56eb9755174b updated for version 7.0043
vimboss
parents: 111
diff changeset
7651 || *arg == '"')
56eb9755174b updated for version 7.0043
vimboss
parents: 111
diff changeset
7652 {
56eb9755174b updated for version 7.0043
vimboss
parents: 111
diff changeset
7653 redir_reg = *arg++;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7654 if (*arg == '>' && arg[1] == '>') // append
268
8e3c690f1f3c updated for version 7.0072
vimboss
parents: 236
diff changeset
7655 arg += 2;
1427
0e5eb96dc18c updated for version 7.1-142
vimboss
parents: 1411
diff changeset
7656 else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7657 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7658 // Can use both "@a" and "@a>".
296
00b73c762d77 updated for version 7.0078
vimboss
parents: 291
diff changeset
7659 if (*arg == '>')
00b73c762d77 updated for version 7.0078
vimboss
parents: 291
diff changeset
7660 arg++;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7661 // Make register empty when not using @A-@Z and the
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7662 // command is valid.
1427
0e5eb96dc18c updated for version 7.1-142
vimboss
parents: 1411
diff changeset
7663 if (*arg == NUL && !isupper(redir_reg))
0e5eb96dc18c updated for version 7.1-142
vimboss
parents: 1411
diff changeset
7664 write_reg_contents(redir_reg, (char_u *)"", -1, FALSE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7665 }
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7666 }
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7667 if (*arg != NUL)
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7668 {
268
8e3c690f1f3c updated for version 7.0072
vimboss
parents: 236
diff changeset
7669 redir_reg = 0;
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
7670 semsg(_(e_invarg2), eap->arg);
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7671 }
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7672 }
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7673 else if (*arg == '=' && arg[1] == '>')
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7674 {
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7675 int append;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7676
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7677 // redirect to a variable
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7678 close_redir();
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7679 arg += 2;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7680
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7681 if (*arg == '>')
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7682 {
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7683 ++arg;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7684 append = TRUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7685 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7686 else
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7687 append = FALSE;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7688
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7689 if (var_redir_start(skipwhite(arg), append) == OK)
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7690 redir_vname = 1;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7691 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7692 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7693
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7694 // TODO: redirect to a buffer
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7695
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7696 else
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
7697 semsg(_(e_invarg2), eap->arg);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7698 }
972
decce137e7be updated for version 7.0-098
vimboss
parents: 971
diff changeset
7699
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7700 // Make sure redirection is not off. Can happen for cmdline completion
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7701 // that indirectly invokes a command to catch its output.
972
decce137e7be updated for version 7.0-098
vimboss
parents: 971
diff changeset
7702 if (redir_fd != NULL
decce137e7be updated for version 7.0-098
vimboss
parents: 971
diff changeset
7703 #ifdef FEAT_EVAL
decce137e7be updated for version 7.0-098
vimboss
parents: 971
diff changeset
7704 || redir_reg || redir_vname
decce137e7be updated for version 7.0-098
vimboss
parents: 971
diff changeset
7705 #endif
decce137e7be updated for version 7.0-098
vimboss
parents: 971
diff changeset
7706 )
decce137e7be updated for version 7.0-098
vimboss
parents: 971
diff changeset
7707 redir_off = FALSE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7708 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7709
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7710 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7711 * ":redraw": force redraw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7712 */
7864
6b0891de44a9 commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents: 7850
diff changeset
7713 void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
7714 ex_redraw(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7715 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7716 int r = RedrawingDisabled;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7717 int p = p_lz;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7718
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7719 RedrawingDisabled = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7720 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
7721 validate_cursor();
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7722 update_topline();
5735
50dbef5e774a updated for version 7.4.212
Bram Moolenaar <bram@vim.org>
parents: 5720
diff changeset
7723 update_screen(eap->forceit ? CLEAR : VIsual_active ? INVERTED : 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7724 #ifdef FEAT_TITLE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7725 if (need_maketitle)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7726 maketitle();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7727 #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
7728 #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
7729 # 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
7730 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
7731 # 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
7732 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
7733 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7734 RedrawingDisabled = r;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7735 p_lz = p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7736
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7737 // Reset msg_didout, so that a message that's there is overwritten.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7738 msg_didout = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7739 msg_col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7740
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7741 // No need to wait after an intentional redraw.
5198
1b89e3f916c5 updated for version 7.4a.025
Bram Moolenaar <bram@vim.org>
parents: 4928
diff changeset
7742 need_wait_return = FALSE;
1b89e3f916c5 updated for version 7.4a.025
Bram Moolenaar <bram@vim.org>
parents: 4928
diff changeset
7743
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7744 out_flush();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7745 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7746
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7747 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7748 * ":redrawstatus": force redraw of status line(s)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7749 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7750 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
7751 ex_redrawstatus(exarg_T *eap UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7752 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7753 int r = RedrawingDisabled;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7754 int p = p_lz;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7755
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7756 RedrawingDisabled = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7757 p_lz = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7758 if (eap->forceit)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7759 status_redraw_all();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7760 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7761 status_redraw_curbuf();
5735
50dbef5e774a updated for version 7.4.212
Bram Moolenaar <bram@vim.org>
parents: 5720
diff changeset
7762 update_screen(VIsual_active ? INVERTED : 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7763 RedrawingDisabled = r;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7764 p_lz = p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7765 out_flush();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7766 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7767
15396
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 15263
diff changeset
7768 /*
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 15263
diff changeset
7769 * ":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
7770 */
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 15263
diff changeset
7771 static void
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 15263
diff changeset
7772 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
7773 {
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 15263
diff changeset
7774 int r = RedrawingDisabled;
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 15263
diff changeset
7775 int p = p_lz;
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 15263
diff changeset
7776
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 15263
diff changeset
7777 RedrawingDisabled = 0;
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 15263
diff changeset
7778 p_lz = FALSE;
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 15263
diff changeset
7779
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 15263
diff changeset
7780 draw_tabline();
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 15263
diff changeset
7781
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 15263
diff changeset
7782 RedrawingDisabled = r;
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 15263
diff changeset
7783 p_lz = p;
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 15263
diff changeset
7784 out_flush();
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 15263
diff changeset
7785 }
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 15263
diff changeset
7786
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7787 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
7788 close_redir(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7789 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7790 if (redir_fd != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7791 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7792 fclose(redir_fd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7793 redir_fd = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7794 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7795 #ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7796 redir_reg = 0;
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7797 if (redir_vname)
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7798 {
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7799 var_redir_stop();
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7800 redir_vname = 0;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7801 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7802 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7803 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7804
17539
554240b9574b patch 8.1.1767: FEAT_SESSION defined separately
Bram Moolenaar <Bram@vim.org>
parents: 17536
diff changeset
7805 #if (defined(FEAT_SESSION) || defined(FEAT_EVAL)) || defined(PROTO)
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7806 int
18139
59bc3cd42cf5 patch 8.1.2064: MS-Windows: compiler warnings for unused arguments
Bram Moolenaar <Bram@vim.org>
parents: 18135
diff changeset
7807 vim_mkdir_emsg(char_u *name, int prot UNUSED)
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7808 {
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7809 if (vim_mkdir(name, prot) != 0)
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7810 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
7811 semsg(_("E739: Cannot create directory: %s"), name);
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7812 return FAIL;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7813 }
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7814 return OK;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7815 }
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7816 #endif
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7817
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7818 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7819 * Open a file for writing for an Ex command, with some checks.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7820 * Return file descriptor, or NULL on failure.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7821 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7822 FILE *
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
7823 open_exfile(
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
7824 char_u *fname,
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
7825 int forceit,
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7826 char *mode) // "w" for create new file or "a" for append
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7827 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7828 FILE *fd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7829
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7830 #ifdef UNIX
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7831 // with Unix it is possible to open a directory
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7832 if (mch_isdir(fname))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7833 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
7834 semsg(_(e_isadir2), fname);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7835 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7836 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7837 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7838 if (!forceit && *mode != 'a' && vim_fexists(fname))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7839 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
7840 semsg(_("E189: \"%s\" exists (add ! to override)"), fname);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7841 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7842 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7843
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7844 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
7845 semsg(_("E190: Cannot open \"%s\" for writing"), fname);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7846
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7847 return fd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7848 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7849
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7850 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7851 * ":mark" and ":k".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7852 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7853 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
7854 ex_mark(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7855 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7856 pos_T pos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7857
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7858 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
7859 emsg(_(e_argreq));
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7860 else if (eap->arg[1] != NUL) // more than one character?
21461
4dfd00f481fb patch 8.2.1281: the "trailing characters" error can be hard to understand
Bram Moolenaar <Bram@vim.org>
parents: 21459
diff changeset
7861 semsg(_(e_trailing_arg), eap->arg);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7862 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7863 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7864 pos = curwin->w_cursor; // save curwin->w_cursor
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7865 curwin->w_cursor.lnum = eap->line2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7866 beginline(BL_WHITE | BL_FIX);
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7867 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
7868 emsg(_("E191: Argument must be a letter or forward/backward quote"));
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7869 curwin->w_cursor = pos; // restore curwin->w_cursor
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7870 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7871 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7872
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7873 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7874 * Update w_topline, w_leftcol and the cursor position.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7875 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7876 void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
7877 update_topline_cursor(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7878 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7879 check_cursor(); // put cursor on valid line
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7880 update_topline();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7881 if (!curwin->w_p_wrap)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7882 validate_cursor();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7883 update_curswant();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7884 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7885
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7886 /*
12521
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
7887 * 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
7888 * 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
7889 */
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
7890 int
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
7891 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
7892 {
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
7893 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
7894 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
7895 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
7896 sst->save_State = State;
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
7897 sst->save_insertmode = p_im;
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
7898 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
7899 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
7900 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
7901
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7902 msg_scroll = FALSE; // no msg scrolling in Normal mode
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7903 restart_edit = 0; // don't go to Insert mode
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7904 p_im = FALSE; // don't use 'insertmode'
12521
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
7905
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
7906 /*
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
7907 * 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
7908 * 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
7909 * ends with half a command.
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
7910 */
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
7911 save_typeahead(&sst->tabuf);
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
7912 return sst->tabuf.typebuf_valid;
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
7913 }
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
7914
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
7915 void
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
7916 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
7917 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7918 // Restore the previous typeahead.
12521
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
7919 restore_typeahead(&sst->tabuf);
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
7920
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
7921 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
7922 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
7923 p_im = sst->save_insertmode;
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
7924 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
7925 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
7926 reg_executing = sst->save_reg_executing;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7927 msg_didout |= sst->save_msg_didout; // don't reset msg_didout now
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7928
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7929 // Restore the state (needed when called from a function executed for
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7930 // 'indentexpr'). Update the mouse and cursor, they may have changed.
12521
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
7931 State = sst->save_State;
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
7932 #ifdef CURSOR_SHAPE
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7933 ui_cursor_shape(); // may show different cursor shape
12521
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
7934 #endif
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
7935 }
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
7936
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
7937 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7938 * ":normal[!] {commands}": Execute normal mode commands.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7939 */
7840
28f569c7dab9 commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents: 7819
diff changeset
7940 void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
7941 ex_normal(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7942 {
12521
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
7943 save_state_T save_state;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7944 char_u *arg = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7945 int l;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7946 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7947
856
8cd729851562 updated for version 7.0g
vimboss
parents: 844
diff changeset
7948 if (ex_normal_lock > 0)
8cd729851562 updated for version 7.0g
vimboss
parents: 844
diff changeset
7949 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
7950 emsg(_(e_secure));
856
8cd729851562 updated for version 7.0g
vimboss
parents: 844
diff changeset
7951 return;
8cd729851562 updated for version 7.0g
vimboss
parents: 844
diff changeset
7952 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7953 if (ex_normal_busy >= p_mmd)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7954 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
7955 emsg(_("E192: Recursive use of :normal too deep"));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7956 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7957 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7958
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7959 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7960 * vgetc() expects a CSI and K_SPECIAL to have been escaped. Don't do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7961 * this for the K_SPECIAL leading byte, otherwise special keys will not
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7962 * work.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7963 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7964 if (has_mbyte)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7965 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7966 int len = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7967
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7968 // Count the number of characters to be escaped.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7969 for (p = eap->arg; *p != NUL; ++p)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7970 {
15595
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15591
diff changeset
7971 #ifdef FEAT_GUI
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7972 if (*p == CSI) // leadbyte CSI
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7973 len += 2;
15595
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15591
diff changeset
7974 #endif
474
a5fcf36ef512 updated for version 7.0127
vimboss
parents: 461
diff changeset
7975 for (l = (*mb_ptr2len)(p) - 1; l > 0; --l)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7976 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
7977 #ifdef FEAT_GUI
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7978 || *p == CSI
15595
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15591
diff changeset
7979 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7980 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7981 len += 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7982 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7983 if (len > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7984 {
16764
ef00b6bc186b patch 8.1.1384: using "int" for alloc() often results in compiler warnings
Bram Moolenaar <Bram@vim.org>
parents: 16738
diff changeset
7985 arg = alloc(STRLEN(eap->arg) + len + 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7986 if (arg != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7987 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7988 len = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7989 for (p = eap->arg; *p != NUL; ++p)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7990 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7991 arg[len++] = *p;
15595
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15591
diff changeset
7992 #ifdef FEAT_GUI
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7993 if (*p == CSI)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7994 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7995 arg[len++] = KS_EXTRA;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7996 arg[len++] = (int)KE_CSI;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7997 }
15595
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15591
diff changeset
7998 #endif
474
a5fcf36ef512 updated for version 7.0127
vimboss
parents: 461
diff changeset
7999 for (l = (*mb_ptr2len)(p) - 1; l > 0; --l)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8000 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8001 arg[len++] = *++p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8002 if (*p == K_SPECIAL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8003 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8004 arg[len++] = KS_SPECIAL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8005 arg[len++] = KE_FILLER;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8006 }
15595
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15591
diff changeset
8007 #ifdef FEAT_GUI
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8008 else if (*p == CSI)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8009 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8010 arg[len++] = KS_EXTRA;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8011 arg[len++] = (int)KE_CSI;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8012 }
15595
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15591
diff changeset
8013 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8014 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8015 arg[len] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8016 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8017 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8018 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8019 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8020
12521
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
8021 ++ex_normal_busy;
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
8022 if (save_current_state(&save_state))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8023 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8024 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8025 * Repeat the :normal command for each line in the range. When no
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8026 * range given, execute it just once, without positioning the cursor
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8027 * first.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8028 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8029 do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8030 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8031 if (eap->addr_count != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8032 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8033 curwin->w_cursor.lnum = eap->line1++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8034 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
8035 check_cursor_moved(curwin);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8036 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8037
15595
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15591
diff changeset
8038 exec_normal_cmd(arg != NULL
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15591
diff changeset
8039 ? arg
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15591
diff changeset
8040 : eap->arg, eap->forceit ? REMAP_NONE : REMAP_YES, FALSE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8041 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8042 while (eap->addr_count > 0 && eap->line1 <= eap->line2 && !got_int);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8043 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8044
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8045 // Might not return to the main loop when in an event handler.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8046 update_topline_cursor();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8047
12521
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
8048 restore_current_state(&save_state);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8049 --ex_normal_busy;
6322
85d8cde3b432 updated for version 7.4.494
Bram Moolenaar <bram@vim.org>
parents: 6305
diff changeset
8050 setmouse();
85d8cde3b432 updated for version 7.4.494
Bram Moolenaar <bram@vim.org>
parents: 6305
diff changeset
8051 #ifdef CURSOR_SHAPE
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8052 ui_cursor_shape(); // may show different cursor shape
6322
85d8cde3b432 updated for version 7.4.494
Bram Moolenaar <bram@vim.org>
parents: 6305
diff changeset
8053 #endif
85d8cde3b432 updated for version 7.4.494
Bram Moolenaar <bram@vim.org>
parents: 6305
diff changeset
8054
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8055 vim_free(arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8056 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8057
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8058 /*
598
05c67faedc8b updated for version 7.0170
vimboss
parents: 595
diff changeset
8059 * ":startinsert", ":startreplace" and ":startgreplace"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8060 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8061 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8062 ex_startinsert(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8063 {
98
98435a8ddb09 updated for version 7.0038
vimboss
parents: 93
diff changeset
8064 if (eap->forceit)
98435a8ddb09 updated for version 7.0038
vimboss
parents: 93
diff changeset
8065 {
17984
2ea47dee7ddd patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents: 17966
diff changeset
8066 // cursor line can be zero on startup
12545
241fbf588b95 patch 8.0.1151: "vim -c startinsert!" doesn't append
Christian Brabandt <cb@256bit.org>
parents: 12521
diff changeset
8067 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
8068 curwin->w_cursor.lnum = 1;
17984
2ea47dee7ddd patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents: 17966
diff changeset
8069 set_cursor_for_append_to_line();
2ea47dee7ddd patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents: 17966
diff changeset
8070 }
20097
165ec447ca77 patch 8.2.0604: :startinsert in a terminal window used later
Bram Moolenaar <Bram@vim.org>
parents: 20079
diff changeset
8071 #ifdef FEAT_TERMINAL
165ec447ca77 patch 8.2.0604: :startinsert in a terminal window used later
Bram Moolenaar <Bram@vim.org>
parents: 20079
diff changeset
8072 // Ignore this when running in an active terminal.
165ec447ca77 patch 8.2.0604: :startinsert in a terminal window used later
Bram Moolenaar <Bram@vim.org>
parents: 20079
diff changeset
8073 if (term_job_running(curbuf->b_term))
165ec447ca77 patch 8.2.0604: :startinsert in a terminal window used later
Bram Moolenaar <Bram@vim.org>
parents: 20079
diff changeset
8074 return;
165ec447ca77 patch 8.2.0604: :startinsert in a terminal window used later
Bram Moolenaar <Bram@vim.org>
parents: 20079
diff changeset
8075 #endif
17984
2ea47dee7ddd patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents: 17966
diff changeset
8076
2ea47dee7ddd patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents: 17966
diff changeset
8077 // Ignore the command when already in Insert mode. Inserting an
2ea47dee7ddd patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents: 17966
diff changeset
8078 // expression register that invokes a function can do this.
89
e1a8191c6768 updated for version 7.0036
vimboss
parents: 84
diff changeset
8079 if (State & INSERT)
e1a8191c6768 updated for version 7.0036
vimboss
parents: 84
diff changeset
8080 return;
e1a8191c6768 updated for version 7.0036
vimboss
parents: 84
diff changeset
8081
598
05c67faedc8b updated for version 7.0170
vimboss
parents: 595
diff changeset
8082 if (eap->cmdidx == CMD_startinsert)
05c67faedc8b updated for version 7.0170
vimboss
parents: 595
diff changeset
8083 restart_edit = 'a';
05c67faedc8b updated for version 7.0170
vimboss
parents: 595
diff changeset
8084 else if (eap->cmdidx == CMD_startreplace)
05c67faedc8b updated for version 7.0170
vimboss
parents: 595
diff changeset
8085 restart_edit = 'R';
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8086 else
598
05c67faedc8b updated for version 7.0170
vimboss
parents: 595
diff changeset
8087 restart_edit = 'V';
05c67faedc8b updated for version 7.0170
vimboss
parents: 595
diff changeset
8088
05c67faedc8b updated for version 7.0170
vimboss
parents: 595
diff changeset
8089 if (!eap->forceit)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8090 {
14
946da5994c01 updated for version 7.0006
vimboss
parents: 11
diff changeset
8091 if (eap->cmdidx == CMD_startinsert)
946da5994c01 updated for version 7.0006
vimboss
parents: 11
diff changeset
8092 restart_edit = 'i';
17984
2ea47dee7ddd patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents: 17966
diff changeset
8093 curwin->w_curswant = 0; // avoid MAXCOL
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8094 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8095 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8096
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8097 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8098 * ":stopinsert"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8099 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8100 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8101 ex_stopinsert(exarg_T *eap UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8102 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8103 restart_edit = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8104 stop_insert_mode = TRUE;
8817
b7eb7bbd71d0 commit https://github.com/vim/vim/commit/fd773e9e88add7d1ffef890fb9f3a00d613b4326
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
8105 clearmode();
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8106 }
7850
10f17a228661 commit https://github.com/vim/vim/commit/e2c3810c2ae290bbc2cba18eb47cc2d44e4b9797
Christian Brabandt <cb@256bit.org>
parents: 7840
diff changeset
8107
36
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
8108 /*
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
8109 * Execute normal mode command "cmd".
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
8110 * "remap" can be REMAP_NONE or REMAP_YES.
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
8111 */
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
8112 void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8113 exec_normal_cmd(char_u *cmd, int remap, int silent)
36
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
8114 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8115 // Stuff the argument into the typeahead buffer.
7703
39251e981d1f commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents: 7549
diff changeset
8116 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
8117 exec_normal(FALSE, FALSE, FALSE);
7703
39251e981d1f commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents: 7549
diff changeset
8118 }
7850
10f17a228661 commit https://github.com/vim/vim/commit/e2c3810c2ae290bbc2cba18eb47cc2d44e4b9797
Christian Brabandt <cb@256bit.org>
parents: 7840
diff changeset
8119
7703
39251e981d1f commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents: 7549
diff changeset
8120 /*
39251e981d1f commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents: 7549
diff changeset
8121 * 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
8122 * 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
8123 */
39251e981d1f commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents: 7549
diff changeset
8124 void
14871
f20df682c8af patch 8.1.0447: GUI scrollbar test fails with Athena and Motif
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
8125 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
8126 {
36
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
8127 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
8128 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
8129
d3377393e3d9 patch 8.1.1136: decoding of mouse click escape sequence is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
8130 // 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
8131 // is nothing to get, so also check for Ctrl_C.
36
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
8132 clear_oparg(&oa);
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
8133 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
8134 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
8135 || ((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
8136 || (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
8137 && !got_int)
36
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
8138 {
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
8139 update_topline_cursor();
13829
044337cbf854 patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents: 13802
diff changeset
8140 #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
8141 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
8142 && 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
8143 && !VIsual_active)
044337cbf854 patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents: 13802
diff changeset
8144 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8145 // If terminal_loop() returns OK we got a key that is handled
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8146 // in Normal model. With FAIL we first need to position the
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8147 // cursor and the screen needs to be redrawn.
13829
044337cbf854 patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents: 13802
diff changeset
8148 if (terminal_loop(TRUE) == OK)
044337cbf854 patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents: 13802
diff changeset
8149 normal_cmd(&oa, TRUE);
044337cbf854 patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents: 13802
diff changeset
8150 }
044337cbf854 patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents: 13802
diff changeset
8151 else
044337cbf854 patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents: 13802
diff changeset
8152 #endif
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8153 // execute a Normal mode cmd
13829
044337cbf854 patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents: 13802
diff changeset
8154 normal_cmd(&oa, TRUE);
36
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
8155 }
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
8156 }
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
8157
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8158 #ifdef FEAT_FIND_ID
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8159 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8160 ex_checkpath(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8161 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8162 find_pattern_in_path(NULL, 0, 0, FALSE, FALSE, CHECK_PATH, 1L,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8163 eap->forceit ? ACTION_SHOW_ALL : ACTION_SHOW,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8164 (linenr_T)1, (linenr_T)MAXLNUM);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8165 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8166
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
8167 #if defined(FEAT_QUICKFIX)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8168 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8169 * ":psearch"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8170 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8171 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8172 ex_psearch(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8173 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8174 g_do_tagpreview = p_pvh;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8175 ex_findpat(eap);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8176 g_do_tagpreview = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8177 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8178 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8179
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8180 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8181 ex_findpat(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8182 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8183 int whole = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8184 long n;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8185 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8186 int action;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8187
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8188 switch (cmdnames[eap->cmdidx].cmd_name[2])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8189 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8190 case 'e': // ":psearch", ":isearch" and ":dsearch"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8191 if (cmdnames[eap->cmdidx].cmd_name[0] == 'p')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8192 action = ACTION_GOTO;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8193 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8194 action = ACTION_SHOW;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8195 break;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8196 case 'i': // ":ilist" and ":dlist"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8197 action = ACTION_SHOW_ALL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8198 break;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8199 case 'u': // ":ijump" and ":djump"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8200 action = ACTION_GOTO;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8201 break;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8202 default: // ":isplit" and ":dsplit"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8203 action = ACTION_SPLIT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8204 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8205 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8206
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8207 n = 1;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8208 if (vim_isdigit(*eap->arg)) // get count
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8209 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8210 n = getdigits(&eap->arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8211 eap->arg = skipwhite(eap->arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8212 }
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8213 if (*eap->arg == '/') // Match regexp, not just whole words
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8214 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8215 whole = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8216 ++eap->arg;
19892
5feb426d2ea1 patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19685
diff changeset
8217 p = skip_regexp(eap->arg, '/', p_magic);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8218 if (*p)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8219 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8220 *p++ = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8221 p = skipwhite(p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8222
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8223 // Check for trailing illegal characters
20111
f40231487a49 patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20097
diff changeset
8224 if (!ends_excmd2(eap->arg, p))
21459
a422bd80b434 patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents: 21413
diff changeset
8225 eap->errmsg = ex_errmsg(e_trailing_arg, p);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8226 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8227 eap->nextcmd = check_nextcmd(p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8228 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8229 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8230 if (!eap->skip)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8231 find_pattern_in_path(eap->arg, 0, (int)STRLEN(eap->arg),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8232 whole, !eap->forceit,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8233 *eap->cmd == 'd' ? FIND_DEFINE : FIND_ANY,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8234 n, action, eap->line1, eap->line2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8235 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8236 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8237
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
8238
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
8239 #ifdef FEAT_QUICKFIX
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8240 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8241 * ":ptag", ":ptselect", ":ptjump", ":ptnext", etc.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8242 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8243 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8244 ex_ptag(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8245 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8246 g_do_tagpreview = p_pvh; // will be reset to 0 in ex_tag_cmd()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8247 ex_tag_cmd(eap, cmdnames[eap->cmdidx].cmd_name + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8248 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8249
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8250 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8251 * ":pedit"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8252 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8253 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8254 ex_pedit(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8255 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8256 win_T *curwin_save = curwin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8257
19621
0d677257e35d patch 8.2.0367: can use :pedit in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 19575
diff changeset
8258 if (ERROR_IF_ANY_POPUP_WINDOW)
0d677257e35d patch 8.2.0367: can use :pedit in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 19575
diff changeset
8259 return;
0d677257e35d patch 8.2.0367: can use :pedit in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 19575
diff changeset
8260
17746
a4e488a6655c patch 8.1.1870: using :pedit from a help file sets help filetype
Bram Moolenaar <Bram@vim.org>
parents: 17744
diff changeset
8261 // Open the preview window or popup and make it the current window.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8262 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
8263 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
8264
17746
a4e488a6655c patch 8.1.1870: using :pedit from a help file sets help filetype
Bram Moolenaar <Bram@vim.org>
parents: 17744
diff changeset
8265 // Edit the file.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8266 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
8267
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8268 if (curwin != curwin_save && win_valid(curwin_save))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8269 {
17746
a4e488a6655c patch 8.1.1870: using :pedit from a help file sets help filetype
Bram Moolenaar <Bram@vim.org>
parents: 17744
diff changeset
8270 // Return cursor to where we were
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8271 validate_cursor();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8272 redraw_later(VALID);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8273 win_enter(curwin_save, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8274 }
18763
49b78d6465e5 patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents: 18715
diff changeset
8275 # ifdef FEAT_PROP_POPUP
17644
daa1dea1c1b3 patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents: 17622
diff changeset
8276 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
8277 {
daa1dea1c1b3 patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents: 17622
diff changeset
8278 // 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
8279 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
8280 }
daa1dea1c1b3 patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents: 17622
diff changeset
8281 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8282 g_do_tagpreview = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8283 }
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
8284 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8285
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8286 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8287 * ":stag", ":stselect" and ":stjump".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8288 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8289 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8290 ex_stag(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8291 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8292 postponed_split = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8293 postponed_split_flags = cmdmod.split;
1090
9a3b65713280 updated for version 7.0-216
vimboss
parents: 1088
diff changeset
8294 postponed_split_tab = cmdmod.tab;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8295 ex_tag_cmd(eap, cmdnames[eap->cmdidx].cmd_name + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8296 postponed_split_flags = 0;
1090
9a3b65713280 updated for version 7.0-216
vimboss
parents: 1088
diff changeset
8297 postponed_split_tab = 0;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8298 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8299
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8300 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8301 * ":tag", ":tselect", ":tjump", ":tnext", etc.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8302 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8303 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8304 ex_tag(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8305 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8306 ex_tag_cmd(eap, cmdnames[eap->cmdidx].cmd_name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8307 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8308
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8309 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8310 ex_tag_cmd(exarg_T *eap, char_u *name)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8311 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8312 int cmd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8313
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8314 switch (name[1])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8315 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8316 case 'j': cmd = DT_JUMP; // ":tjump"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8317 break;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8318 case 's': cmd = DT_SELECT; // ":tselect"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8319 break;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8320 case 'p': cmd = DT_PREV; // ":tprevious"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8321 break;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8322 case 'N': cmd = DT_PREV; // ":tNext"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8323 break;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8324 case 'n': cmd = DT_NEXT; // ":tnext"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8325 break;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8326 case 'o': cmd = DT_POP; // ":pop"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8327 break;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8328 case 'f': // ":tfirst"
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8329 case 'r': cmd = DT_FIRST; // ":trewind"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8330 break;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8331 case 'l': cmd = DT_LAST; // ":tlast"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8332 break;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8333 default: // ":tag"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8334 #ifdef FEAT_CSCOPE
1603
694e8715dce6 updated for version 7.1-316
vimboss
parents: 1570
diff changeset
8335 if (p_cst && *eap->arg != NUL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8336 {
10373
bd674706408a commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents: 10361
diff changeset
8337 ex_cstag(eap);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8338 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8339 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8340 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8341 cmd = DT_TAG;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8342 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8343 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8344
649
8157079cea85 updated for version 7.0191
vimboss
parents: 635
diff changeset
8345 if (name[0] == 'l')
8157079cea85 updated for version 7.0191
vimboss
parents: 635
diff changeset
8346 {
8157079cea85 updated for version 7.0191
vimboss
parents: 635
diff changeset
8347 #ifndef FEAT_QUICKFIX
8157079cea85 updated for version 7.0191
vimboss
parents: 635
diff changeset
8348 ex_ni(eap);
8157079cea85 updated for version 7.0191
vimboss
parents: 635
diff changeset
8349 return;
8157079cea85 updated for version 7.0191
vimboss
parents: 635
diff changeset
8350 #else
8157079cea85 updated for version 7.0191
vimboss
parents: 635
diff changeset
8351 cmd = DT_LTAG;
8157079cea85 updated for version 7.0191
vimboss
parents: 635
diff changeset
8352 #endif
8157079cea85 updated for version 7.0191
vimboss
parents: 635
diff changeset
8353 }
8157079cea85 updated for version 7.0191
vimboss
parents: 635
diff changeset
8354
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8355 do_tag(eap->arg, cmd, eap->addr_count > 0 ? (int)eap->line2 : 1,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8356 eap->forceit, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8357 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8358
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8359 /*
1661
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
8360 * Check "str" for starting with a special cmdline variable.
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
8361 * If found return one of the SPEC_ values and set "*usedlen" to the length of
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
8362 * the variable. Otherwise return -1 and "*usedlen" is unchanged.
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
8363 */
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
8364 int
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8365 find_cmdline_var(char_u *src, int *usedlen)
1661
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
8366 {
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
8367 int len;
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
8368 int i;
1879
e8eeeff19eae updated for version 7.2-176
vimboss
parents: 1877
diff changeset
8369 static char *(spec_str[]) = {
1661
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
8370 "%",
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
8371 #define SPEC_PERC 0
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
8372 "#",
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
8373 #define SPEC_HASH (SPEC_PERC + 1)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8374 "<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
8375 #define SPEC_CWORD (SPEC_HASH + 1)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8376 "<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
8377 #define SPEC_CCWORD (SPEC_CWORD + 1)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8378 "<cexpr>", // expr under cursor
12421
da55ea30842c patch 8.0.1090: cannot get the text under the cursor like v:beval_text
Christian Brabandt <cb@256bit.org>
parents: 12419
diff changeset
8379 #define SPEC_CEXPR (SPEC_CCWORD + 1)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8380 "<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
8381 #define SPEC_CFILE (SPEC_CEXPR + 1)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8382 "<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
8383 #define SPEC_SFILE (SPEC_CFILE + 1)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8384 "<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
8385 #define SPEC_SLNUM (SPEC_SFILE + 1)
21493
7449921216bc patch 8.2.1297: when a test fails it's often not easy to see where
Bram Moolenaar <Bram@vim.org>
parents: 21487
diff changeset
8386 "<stack>", // call stack
7449921216bc patch 8.2.1297: when a test fails it's often not easy to see where
Bram Moolenaar <Bram@vim.org>
parents: 21487
diff changeset
8387 #define SPEC_STACK (SPEC_SLNUM + 1)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8388 "<afile>", // autocommand file name
21493
7449921216bc patch 8.2.1297: when a test fails it's often not easy to see where
Bram Moolenaar <Bram@vim.org>
parents: 21487
diff changeset
8389 #define SPEC_AFILE (SPEC_STACK + 1)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8390 "<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
8391 #define SPEC_ABUF (SPEC_AFILE + 1)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8392 "<amatch>", // autocommand match name
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13288
diff changeset
8393 #define SPEC_AMATCH (SPEC_ABUF + 1)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8394 "<sflnum>", // script file line number
14700
0a3b9ecf7cb8 patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents: 14677
diff changeset
8395 #define SPEC_SFLNUM (SPEC_AMATCH + 1)
21594
5daca8504c63 patch 8.2.1347: cannot easily get the script ID
Bram Moolenaar <Bram@vim.org>
parents: 21592
diff changeset
8396 "<SID>", // script ID: <SNR>123_
5daca8504c63 patch 8.2.1347: cannot easily get the script ID
Bram Moolenaar <Bram@vim.org>
parents: 21592
diff changeset
8397 #define SPEC_SID (SPEC_SFLNUM + 1)
1661
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
8398 #ifdef FEAT_CLIENTSERVER
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
8399 "<client>"
21594
5daca8504c63 patch 8.2.1347: cannot easily get the script ID
Bram Moolenaar <Bram@vim.org>
parents: 21592
diff changeset
8400 # define SPEC_CLIENT (SPEC_SID + 1)
1661
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
8401 #endif
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
8402 };
1872
f13849167330 updated for version 7.2-169
vimboss
parents: 1868
diff changeset
8403
f13849167330 updated for version 7.2-169
vimboss
parents: 1868
diff changeset
8404 for (i = 0; i < (int)(sizeof(spec_str) / sizeof(char *)); ++i)
1661
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
8405 {
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
8406 len = (int)STRLEN(spec_str[i]);
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
8407 if (STRNCMP(src, spec_str[i], len) == 0)
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
8408 {
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
8409 *usedlen = len;
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
8410 return i;
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
8411 }
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
8412 }
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
8413 return -1;
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
8414 }
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
8415
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
8416 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8417 * Evaluate cmdline variables.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8418 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8419 * change '%' to curbuf->b_ffname
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8420 * '#' to curwin->w_altfile
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8421 * '<cword>' to word under the cursor
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8422 * '<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
8423 * '<cexpr>' to C-expression under the cursor
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8424 * '<cfile>' to path name under the cursor
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8425 * '<sfile>' to sourced file name
22208
a607f02fd17a patch 8.2.1653: expand('<stack>') does not include the final line number
Bram Moolenaar <Bram@vim.org>
parents: 22176
diff changeset
8426 * '<stack>' to call stack
2645
a2271decbce5 updated for version 7.3.065
Bram Moolenaar <bram@vim.org>
parents: 2635
diff changeset
8427 * '<slnum>' to sourced file line number
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8428 * '<afile>' to file name for autocommand
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8429 * '<abuf>' to buffer number for autocommand
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8430 * '<amatch>' to matching name for autocommand
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8431 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8432 * When an error is detected, "errormsg" is set to a non-NULL pointer (may be
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8433 * "" for error without a message) and NULL is returned.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8434 * Returns an allocated string if a valid match was found.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8435 * Returns NULL if no match was found. "usedlen" then still contains the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8436 * number of characters to skip.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8437 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8438 char_u *
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8439 eval_vars(
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8440 char_u *src, // pointer into commandline
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8441 char_u *srcstart, // beginning of valid memory for src
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8442 int *usedlen, // characters after src that are used
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8443 linenr_T *lnump, // line number for :e command, or NULL
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8444 char **errormsg, // pointer to error message
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8445 int *escaped) // return value has escaped white space (can
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8446 // be NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8447 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8448 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8449 char_u *s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8450 char_u *result;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8451 char_u *resultbuf = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8452 int resultlen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8453 buf_T *buf;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8454 int valid = VALID_HEAD + VALID_PATH; // assume valid result
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8455 int spec_idx;
14405
289b850d2cbf patch 8.1.0217: compiler warning for variable set but not used
Christian Brabandt <cb@256bit.org>
parents: 14393
diff changeset
8456 int tilde_file = FALSE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8457 int skip_mod = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8458 char_u strbuf[30];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8459
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8460 *errormsg = NULL;
1098
5a1d8468d1fa updated for version 7.0-224
vimboss
parents: 1090
diff changeset
8461 if (escaped != NULL)
5a1d8468d1fa updated for version 7.0-224
vimboss
parents: 1090
diff changeset
8462 *escaped = FALSE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8463
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8464 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8465 * Check if there is something to do.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8466 */
1661
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
8467 spec_idx = find_cmdline_var(src, usedlen);
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8468 if (spec_idx < 0) // no match
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8469 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8470 *usedlen = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8471 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8472 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8473
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8474 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8475 * Skip when preceded with a backslash "\%" and "\#".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8476 * Note: In "\\%" the % is also not recognized!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8477 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8478 if (src > srcstart && src[-1] == '\\')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8479 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8480 *usedlen = 0;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8481 STRMOVE(src - 1, src); // remove backslash
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8482 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8483 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8484
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8485 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8486 * word or WORD under cursor
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8487 */
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
8488 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
8489 || 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
8490 {
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
8491 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
8492 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
8493 : 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
8494 : FIND_STRING);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8495 if (resultlen == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8496 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
8497 *errormsg = "";
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8498 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8499 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8500 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8501
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8502 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8503 * '#': Alternate file name
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8504 * '%': Current file name
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8505 * File name under the cursor
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8506 * File name for autocommand
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8507 * and following modifiers
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8508 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8509 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8510 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8511 switch (spec_idx)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8512 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8513 case SPEC_PERC: // '%': current file
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8514 if (curbuf->b_fname == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8515 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8516 result = (char_u *)"";
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8517 valid = 0; // Must have ":p:h" to be valid
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8518 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8519 else
14393
c62601adad69 patch 8.1.0211: expanding a file name "~" results in $HOME
Christian Brabandt <cb@256bit.org>
parents: 14286
diff changeset
8520 {
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8521 result = curbuf->b_fname;
14393
c62601adad69 patch 8.1.0211: expanding a file name "~" results in $HOME
Christian Brabandt <cb@256bit.org>
parents: 14286
diff changeset
8522 tilde_file = STRCMP(result, "~") == 0;
c62601adad69 patch 8.1.0211: expanding a file name "~" results in $HOME
Christian Brabandt <cb@256bit.org>
parents: 14286
diff changeset
8523 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8524 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8525
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8526 case SPEC_HASH: // '#' or "#99": alternate file
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8527 if (src[1] == '#') // "##": the argument list
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8528 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8529 result = arg_all();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8530 resultbuf = result;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8531 *usedlen = 2;
1098
5a1d8468d1fa updated for version 7.0-224
vimboss
parents: 1090
diff changeset
8532 if (escaped != NULL)
5a1d8468d1fa updated for version 7.0-224
vimboss
parents: 1090
diff changeset
8533 *escaped = TRUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8534 skip_mod = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8535 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8536 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8537 s = src + 1;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8538 if (*s == '<') // "#<99" uses v:oldfiles
1733
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
8539 ++s;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8540 i = (int)getdigits(&s);
12706
9b882316aa63 patch 8.0.1231: expanding file name drops dash
Christian Brabandt <cb@256bit.org>
parents: 12674
diff changeset
8541 if (s == src + 2 && src[1] == '-')
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8542 // just a minus sign, don't skip over it
12706
9b882316aa63 patch 8.0.1231: expanding file name drops dash
Christian Brabandt <cb@256bit.org>
parents: 12674
diff changeset
8543 s--;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8544 *usedlen = (int)(s - src); // length of what we expand
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8545
12706
9b882316aa63 patch 8.0.1231: expanding file name drops dash
Christian Brabandt <cb@256bit.org>
parents: 12674
diff changeset
8546 if (src[1] == '<' && i != 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8547 {
1733
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
8548 if (*usedlen < 2)
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
8549 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8550 // Should we give an error message for #<text?
1733
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
8551 *usedlen = 1;
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
8552 return NULL;
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
8553 }
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
8554 #ifdef FEAT_EVAL
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
8555 result = list_find_str(get_vim_var_list(VV_OLDFILES),
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
8556 (long)i);
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
8557 if (result == NULL)
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
8558 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
8559 *errormsg = "";
1733
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
8560 return NULL;
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
8561 }
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
8562 #else
15488
da8b98c008bf patch 8.1.0752: one more compiler warning for signed/unsigned string
Bram Moolenaar <Bram@vim.org>
parents: 15474
diff changeset
8563 *errormsg = _("E809: #< is not available without the +eval feature");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8564 return NULL;
1733
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
8565 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8566 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8567 else
1733
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
8568 {
12706
9b882316aa63 patch 8.0.1231: expanding file name drops dash
Christian Brabandt <cb@256bit.org>
parents: 12674
diff changeset
8569 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
8570 *usedlen = 1;
1733
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
8571 buf = buflist_findnr(i);
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
8572 if (buf == NULL)
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
8573 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
8574 *errormsg = _("E194: No alternate file name to substitute for '#'");
1733
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
8575 return NULL;
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
8576 }
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
8577 if (lnump != NULL)
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
8578 *lnump = ECMD_LAST;
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
8579 if (buf->b_fname == NULL)
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
8580 {
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
8581 result = (char_u *)"";
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8582 valid = 0; // Must have ":p:h" to be valid
1733
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
8583 }
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
8584 else
14393
c62601adad69 patch 8.1.0211: expanding a file name "~" results in $HOME
Christian Brabandt <cb@256bit.org>
parents: 14286
diff changeset
8585 {
1733
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
8586 result = buf->b_fname;
14393
c62601adad69 patch 8.1.0211: expanding a file name "~" results in $HOME
Christian Brabandt <cb@256bit.org>
parents: 14286
diff changeset
8587 tilde_file = STRCMP(result, "~") == 0;
c62601adad69 patch 8.1.0211: expanding a file name "~" results in $HOME
Christian Brabandt <cb@256bit.org>
parents: 14286
diff changeset
8588 }
1733
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
8589 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8590 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8591
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8592 #ifdef FEAT_SEARCHPATH
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8593 case SPEC_CFILE: // file name under cursor
681
9364d114ed8d updated for version 7.0204
vimboss
parents: 678
diff changeset
8594 result = file_name_at_cursor(FNAME_MESS|FNAME_HYP, 1L, NULL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8595 if (result == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8596 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
8597 *errormsg = "";
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8598 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8599 }
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8600 resultbuf = result; // remember allocated string
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8601 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8602 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8603
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8604 case SPEC_AFILE: // file name for autocommand
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8605 result = autocmd_fname;
1723
2e42153b37f1 updated for version 7.2-021
vimboss
parents: 1721
diff changeset
8606 if (result != NULL && !autocmd_fname_full)
2e42153b37f1 updated for version 7.2-021
vimboss
parents: 1721
diff changeset
8607 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8608 // Still need to turn the fname into a full path. It is
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8609 // postponed to avoid a delay when <afile> is not used.
1723
2e42153b37f1 updated for version 7.2-021
vimboss
parents: 1721
diff changeset
8610 autocmd_fname_full = TRUE;
2e42153b37f1 updated for version 7.2-021
vimboss
parents: 1721
diff changeset
8611 result = FullName_save(autocmd_fname, FALSE);
2e42153b37f1 updated for version 7.2-021
vimboss
parents: 1721
diff changeset
8612 vim_free(autocmd_fname);
2e42153b37f1 updated for version 7.2-021
vimboss
parents: 1721
diff changeset
8613 autocmd_fname = result;
2e42153b37f1 updated for version 7.2-021
vimboss
parents: 1721
diff changeset
8614 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8615 if (result == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8616 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
8617 *errormsg = _("E495: no autocommand file name to substitute for \"<afile>\"");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8618 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8619 }
1471
e980e93d2ac2 updated for version 7.1-186
vimboss
parents: 1467
diff changeset
8620 result = shorten_fname1(result);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8621 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8622
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8623 case SPEC_ABUF: // buffer number for autocommand
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8624 if (autocmd_bufnr <= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8625 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
8626 *errormsg = _("E496: no autocommand buffer number to substitute for \"<abuf>\"");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8627 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8628 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8629 sprintf((char *)strbuf, "%d", autocmd_bufnr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8630 result = strbuf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8631 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8632
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8633 case SPEC_AMATCH: // match name for autocommand
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8634 result = autocmd_match;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8635 if (result == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8636 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
8637 *errormsg = _("E497: no autocommand match name to substitute for \"<amatch>\"");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8638 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8639 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8640 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8641
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8642 case SPEC_SFILE: // file name for ":so" command
21493
7449921216bc patch 8.2.1297: when a test fails it's often not easy to see where
Bram Moolenaar <Bram@vim.org>
parents: 21487
diff changeset
8643 case SPEC_STACK: // call stack
22208
a607f02fd17a patch 8.2.1653: expand('<stack>') does not include the final line number
Bram Moolenaar <Bram@vim.org>
parents: 22176
diff changeset
8644 result = estack_sfile(spec_idx == SPEC_SFILE
a607f02fd17a patch 8.2.1653: expand('<stack>') does not include the final line number
Bram Moolenaar <Bram@vim.org>
parents: 22176
diff changeset
8645 ? ESTACK_SFILE : ESTACK_STACK);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8646 if (result == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8647 {
21493
7449921216bc patch 8.2.1297: when a test fails it's often not easy to see where
Bram Moolenaar <Bram@vim.org>
parents: 21487
diff changeset
8648 *errormsg = spec_idx == SPEC_SFILE
7449921216bc patch 8.2.1297: when a test fails it's often not easy to see where
Bram Moolenaar <Bram@vim.org>
parents: 21487
diff changeset
8649 ? _("E498: no :source file name to substitute for \"<sfile>\"")
7449921216bc patch 8.2.1297: when a test fails it's often not easy to see where
Bram Moolenaar <Bram@vim.org>
parents: 21487
diff changeset
8650 : _("E489: no call stack to substitute for \"<stack>\"");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8651 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8652 }
18991
847cc7932c42 patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents: 18904
diff changeset
8653 resultbuf = result; // remember allocated string
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8654 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
8655
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8656 case SPEC_SLNUM: // line in file for ":so" command
18991
847cc7932c42 patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents: 18904
diff changeset
8657 if (SOURCING_NAME == NULL || SOURCING_LNUM == 0)
2645
a2271decbce5 updated for version 7.3.065
Bram Moolenaar <bram@vim.org>
parents: 2635
diff changeset
8658 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
8659 *errormsg = _("E842: no line number to use for \"<slnum>\"");
2645
a2271decbce5 updated for version 7.3.065
Bram Moolenaar <bram@vim.org>
parents: 2635
diff changeset
8660 return NULL;
a2271decbce5 updated for version 7.3.065
Bram Moolenaar <bram@vim.org>
parents: 2635
diff changeset
8661 }
18991
847cc7932c42 patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents: 18904
diff changeset
8662 sprintf((char *)strbuf, "%ld", SOURCING_LNUM);
2645
a2271decbce5 updated for version 7.3.065
Bram Moolenaar <bram@vim.org>
parents: 2635
diff changeset
8663 result = strbuf;
a2271decbce5 updated for version 7.3.065
Bram Moolenaar <bram@vim.org>
parents: 2635
diff changeset
8664 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
8665
0a3b9ecf7cb8 patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents: 14677
diff changeset
8666 #ifdef FEAT_EVAL
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8667 case SPEC_SFLNUM: // line in script file
18991
847cc7932c42 patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents: 18904
diff changeset
8668 if (current_sctx.sc_lnum + SOURCING_LNUM == 0)
14700
0a3b9ecf7cb8 patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents: 14677
diff changeset
8669 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
8670 *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
8671 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
8672 }
0a3b9ecf7cb8 patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents: 14677
diff changeset
8673 sprintf((char *)strbuf, "%ld",
18991
847cc7932c42 patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents: 18904
diff changeset
8674 (long)(current_sctx.sc_lnum + SOURCING_LNUM));
14700
0a3b9ecf7cb8 patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents: 14677
diff changeset
8675 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
8676 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
8677
21594
5daca8504c63 patch 8.2.1347: cannot easily get the script ID
Bram Moolenaar <Bram@vim.org>
parents: 21592
diff changeset
8678 case SPEC_SID:
5daca8504c63 patch 8.2.1347: cannot easily get the script ID
Bram Moolenaar <Bram@vim.org>
parents: 21592
diff changeset
8679 if (current_sctx.sc_sid <= 0)
5daca8504c63 patch 8.2.1347: cannot easily get the script ID
Bram Moolenaar <Bram@vim.org>
parents: 21592
diff changeset
8680 {
5daca8504c63 patch 8.2.1347: cannot easily get the script ID
Bram Moolenaar <Bram@vim.org>
parents: 21592
diff changeset
8681 *errormsg = _(e_usingsid);
5daca8504c63 patch 8.2.1347: cannot easily get the script ID
Bram Moolenaar <Bram@vim.org>
parents: 21592
diff changeset
8682 return NULL;
5daca8504c63 patch 8.2.1347: cannot easily get the script ID
Bram Moolenaar <Bram@vim.org>
parents: 21592
diff changeset
8683 }
5daca8504c63 patch 8.2.1347: cannot easily get the script ID
Bram Moolenaar <Bram@vim.org>
parents: 21592
diff changeset
8684 sprintf((char *)strbuf, "<SNR>%d_", current_sctx.sc_sid);
5daca8504c63 patch 8.2.1347: cannot easily get the script ID
Bram Moolenaar <Bram@vim.org>
parents: 21592
diff changeset
8685 result = strbuf;
5daca8504c63 patch 8.2.1347: cannot easily get the script ID
Bram Moolenaar <Bram@vim.org>
parents: 21592
diff changeset
8686 break;
21596
c18d00494b60 patch 8.2.1348: build failure without the eval feature
Bram Moolenaar <Bram@vim.org>
parents: 21594
diff changeset
8687 #endif
21594
5daca8504c63 patch 8.2.1347: cannot easily get the script ID
Bram Moolenaar <Bram@vim.org>
parents: 21592
diff changeset
8688
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
8689 #ifdef FEAT_CLIENTSERVER
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8690 case SPEC_CLIENT: // Source of last submitted input
840
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 838
diff changeset
8691 sprintf((char *)strbuf, PRINTF_HEX_LONG_U,
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 838
diff changeset
8692 (long_u)clientWindow);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8693 result = strbuf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8694 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8695 #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
8696
11428
346168f2a6cb patch 8.0.0598: building with gcc 7.1 yields new warnings
Christian Brabandt <cb@256bit.org>
parents: 11374
diff changeset
8697 default:
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8698 result = (char_u *)""; // avoid gcc warning
11428
346168f2a6cb patch 8.0.0598: building with gcc 7.1 yields new warnings
Christian Brabandt <cb@256bit.org>
parents: 11374
diff changeset
8699 break;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8700 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8701
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8702 resultlen = (int)STRLEN(result); // length of new string
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8703 if (src[*usedlen] == '<') // remove the file name extension
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8704 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8705 ++*usedlen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8706 if ((s = vim_strrchr(result, '.')) != NULL && s >= gettail(result))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8707 resultlen = (int)(s - result);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8708 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8709 else if (!skip_mod)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8710 {
14393
c62601adad69 patch 8.1.0211: expanding a file name "~" results in $HOME
Christian Brabandt <cb@256bit.org>
parents: 14286
diff changeset
8711 valid |= modify_fname(src, tilde_file, usedlen, &result, &resultbuf,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8712 &resultlen);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8713 if (result == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8714 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
8715 *errormsg = "";
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8716 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8717 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8718 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8719 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8720
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8721 if (resultlen == 0 || valid != VALID_HEAD + VALID_PATH)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8722 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8723 if (valid != VALID_HEAD + VALID_PATH)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8724 // 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
8725 *errormsg = _("E499: Empty file name for '%' or '#', only works with \":p:h\"");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8726 else
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
8727 *errormsg = _("E500: Evaluates to an empty string");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8728 result = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8729 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8730 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8731 result = vim_strnsave(result, resultlen);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8732 vim_free(resultbuf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8733 return result;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8734 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8735
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8736 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8737 * Expand the <sfile> string in "arg".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8738 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8739 * Returns an allocated string, or NULL for any error.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8740 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8741 char_u *
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8742 expand_sfile(char_u *arg)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8743 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
8744 char *errormsg;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8745 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8746 char_u *result;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8747 char_u *newres;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8748 char_u *repl;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8749 int srclen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8750 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8751
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8752 result = vim_strsave(arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8753 if (result == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8754 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8755
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8756 for (p = result; *p; )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8757 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8758 if (STRNCMP(p, "<sfile>", 7) != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8759 ++p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8760 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8761 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8762 // replace "<sfile>" with the sourced file name, and do ":" stuff
1098
5a1d8468d1fa updated for version 7.0-224
vimboss
parents: 1090
diff changeset
8763 repl = eval_vars(p, result, &srclen, NULL, &errormsg, NULL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8764 if (errormsg != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8765 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8766 if (*errormsg)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8767 emsg(errormsg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8768 vim_free(result);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8769 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8770 }
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8771 if (repl == NULL) // no match (cannot happen)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8772 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8773 p += srclen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8774 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8775 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8776 len = (int)STRLEN(result) - srclen + (int)STRLEN(repl) + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8777 newres = alloc(len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8778 if (newres == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8779 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8780 vim_free(repl);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8781 vim_free(result);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8782 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8783 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8784 mch_memmove(newres, result, (size_t)(p - result));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8785 STRCPY(newres + (p - result), repl);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8786 len = (int)STRLEN(newres);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8787 STRCAT(newres, p + srclen);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8788 vim_free(repl);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8789 vim_free(result);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8790 result = newres;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8791 p = newres + len; // continue after the match
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8792 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8793 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8794
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8795 return result;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8796 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8797
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8798 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) || defined(PROTO)
272
ddada568db54 updated for version 7.0073
vimboss
parents: 268
diff changeset
8799 /*
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
8800 * Make a dialog message in "buff[DIALOG_MSG_SIZE]".
310
04bf54c587f4 updated for version 7.0082
vimboss
parents: 296
diff changeset
8801 * "format" must contain "%s".
272
ddada568db54 updated for version 7.0073
vimboss
parents: 268
diff changeset
8802 */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8803 void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8804 dialog_msg(char_u *buff, char *format, char_u *fname)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8805 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8806 if (fname == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8807 fname = (char_u *)_("Untitled");
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
8808 vim_snprintf((char *)buff, DIALOG_MSG_SIZE, format, fname);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8809 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8810 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8811
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8812 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8813 * ":behave {mswin,xterm}"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8814 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8815 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8816 ex_behave(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8817 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8818 if (STRCMP(eap->arg, "mswin") == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8819 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8820 set_option_value((char_u *)"selection", 0L, (char_u *)"exclusive", 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8821 set_option_value((char_u *)"selectmode", 0L, (char_u *)"mouse,key", 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8822 set_option_value((char_u *)"mousemodel", 0L, (char_u *)"popup", 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8823 set_option_value((char_u *)"keymodel", 0L,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8824 (char_u *)"startsel,stopsel", 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8825 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8826 else if (STRCMP(eap->arg, "xterm") == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8827 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8828 set_option_value((char_u *)"selection", 0L, (char_u *)"inclusive", 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8829 set_option_value((char_u *)"selectmode", 0L, (char_u *)"", 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8830 set_option_value((char_u *)"mousemodel", 0L, (char_u *)"extend", 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8831 set_option_value((char_u *)"keymodel", 0L, (char_u *)"", 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8832 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8833 else
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
8834 semsg(_(e_invarg2), eap->arg);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8835 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8836
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8837 static int filetype_detect = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8838 static int filetype_plugin = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8839 static int filetype_indent = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8840
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8841 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8842 * ":filetype [plugin] [indent] {on,off,detect}"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8843 * on: Load the filetype.vim file to install autocommands for file types.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8844 * off: Load the ftoff.vim file to remove all autocommands for file types.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8845 * plugin on: load filetype.vim and ftplugin.vim
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8846 * plugin off: load ftplugof.vim
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8847 * indent on: load filetype.vim and indent.vim
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8848 * indent off: load indoff.vim
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8849 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8850 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8851 ex_filetype(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8852 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8853 char_u *arg = eap->arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8854 int plugin = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8855 int indent = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8856
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8857 if (*eap->arg == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8858 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8859 // Print current status.
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
8860 smsg("filetype detection:%s plugin:%s indent:%s",
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8861 filetype_detect ? "ON" : "OFF",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8862 filetype_plugin ? (filetype_detect ? "ON" : "(on)") : "OFF",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8863 filetype_indent ? (filetype_detect ? "ON" : "(on)") : "OFF");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8864 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8865 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8866
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8867 // Accept "plugin" and "indent" in any order.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8868 for (;;)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8869 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8870 if (STRNCMP(arg, "plugin", 6) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8871 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8872 plugin = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8873 arg = skipwhite(arg + 6);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8874 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8875 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8876 if (STRNCMP(arg, "indent", 6) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8877 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8878 indent = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8879 arg = skipwhite(arg + 6);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8880 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8881 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8882 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8883 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8884 if (STRCMP(arg, "on") == 0 || STRCMP(arg, "detect") == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8885 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8886 if (*arg == 'o' || !filetype_detect)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8887 {
8524
2f57bbe870ea commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents: 8402
diff changeset
8888 source_runtime((char_u *)FILETYPE_FILE, DIP_ALL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8889 filetype_detect = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8890 if (plugin)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8891 {
8524
2f57bbe870ea commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents: 8402
diff changeset
8892 source_runtime((char_u *)FTPLUGIN_FILE, DIP_ALL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8893 filetype_plugin = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8894 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8895 if (indent)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8896 {
8524
2f57bbe870ea commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents: 8402
diff changeset
8897 source_runtime((char_u *)INDENT_FILE, DIP_ALL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8898 filetype_indent = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8899 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8900 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8901 if (*arg == 'd')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8902 {
9260
ac8180818504 commit https://github.com/vim/vim/commit/1610d052413e0ed664498853a47acc2d677a22d1
Christian Brabandt <cb@256bit.org>
parents: 9230
diff changeset
8903 (void)do_doautocmd((char_u *)"filetypedetect BufRead", TRUE, NULL);
717
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 715
diff changeset
8904 do_modelines(0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8905 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8906 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8907 else if (STRCMP(arg, "off") == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8908 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8909 if (plugin || indent)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8910 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8911 if (plugin)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8912 {
8524
2f57bbe870ea commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents: 8402
diff changeset
8913 source_runtime((char_u *)FTPLUGOF_FILE, DIP_ALL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8914 filetype_plugin = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8915 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8916 if (indent)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8917 {
8524
2f57bbe870ea commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents: 8402
diff changeset
8918 source_runtime((char_u *)INDOFF_FILE, DIP_ALL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8919 filetype_indent = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8920 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8921 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8922 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8923 {
8524
2f57bbe870ea commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents: 8402
diff changeset
8924 source_runtime((char_u *)FTOFF_FILE, DIP_ALL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8925 filetype_detect = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8926 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8927 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8928 else
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
8929 semsg(_(e_invarg2), arg);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8930 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8931
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8932 /*
11459
561b76ed9d12 patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents: 11428
diff changeset
8933 * ":setfiletype [FALLBACK] {name}"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8934 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8935 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8936 ex_setfiletype(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8937 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8938 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
8939 {
561b76ed9d12 patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents: 11428
diff changeset
8940 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
8941
561b76ed9d12 patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents: 11428
diff changeset
8942 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
8943 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
8944
561b76ed9d12 patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents: 11428
diff changeset
8945 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
8946 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
8947 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
8948 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8949 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8950
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8951 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8952 ex_digraphs(exarg_T *eap UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8953 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8954 #ifdef FEAT_DIGRAPHS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8955 if (*eap->arg != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8956 putdigraph(eap->arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8957 else
15152
1ef429366fd4 patch 8.1.0586: :digraph output is not easy to read
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
8958 listdigraphs(eap->forceit);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8959 #else
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
8960 emsg(_("E196: No digraphs in this version"));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8961 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8962 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8963
13792
0e9b2971d7c3 patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents: 13581
diff changeset
8964 #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
8965 void
0e9b2971d7c3 patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents: 13581
diff changeset
8966 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
8967 {
0e9b2971d7c3 patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents: 13581
diff changeset
8968 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
8969 # 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
8970 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
8971 # endif
0e9b2971d7c3 patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents: 13581
diff changeset
8972 }
0e9b2971d7c3 patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents: 13581
diff changeset
8973
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8974 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8975 * ":nohlsearch"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8976 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8977 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8978 ex_nohlsearch(exarg_T *eap UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8979 {
13792
0e9b2971d7c3 patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents: 13581
diff changeset
8980 set_no_hlsearch(TRUE);
737
59971e227f8c updated for version 7.0222
vimboss
parents: 727
diff changeset
8981 redraw_all_later(SOME_VALID);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8982 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8983 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8984
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8985 #ifdef FEAT_CRYPT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8986 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8987 * ":X": Get crypt key
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8988 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8989 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8990 ex_X(exarg_T *eap UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8991 {
6353
60659773c73b updated for version 7.4.509
Bram Moolenaar <bram@vim.org>
parents: 6322
diff changeset
8992 crypt_check_current_method();
6122
18ac55444b37 updated for version 7.4.399
Bram Moolenaar <bram@vim.org>
parents: 6116
diff changeset
8993 (void)crypt_get_key(TRUE, TRUE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8994 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8995 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8996
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8997 #ifdef FEAT_FOLDING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8998 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8999 ex_fold(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9000 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9001 if (foldManualAllowed(TRUE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9002 foldCreate(eap->line1, eap->line2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9003 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9004
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9005 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
9006 ex_foldopen(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9007 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9008 opFoldRange(eap->line1, eap->line2, eap->cmdidx == CMD_foldopen,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9009 eap->forceit, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9010 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9011
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9012 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
9013 ex_folddo(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9014 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9015 linenr_T lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9016
18297
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
9017 # ifdef FEAT_CLIPBOARD
6116
7766142fc7d3 updated for version 7.4.396
Bram Moolenaar <bram@vim.org>
parents: 5979
diff changeset
9018 start_global_changes();
18297
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
9019 # endif
6116
7766142fc7d3 updated for version 7.4.396
Bram Moolenaar <bram@vim.org>
parents: 5979
diff changeset
9020
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9021 // First set the marks for all lines closed/open.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9022 for (lnum = eap->line1; lnum <= eap->line2; ++lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9023 if (hasFolding(lnum, NULL, NULL) == (eap->cmdidx == CMD_folddoclosed))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9024 ml_setmarked(lnum);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9025
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9026 // Execute the command on the marked lines.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9027 global_exe(eap->arg);
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9028 ml_clearmarked(); // clear rest of the marks
18297
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
9029 # ifdef FEAT_CLIPBOARD
6116
7766142fc7d3 updated for version 7.4.396
Bram Moolenaar <bram@vim.org>
parents: 5979
diff changeset
9030 end_global_changes();
18297
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
9031 # endif
6116
7766142fc7d3 updated for version 7.4.396
Bram Moolenaar <bram@vim.org>
parents: 5979
diff changeset
9032 }
7766142fc7d3 updated for version 7.4.396
Bram Moolenaar <bram@vim.org>
parents: 5979
diff changeset
9033 #endif
12459
937356f8f8d6 patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents: 12457
diff changeset
9034
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
9035 #if defined(FEAT_QUICKFIX) || defined(PROTO)
14550
60b9b6196644 patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents: 14538
diff changeset
9036 /*
60b9b6196644 patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents: 14538
diff changeset
9037 * 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
9038 * 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
9039 */
60b9b6196644 patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents: 14538
diff changeset
9040 int
60b9b6196644 patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents: 14538
diff changeset
9041 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
9042 {
14621
89cc3e7ecb68 patch 8.1.0324: off-by-one error in cmdidx check
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
9043 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
9044 return FALSE;
60b9b6196644 patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents: 14538
diff changeset
9045 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
9046 }
60b9b6196644 patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents: 14538
diff changeset
9047 #endif
60b9b6196644 patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents: 14538
diff changeset
9048
18297
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
9049 #if defined(FEAT_TIMERS) || defined(PROTO)
12459
937356f8f8d6 patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents: 12457
diff changeset
9050 int
937356f8f8d6 patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents: 12457
diff changeset
9051 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
9052 {
937356f8f8d6 patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents: 12457
diff changeset
9053 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
9054 }
937356f8f8d6 patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents: 12457
diff changeset
9055
937356f8f8d6 patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents: 12457
diff changeset
9056 void
937356f8f8d6 patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents: 12457
diff changeset
9057 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
9058 {
937356f8f8d6 patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents: 12457
diff changeset
9059 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
9060 }
937356f8f8d6 patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents: 12457
diff changeset
9061 #endif