Mercurial > vim
annotate src/ex_getln.c @ 25014:a47dea17acba v8.2.3044
patch 8.2.3044: Amiga MorphOS and AROS: process ID is not valid
Commit: https://github.com/vim/vim/commit/3a62b14077c51c739cdc755356882b40c299f1c0
Author: ola.soder@axis.com <ola.soder@axis.com>
Date: Thu Jun 24 18:50:30 2021 +0200
patch 8.2.3044: Amiga MorphOS and AROS: process ID is not valid
Problem: Amiga MorphOS and AROS: process ID is not valid.
Solution: Use FindTask to return something which is unique to all processes.
(Ola S?der, closes #8444)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 24 Jun 2021 19:00:05 +0200 |
parents | ce7a80bd0fd5 |
children | 8f2262c72178 |
rev | line source |
---|---|
10042
4aead6a9b7a9
commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents:
9990
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
7 | 2 * |
3 * VIM - Vi IMproved by Bram Moolenaar | |
4 * | |
5 * Do ":help uganda" in Vim to read copying and usage conditions. | |
6 * Do ":help credits" in Vim to see a list of people who contributed. | |
7 * See README.txt for an overview of the Vim source code. | |
8 */ | |
9 | |
10 /* | |
11 * ex_getln.c: Functions for entering and editing an Ex command line. | |
12 */ | |
13 | |
14 #include "vim.h" | |
15 | |
14548
806e1a2648c6
patch 8.1.0287: MAX is not defined everywhere
Christian Brabandt <cb@256bit.org>
parents:
14546
diff
changeset
|
16 #ifndef MAX |
806e1a2648c6
patch 8.1.0287: MAX is not defined everywhere
Christian Brabandt <cb@256bit.org>
parents:
14546
diff
changeset
|
17 # define MAX(x,y) ((x) > (y) ? (x) : (y)) |
806e1a2648c6
patch 8.1.0287: MAX is not defined everywhere
Christian Brabandt <cb@256bit.org>
parents:
14546
diff
changeset
|
18 #endif |
806e1a2648c6
patch 8.1.0287: MAX is not defined everywhere
Christian Brabandt <cb@256bit.org>
parents:
14546
diff
changeset
|
19 |
22145
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
20 // Return value when handling keys in command-line mode. |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
21 #define CMDLINE_NOT_CHANGED 1 |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
22 #define CMDLINE_CHANGED 2 |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
23 #define GOTO_NORMAL_MODE 3 |
22169
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
24 #define PROCESS_NEXT_KEY 4 |
22145
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
25 |
14854
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
26 // The current cmdline_info. It is initialized in getcmdline() and after that |
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
27 // used by other functions. When invoking getcmdline() recursively it needs |
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
28 // to be saved with save_cmdline() and restored with restore_cmdline(). |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
29 static cmdline_info_T ccline; |
7 | 30 |
31 #ifdef FEAT_EVAL | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
32 static int new_cmdpos; // position set by set_cmdline_pos() |
7 | 33 #endif |
34 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
35 static int extra_char = NUL; // extra character to display when redrawing |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
36 // the command line |
11674
d093e4167733
patch 8.0.0720: unfinished mapping not displayed when running timer
Christian Brabandt <cb@256bit.org>
parents:
11664
diff
changeset
|
37 static int extra_char_shift; |
d093e4167733
patch 8.0.0720: unfinished mapping not displayed when running timer
Christian Brabandt <cb@256bit.org>
parents:
11664
diff
changeset
|
38 |
7 | 39 #ifdef FEAT_RIGHTLEFT |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
40 static int cmd_hkmap = 0; // Hebrew mapping during command line |
7 | 41 #endif |
42 | |
22169
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
43 static char_u *getcmdline_int(int firstc, long count, int indent, int clear_ccline); |
7801
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
7447
diff
changeset
|
44 static int cmdline_charsize(int idx); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
7447
diff
changeset
|
45 static void set_cmdspos(void); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
7447
diff
changeset
|
46 static void set_cmdspos_cursor(void); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
7447
diff
changeset
|
47 static void correct_cmdspos(int idx, int cells); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
7447
diff
changeset
|
48 static void alloc_cmdbuff(int len); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
7447
diff
changeset
|
49 static void draw_cmdline(int start, int len); |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
50 static void save_cmdline(cmdline_info_T *ccp); |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
51 static void restore_cmdline(cmdline_info_T *ccp); |
7801
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
7447
diff
changeset
|
52 static int cmdline_paste(int regname, int literally, int remcr); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
7447
diff
changeset
|
53 static void redrawcmdprompt(void); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
7447
diff
changeset
|
54 static int ccheck_abbr(int); |
23505
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
55 #ifdef FEAT_SEARCH_EXTRA |
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
56 static int empty_pattern_magic(char_u *pat, size_t len, magic_T magic_val); |
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
57 #endif |
7 | 58 |
59 #ifdef FEAT_CMDWIN | |
11321
f57dce6b934b
patch 8.0.0546: swap file exists briefly when opening the command window
Christian Brabandt <cb@256bit.org>
parents:
11285
diff
changeset
|
60 static int open_cmdwin(void); |
18679
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
61 |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
62 static int cedit_key INIT(= -1); // key value of 'cedit' option |
7 | 63 #endif |
64 | |
12656
0a9dacb8826a
patch 8.0.1206: no autocmd for entering or leaving the command line
Christian Brabandt <cb@256bit.org>
parents:
12529
diff
changeset
|
65 |
0a9dacb8826a
patch 8.0.1206: no autocmd for entering or leaving the command line
Christian Brabandt <cb@256bit.org>
parents:
12529
diff
changeset
|
66 static void |
0a9dacb8826a
patch 8.0.1206: no autocmd for entering or leaving the command line
Christian Brabandt <cb@256bit.org>
parents:
12529
diff
changeset
|
67 trigger_cmd_autocmd(int typechar, int evt) |
0a9dacb8826a
patch 8.0.1206: no autocmd for entering or leaving the command line
Christian Brabandt <cb@256bit.org>
parents:
12529
diff
changeset
|
68 { |
0a9dacb8826a
patch 8.0.1206: no autocmd for entering or leaving the command line
Christian Brabandt <cb@256bit.org>
parents:
12529
diff
changeset
|
69 char_u typestr[2]; |
0a9dacb8826a
patch 8.0.1206: no autocmd for entering or leaving the command line
Christian Brabandt <cb@256bit.org>
parents:
12529
diff
changeset
|
70 |
0a9dacb8826a
patch 8.0.1206: no autocmd for entering or leaving the command line
Christian Brabandt <cb@256bit.org>
parents:
12529
diff
changeset
|
71 typestr[0] = typechar; |
0a9dacb8826a
patch 8.0.1206: no autocmd for entering or leaving the command line
Christian Brabandt <cb@256bit.org>
parents:
12529
diff
changeset
|
72 typestr[1] = NUL; |
0a9dacb8826a
patch 8.0.1206: no autocmd for entering or leaving the command line
Christian Brabandt <cb@256bit.org>
parents:
12529
diff
changeset
|
73 apply_autocmds(evt, typestr, typestr, FALSE, curbuf); |
0a9dacb8826a
patch 8.0.1206: no autocmd for entering or leaving the command line
Christian Brabandt <cb@256bit.org>
parents:
12529
diff
changeset
|
74 } |
0a9dacb8826a
patch 8.0.1206: no autocmd for entering or leaving the command line
Christian Brabandt <cb@256bit.org>
parents:
12529
diff
changeset
|
75 |
7 | 76 /* |
12664
42cd1f315e8b
patch 8.0.1210: CTRL-G and CTRL-T are ignored with typeahead
Christian Brabandt <cb@256bit.org>
parents:
12656
diff
changeset
|
77 * Abandon the command line. |
42cd1f315e8b
patch 8.0.1210: CTRL-G and CTRL-T are ignored with typeahead
Christian Brabandt <cb@256bit.org>
parents:
12656
diff
changeset
|
78 */ |
42cd1f315e8b
patch 8.0.1210: CTRL-G and CTRL-T are ignored with typeahead
Christian Brabandt <cb@256bit.org>
parents:
12656
diff
changeset
|
79 static void |
42cd1f315e8b
patch 8.0.1210: CTRL-G and CTRL-T are ignored with typeahead
Christian Brabandt <cb@256bit.org>
parents:
12656
diff
changeset
|
80 abandon_cmdline(void) |
42cd1f315e8b
patch 8.0.1210: CTRL-G and CTRL-T are ignored with typeahead
Christian Brabandt <cb@256bit.org>
parents:
12656
diff
changeset
|
81 { |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13142
diff
changeset
|
82 VIM_CLEAR(ccline.cmdbuff); |
12664
42cd1f315e8b
patch 8.0.1210: CTRL-G and CTRL-T are ignored with typeahead
Christian Brabandt <cb@256bit.org>
parents:
12656
diff
changeset
|
83 if (msg_scrolled == 0) |
42cd1f315e8b
patch 8.0.1210: CTRL-G and CTRL-T are ignored with typeahead
Christian Brabandt <cb@256bit.org>
parents:
12656
diff
changeset
|
84 compute_cmdrow(); |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
85 msg(""); |
12664
42cd1f315e8b
patch 8.0.1210: CTRL-G and CTRL-T are ignored with typeahead
Christian Brabandt <cb@256bit.org>
parents:
12656
diff
changeset
|
86 redraw_cmdline = TRUE; |
42cd1f315e8b
patch 8.0.1210: CTRL-G and CTRL-T are ignored with typeahead
Christian Brabandt <cb@256bit.org>
parents:
12656
diff
changeset
|
87 } |
42cd1f315e8b
patch 8.0.1210: CTRL-G and CTRL-T are ignored with typeahead
Christian Brabandt <cb@256bit.org>
parents:
12656
diff
changeset
|
88 |
13047
669c4f75a69e
patch 8.0.1399: warnings and errors when building tiny version
Christian Brabandt <cb@256bit.org>
parents:
13041
diff
changeset
|
89 #ifdef FEAT_SEARCH_EXTRA |
12664
42cd1f315e8b
patch 8.0.1210: CTRL-G and CTRL-T are ignored with typeahead
Christian Brabandt <cb@256bit.org>
parents:
12656
diff
changeset
|
90 /* |
13035
89e191a2a8a7
patch 8.0.1393: too much highlighting with 'hlsearch' and 'incsearch' set
Christian Brabandt <cb@256bit.org>
parents:
12960
diff
changeset
|
91 * Guess that the pattern matches everything. Only finds specific cases, such |
89e191a2a8a7
patch 8.0.1393: too much highlighting with 'hlsearch' and 'incsearch' set
Christian Brabandt <cb@256bit.org>
parents:
12960
diff
changeset
|
92 * as a trailing \|, which can happen while typing a pattern. |
89e191a2a8a7
patch 8.0.1393: too much highlighting with 'hlsearch' and 'incsearch' set
Christian Brabandt <cb@256bit.org>
parents:
12960
diff
changeset
|
93 */ |
89e191a2a8a7
patch 8.0.1393: too much highlighting with 'hlsearch' and 'incsearch' set
Christian Brabandt <cb@256bit.org>
parents:
12960
diff
changeset
|
94 static int |
23505
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
95 empty_pattern(char_u *p, int delim) |
13035
89e191a2a8a7
patch 8.0.1393: too much highlighting with 'hlsearch' and 'incsearch' set
Christian Brabandt <cb@256bit.org>
parents:
12960
diff
changeset
|
96 { |
23505
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
97 size_t n = STRLEN(p); |
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
98 magic_T magic_val = MAGIC_ON; |
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
99 |
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
100 if (n > 0) |
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
101 (void) skip_regexp_ex(p, delim, magic_isset(), NULL, NULL, &magic_val); |
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
102 else |
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
103 return TRUE; |
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
104 |
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
105 return empty_pattern_magic(p, n, magic_val); |
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
106 } |
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
107 |
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
108 static int |
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
109 empty_pattern_magic(char_u *p, size_t len, magic_T magic_val) |
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
110 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
111 // remove trailing \v and the like |
23505
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
112 while (len >= 2 && p[len - 2] == '\\' |
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
113 && vim_strchr((char_u *)"mMvVcCZ", p[len - 1]) != NULL) |
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
114 len -= 2; |
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
115 |
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
116 // true, if the pattern is empty, or the pattern ends with \| and magic is |
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
117 // set (or it ends with '|' and very magic is set) |
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
118 return len == 0 || (len > 1 |
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
119 && ((p[len - 2] == '\\' |
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
120 && p[len - 1] == '|' && magic_val == MAGIC_ON) |
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
121 || (p[len - 2] != '\\' |
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
122 && p[len - 1] == '|' && magic_val == MAGIC_ALL))); |
13035
89e191a2a8a7
patch 8.0.1393: too much highlighting with 'hlsearch' and 'incsearch' set
Christian Brabandt <cb@256bit.org>
parents:
12960
diff
changeset
|
123 } |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
124 |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
125 // Struct to store the viewstate during 'incsearch' highlighting. |
13794
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
126 typedef struct { |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
127 colnr_T vs_curswant; |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
128 colnr_T vs_leftcol; |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
129 linenr_T vs_topline; |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
130 # ifdef FEAT_DIFF |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
131 int vs_topfill; |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
132 # endif |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
133 linenr_T vs_botline; |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
134 linenr_T vs_empty_rows; |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
135 } viewstate_T; |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
136 |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
137 static void |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
138 save_viewstate(viewstate_T *vs) |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
139 { |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
140 vs->vs_curswant = curwin->w_curswant; |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
141 vs->vs_leftcol = curwin->w_leftcol; |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
142 vs->vs_topline = curwin->w_topline; |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
143 # ifdef FEAT_DIFF |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
144 vs->vs_topfill = curwin->w_topfill; |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
145 # endif |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
146 vs->vs_botline = curwin->w_botline; |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
147 vs->vs_empty_rows = curwin->w_empty_rows; |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
148 } |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
149 |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
150 static void |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
151 restore_viewstate(viewstate_T *vs) |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
152 { |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
153 curwin->w_curswant = vs->vs_curswant; |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
154 curwin->w_leftcol = vs->vs_leftcol; |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
155 curwin->w_topline = vs->vs_topline; |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
156 # ifdef FEAT_DIFF |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
157 curwin->w_topfill = vs->vs_topfill; |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
158 # endif |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
159 curwin->w_botline = vs->vs_botline; |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
160 curwin->w_empty_rows = vs->vs_empty_rows; |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
161 } |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
162 |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
163 // Struct to store the state of 'incsearch' highlighting. |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
164 typedef struct { |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
165 pos_T search_start; // where 'incsearch' starts searching |
18227
7d90fa3e5f8d
patch 8.1.2108: cannot close the cmdline window from CmdWinEnter
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
166 pos_T save_cursor; |
22872
5a7db84713dc
patch 8.2.1983: ml_get error when using <Cmd> to open a terminal
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
167 int winid; // window where this state is valid |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
168 viewstate_T init_viewstate; |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
169 viewstate_T old_viewstate; |
18227
7d90fa3e5f8d
patch 8.1.2108: cannot close the cmdline window from CmdWinEnter
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
170 pos_T match_start; |
7d90fa3e5f8d
patch 8.1.2108: cannot close the cmdline window from CmdWinEnter
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
171 pos_T match_end; |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
172 int did_incsearch; |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
173 int incsearch_postponed; |
23505
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
174 optmagic_T magic_overruled_save; |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
175 } incsearch_state_T; |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
176 |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
177 static void |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
178 init_incsearch_state(incsearch_state_T *is_state) |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
179 { |
22872
5a7db84713dc
patch 8.2.1983: ml_get error when using <Cmd> to open a terminal
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
180 is_state->winid = curwin->w_id; |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
181 is_state->match_start = curwin->w_cursor; |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
182 is_state->did_incsearch = FALSE; |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
183 is_state->incsearch_postponed = FALSE; |
23272
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
23076
diff
changeset
|
184 is_state->magic_overruled_save = magic_overruled; |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
185 CLEAR_POS(&is_state->match_end); |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
186 is_state->save_cursor = curwin->w_cursor; // may be restored later |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
187 is_state->search_start = curwin->w_cursor; |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
188 save_viewstate(&is_state->init_viewstate); |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
189 save_viewstate(&is_state->old_viewstate); |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
190 } |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
191 |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
192 /* |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
193 * First move cursor to end of match, then to the start. This |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
194 * moves the whole match onto the screen when 'nowrap' is set. |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
195 */ |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
196 static void |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
197 set_search_match(pos_T *t) |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
198 { |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
199 t->lnum += search_match_lines; |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
200 t->col = search_match_endcol; |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
201 if (t->lnum > curbuf->b_ml.ml_line_count) |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
202 { |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
203 t->lnum = curbuf->b_ml.ml_line_count; |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
204 coladvance((colnr_T)MAXCOL); |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
205 } |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
206 } |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
207 |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
208 /* |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
209 * Return TRUE when 'incsearch' highlighting is to be done. |
14515
3648e74dd523
patch 8.1.0271: 'incsearch' doesn't work for :s, :g or :v
Christian Brabandt <cb@256bit.org>
parents:
14503
diff
changeset
|
210 * Sets search_first_line and search_last_line to the address range. |
14677
7771a1ff8b99
patch 8.1.0351: 'incsearch' for :/foo/s//<Esc> changes last search pattern
Christian Brabandt <cb@256bit.org>
parents:
14652
diff
changeset
|
211 * May change the last search pattern. |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
212 */ |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
213 static int |
22260
d7c1e3efa88e
patch 8.2.1679: Vim9: ":*" is not recognized as a range
Bram Moolenaar <Bram@vim.org>
parents:
22169
diff
changeset
|
214 do_incsearch_highlighting( |
d7c1e3efa88e
patch 8.2.1679: Vim9: ":*" is not recognized as a range
Bram Moolenaar <Bram@vim.org>
parents:
22169
diff
changeset
|
215 int firstc, |
d7c1e3efa88e
patch 8.2.1679: Vim9: ":*" is not recognized as a range
Bram Moolenaar <Bram@vim.org>
parents:
22169
diff
changeset
|
216 int *search_delim, |
d7c1e3efa88e
patch 8.2.1679: Vim9: ":*" is not recognized as a range
Bram Moolenaar <Bram@vim.org>
parents:
22169
diff
changeset
|
217 incsearch_state_T *is_state, |
d7c1e3efa88e
patch 8.2.1679: Vim9: ":*" is not recognized as a range
Bram Moolenaar <Bram@vim.org>
parents:
22169
diff
changeset
|
218 int *skiplen, |
d7c1e3efa88e
patch 8.2.1679: Vim9: ":*" is not recognized as a range
Bram Moolenaar <Bram@vim.org>
parents:
22169
diff
changeset
|
219 int *patlen) |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
220 { |
14565
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
221 char_u *cmd; |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22260
diff
changeset
|
222 cmdmod_T dummy_cmdmod; |
14565
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
223 char_u *p; |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
224 int delim_optional = FALSE; |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
225 int delim; |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
226 char_u *end; |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
227 char *dummy; |
14565
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
228 exarg_T ea; |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
229 pos_T save_cursor; |
14613
3f9b73cc8adb
patch 8.1.0320: too much 'incsearch' highlight for pat matching everything
Christian Brabandt <cb@256bit.org>
parents:
14565
diff
changeset
|
230 int use_last_pat; |
18693
d7c47e45bcc3
patch 8.1.2338: using Visual mark sith :s gives E20 if not set
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
231 int retval = FALSE; |
23505
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
232 magic_T magic = 0; |
14565
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
233 |
14515
3648e74dd523
patch 8.1.0271: 'incsearch' doesn't work for :s, :g or :v
Christian Brabandt <cb@256bit.org>
parents:
14503
diff
changeset
|
234 *skiplen = 0; |
3648e74dd523
patch 8.1.0271: 'incsearch' doesn't work for :s, :g or :v
Christian Brabandt <cb@256bit.org>
parents:
14503
diff
changeset
|
235 *patlen = ccline.cmdlen; |
3648e74dd523
patch 8.1.0271: 'incsearch' doesn't work for :s, :g or :v
Christian Brabandt <cb@256bit.org>
parents:
14503
diff
changeset
|
236 |
14565
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
237 if (!p_is || cmd_silent) |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
238 return FALSE; |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
239 |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
240 // by default search all lines |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
241 search_first_line = 0; |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
242 search_last_line = MAXLNUM; |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
243 |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
244 if (firstc == '/' || firstc == '?') |
19475
5512aa74cb62
patch 8.2.0295: highlighting for :s wrong when using different separator
Bram Moolenaar <Bram@vim.org>
parents:
18886
diff
changeset
|
245 { |
5512aa74cb62
patch 8.2.0295: highlighting for :s wrong when using different separator
Bram Moolenaar <Bram@vim.org>
parents:
18886
diff
changeset
|
246 *search_delim = firstc; |
14565
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
247 return TRUE; |
19475
5512aa74cb62
patch 8.2.0295: highlighting for :s wrong when using different separator
Bram Moolenaar <Bram@vim.org>
parents:
18886
diff
changeset
|
248 } |
14565
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
249 if (firstc != ':') |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
250 return FALSE; |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
251 |
18693
d7c47e45bcc3
patch 8.1.2338: using Visual mark sith :s gives E20 if not set
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
252 ++emsg_off; |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
253 CLEAR_FIELD(ea); |
14565
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
254 ea.line1 = 1; |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
255 ea.line2 = 1; |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
256 ea.cmd = ccline.cmdbuff; |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
257 ea.addr_type = ADDR_LINES; |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
258 |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22260
diff
changeset
|
259 CLEAR_FIELD(dummy_cmdmod); |
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22260
diff
changeset
|
260 parse_command_modifiers(&ea, &dummy, &dummy_cmdmod, TRUE); |
14565
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
261 |
22260
d7c1e3efa88e
patch 8.2.1679: Vim9: ":*" is not recognized as a range
Bram Moolenaar <Bram@vim.org>
parents:
22169
diff
changeset
|
262 cmd = skip_range(ea.cmd, TRUE, NULL); |
14565
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
263 if (vim_strchr((char_u *)"sgvl", *cmd) == NULL) |
18693
d7c47e45bcc3
patch 8.1.2338: using Visual mark sith :s gives E20 if not set
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
264 goto theend; |
14565
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
265 |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
266 // Skip over "substitute" to find the pattern separator. |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
267 for (p = cmd; ASCII_ISALPHA(*p); ++p) |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
268 ; |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
269 if (*skipwhite(p) == NUL) |
18693
d7c47e45bcc3
patch 8.1.2338: using Visual mark sith :s gives E20 if not set
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
270 goto theend; |
14565
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
271 |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
272 if (STRNCMP(cmd, "substitute", p - cmd) == 0 |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
273 || STRNCMP(cmd, "smagic", p - cmd) == 0 |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
274 || STRNCMP(cmd, "snomagic", MAX(p - cmd, 3)) == 0 |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
275 || STRNCMP(cmd, "vglobal", p - cmd) == 0) |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
276 { |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
277 if (*cmd == 's' && cmd[1] == 'm') |
23505
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
278 magic_overruled = OPTION_MAGIC_ON; |
14565
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
279 else if (*cmd == 's' && cmd[1] == 'n') |
23505
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
280 magic_overruled = OPTION_MAGIC_OFF; |
14565
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
281 } |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
282 else if (STRNCMP(cmd, "sort", MAX(p - cmd, 3)) == 0) |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
283 { |
20164
2dd1ac2c48f4
patch 8.2.0637: incsearch highlighting does not work for ":sort!"
Bram Moolenaar <Bram@vim.org>
parents:
20118
diff
changeset
|
284 // skip over ! and flags |
2dd1ac2c48f4
patch 8.2.0637: incsearch highlighting does not work for ":sort!"
Bram Moolenaar <Bram@vim.org>
parents:
20118
diff
changeset
|
285 if (*p == '!') |
2dd1ac2c48f4
patch 8.2.0637: incsearch highlighting does not work for ":sort!"
Bram Moolenaar <Bram@vim.org>
parents:
20118
diff
changeset
|
286 p = skipwhite(p + 1); |
14565
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
287 while (ASCII_ISALPHA(*(p = skipwhite(p)))) |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
288 ++p; |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
289 if (*p == NUL) |
18693
d7c47e45bcc3
patch 8.1.2338: using Visual mark sith :s gives E20 if not set
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
290 goto theend; |
14565
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
291 } |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
292 else if (STRNCMP(cmd, "vimgrep", MAX(p - cmd, 3)) == 0 |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
293 || STRNCMP(cmd, "vimgrepadd", MAX(p - cmd, 8)) == 0 |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
294 || STRNCMP(cmd, "lvimgrep", MAX(p - cmd, 2)) == 0 |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
295 || STRNCMP(cmd, "lvimgrepadd", MAX(p - cmd, 9)) == 0 |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
296 || STRNCMP(cmd, "global", p - cmd) == 0) |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
297 { |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
298 // skip over "!" |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
299 if (*p == '!') |
14515
3648e74dd523
patch 8.1.0271: 'incsearch' doesn't work for :s, :g or :v
Christian Brabandt <cb@256bit.org>
parents:
14503
diff
changeset
|
300 { |
14565
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
301 p++; |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
302 if (*skipwhite(p) == NUL) |
18693
d7c47e45bcc3
patch 8.1.2338: using Visual mark sith :s gives E20 if not set
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
303 goto theend; |
14515
3648e74dd523
patch 8.1.0271: 'incsearch' doesn't work for :s, :g or :v
Christian Brabandt <cb@256bit.org>
parents:
14503
diff
changeset
|
304 } |
14565
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
305 if (*cmd != 'g') |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
306 delim_optional = TRUE; |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
307 } |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
308 else |
18693
d7c47e45bcc3
patch 8.1.2338: using Visual mark sith :s gives E20 if not set
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
309 goto theend; |
14565
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
310 |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
311 p = skipwhite(p); |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
312 delim = (delim_optional && vim_isIDc(*p)) ? ' ' : *p++; |
19475
5512aa74cb62
patch 8.2.0295: highlighting for :s wrong when using different separator
Bram Moolenaar <Bram@vim.org>
parents:
18886
diff
changeset
|
313 *search_delim = delim; |
23505
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
314 end = skip_regexp_ex(p, delim, magic_isset(), NULL, NULL, &magic); |
14565
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
315 |
14613
3f9b73cc8adb
patch 8.1.0320: too much 'incsearch' highlight for pat matching everything
Christian Brabandt <cb@256bit.org>
parents:
14565
diff
changeset
|
316 use_last_pat = end == p && *end == delim; |
3f9b73cc8adb
patch 8.1.0320: too much 'incsearch' highlight for pat matching everything
Christian Brabandt <cb@256bit.org>
parents:
14565
diff
changeset
|
317 |
3f9b73cc8adb
patch 8.1.0320: too much 'incsearch' highlight for pat matching everything
Christian Brabandt <cb@256bit.org>
parents:
14565
diff
changeset
|
318 if (end == p && !use_last_pat) |
18693
d7c47e45bcc3
patch 8.1.2338: using Visual mark sith :s gives E20 if not set
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
319 goto theend; |
14613
3f9b73cc8adb
patch 8.1.0320: too much 'incsearch' highlight for pat matching everything
Christian Brabandt <cb@256bit.org>
parents:
14565
diff
changeset
|
320 |
3f9b73cc8adb
patch 8.1.0320: too much 'incsearch' highlight for pat matching everything
Christian Brabandt <cb@256bit.org>
parents:
14565
diff
changeset
|
321 // Don't do 'hlsearch' highlighting if the pattern matches everything. |
3f9b73cc8adb
patch 8.1.0320: too much 'incsearch' highlight for pat matching everything
Christian Brabandt <cb@256bit.org>
parents:
14565
diff
changeset
|
322 if (!use_last_pat) |
3f9b73cc8adb
patch 8.1.0320: too much 'incsearch' highlight for pat matching everything
Christian Brabandt <cb@256bit.org>
parents:
14565
diff
changeset
|
323 { |
3f9b73cc8adb
patch 8.1.0320: too much 'incsearch' highlight for pat matching everything
Christian Brabandt <cb@256bit.org>
parents:
14565
diff
changeset
|
324 char c = *end; |
3f9b73cc8adb
patch 8.1.0320: too much 'incsearch' highlight for pat matching everything
Christian Brabandt <cb@256bit.org>
parents:
14565
diff
changeset
|
325 int empty; |
3f9b73cc8adb
patch 8.1.0320: too much 'incsearch' highlight for pat matching everything
Christian Brabandt <cb@256bit.org>
parents:
14565
diff
changeset
|
326 |
3f9b73cc8adb
patch 8.1.0320: too much 'incsearch' highlight for pat matching everything
Christian Brabandt <cb@256bit.org>
parents:
14565
diff
changeset
|
327 *end = NUL; |
23505
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
328 empty = empty_pattern_magic(p, STRLEN(p), magic); |
14613
3f9b73cc8adb
patch 8.1.0320: too much 'incsearch' highlight for pat matching everything
Christian Brabandt <cb@256bit.org>
parents:
14565
diff
changeset
|
329 *end = c; |
3f9b73cc8adb
patch 8.1.0320: too much 'incsearch' highlight for pat matching everything
Christian Brabandt <cb@256bit.org>
parents:
14565
diff
changeset
|
330 if (empty) |
18693
d7c47e45bcc3
patch 8.1.2338: using Visual mark sith :s gives E20 if not set
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
331 goto theend; |
14613
3f9b73cc8adb
patch 8.1.0320: too much 'incsearch' highlight for pat matching everything
Christian Brabandt <cb@256bit.org>
parents:
14565
diff
changeset
|
332 } |
3f9b73cc8adb
patch 8.1.0320: too much 'incsearch' highlight for pat matching everything
Christian Brabandt <cb@256bit.org>
parents:
14565
diff
changeset
|
333 |
14565
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
334 // found a non-empty pattern or // |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
335 *skiplen = (int)(p - ccline.cmdbuff); |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
336 *patlen = (int)(end - p); |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
337 |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
338 // parse the address range |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
339 save_cursor = curwin->w_cursor; |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
340 curwin->w_cursor = is_state->search_start; |
14760
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
341 parse_cmd_address(&ea, &dummy, TRUE); |
14565
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
342 if (ea.addr_count > 0) |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
343 { |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
344 // Allow for reverse match. |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
345 if (ea.line2 < ea.line1) |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
346 { |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
347 search_first_line = ea.line2; |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
348 search_last_line = ea.line1; |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
349 } |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
350 else |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
351 { |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
352 search_first_line = ea.line1; |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
353 search_last_line = ea.line2; |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
354 } |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
355 } |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
356 else if (cmd[0] == 's' && cmd[1] != 'o') |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
357 { |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
358 // :s defaults to the current line |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
359 search_first_line = curwin->w_cursor.lnum; |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
360 search_last_line = curwin->w_cursor.lnum; |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
361 } |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
362 |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
363 curwin->w_cursor = save_cursor; |
18693
d7c47e45bcc3
patch 8.1.2338: using Visual mark sith :s gives E20 if not set
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
364 retval = TRUE; |
d7c47e45bcc3
patch 8.1.2338: using Visual mark sith :s gives E20 if not set
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
365 theend: |
d7c47e45bcc3
patch 8.1.2338: using Visual mark sith :s gives E20 if not set
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
366 --emsg_off; |
d7c47e45bcc3
patch 8.1.2338: using Visual mark sith :s gives E20 if not set
Bram Moolenaar <Bram@vim.org>
parents:
18679
diff
changeset
|
367 return retval; |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
368 } |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
369 |
14528
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
370 static void |
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
371 finish_incsearch_highlighting( |
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
372 int gotesc, |
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
373 incsearch_state_T *is_state, |
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
374 int call_update_screen) |
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
375 { |
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
376 if (is_state->did_incsearch) |
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
377 { |
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
378 is_state->did_incsearch = FALSE; |
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
379 if (gotesc) |
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
380 curwin->w_cursor = is_state->save_cursor; |
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
381 else |
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
382 { |
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
383 if (!EQUAL_POS(is_state->save_cursor, is_state->search_start)) |
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
384 { |
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
385 // put the '" mark at the original position |
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
386 curwin->w_cursor = is_state->save_cursor; |
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
387 setpcmark(); |
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
388 } |
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
389 curwin->w_cursor = is_state->search_start; |
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
390 } |
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
391 restore_viewstate(&is_state->old_viewstate); |
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
392 highlight_match = FALSE; |
14652
f3b183c3d3e2
patch 8.1.0339: wrong highlight when 'incsearch' set and cancelling :s
Christian Brabandt <cb@256bit.org>
parents:
14615
diff
changeset
|
393 |
f3b183c3d3e2
patch 8.1.0339: wrong highlight when 'incsearch' set and cancelling :s
Christian Brabandt <cb@256bit.org>
parents:
14615
diff
changeset
|
394 // by default search all lines |
f3b183c3d3e2
patch 8.1.0339: wrong highlight when 'incsearch' set and cancelling :s
Christian Brabandt <cb@256bit.org>
parents:
14615
diff
changeset
|
395 search_first_line = 0; |
f3b183c3d3e2
patch 8.1.0339: wrong highlight when 'incsearch' set and cancelling :s
Christian Brabandt <cb@256bit.org>
parents:
14615
diff
changeset
|
396 search_last_line = MAXLNUM; |
f3b183c3d3e2
patch 8.1.0339: wrong highlight when 'incsearch' set and cancelling :s
Christian Brabandt <cb@256bit.org>
parents:
14615
diff
changeset
|
397 |
23272
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
23076
diff
changeset
|
398 magic_overruled = is_state->magic_overruled_save; |
14652
f3b183c3d3e2
patch 8.1.0339: wrong highlight when 'incsearch' set and cancelling :s
Christian Brabandt <cb@256bit.org>
parents:
14615
diff
changeset
|
399 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
400 validate_cursor(); // needed for TAB |
14774
5e5f2d824189
patch 8.1.0399: 'hlsearch' highlight remains in other window
Christian Brabandt <cb@256bit.org>
parents:
14760
diff
changeset
|
401 redraw_all_later(SOME_VALID); |
14528
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
402 if (call_update_screen) |
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
403 update_screen(SOME_VALID); |
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
404 } |
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
405 } |
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
406 |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
407 /* |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
408 * Do 'incsearch' highlighting if desired. |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
409 */ |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
410 static void |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
411 may_do_incsearch_highlighting( |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
412 int firstc, |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
413 long count, |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
414 incsearch_state_T *is_state) |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
415 { |
14515
3648e74dd523
patch 8.1.0271: 'incsearch' doesn't work for :s, :g or :v
Christian Brabandt <cb@256bit.org>
parents:
14503
diff
changeset
|
416 int skiplen, patlen; |
14687
2982a54aa304
patch 8.1.0356: using :s with 'incsearch' prevents CTRL-R CTRL-W
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
417 int found; // do_search() result |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
418 pos_T end_pos; |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
419 #ifdef FEAT_RELTIME |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
420 proftime_T tm; |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
421 searchit_arg_T sia; |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
422 #endif |
14528
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
423 int next_char; |
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
424 int use_last_pat; |
17155
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
425 int did_do_incsearch = is_state->did_incsearch; |
19475
5512aa74cb62
patch 8.2.0295: highlighting for :s wrong when using different separator
Bram Moolenaar <Bram@vim.org>
parents:
18886
diff
changeset
|
426 int search_delim; |
14515
3648e74dd523
patch 8.1.0271: 'incsearch' doesn't work for :s, :g or :v
Christian Brabandt <cb@256bit.org>
parents:
14503
diff
changeset
|
427 |
14677
7771a1ff8b99
patch 8.1.0351: 'incsearch' for :/foo/s//<Esc> changes last search pattern
Christian Brabandt <cb@256bit.org>
parents:
14652
diff
changeset
|
428 // Parsing range may already set the last search pattern. |
15083
70aa5caa9f0d
patch 8.1.0552: saved last search pattern may not be restored
Bram Moolenaar <Bram@vim.org>
parents:
15064
diff
changeset
|
429 // NOTE: must call restore_last_search_pattern() before returning! |
14677
7771a1ff8b99
patch 8.1.0351: 'incsearch' for :/foo/s//<Esc> changes last search pattern
Christian Brabandt <cb@256bit.org>
parents:
14652
diff
changeset
|
430 save_last_search_pattern(); |
7771a1ff8b99
patch 8.1.0351: 'incsearch' for :/foo/s//<Esc> changes last search pattern
Christian Brabandt <cb@256bit.org>
parents:
14652
diff
changeset
|
431 |
22061
d6120c97f57c
patch 8.2.1580: wildmenu does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
21883
diff
changeset
|
432 if (!do_incsearch_highlighting(firstc, &search_delim, is_state, |
d6120c97f57c
patch 8.2.1580: wildmenu does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
21883
diff
changeset
|
433 &skiplen, &patlen)) |
14528
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
434 { |
14677
7771a1ff8b99
patch 8.1.0351: 'incsearch' for :/foo/s//<Esc> changes last search pattern
Christian Brabandt <cb@256bit.org>
parents:
14652
diff
changeset
|
435 restore_last_search_pattern(); |
14528
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
436 finish_incsearch_highlighting(FALSE, is_state, TRUE); |
17155
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
437 if (did_do_incsearch && vpeekc() == NUL) |
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
438 // may have skipped a redraw, do it now |
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
439 redrawcmd(); |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
440 return; |
14528
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
441 } |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
442 |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
443 // If there is a character waiting, search and redraw later. |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
444 if (char_avail()) |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
445 { |
14677
7771a1ff8b99
patch 8.1.0351: 'incsearch' for :/foo/s//<Esc> changes last search pattern
Christian Brabandt <cb@256bit.org>
parents:
14652
diff
changeset
|
446 restore_last_search_pattern(); |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
447 is_state->incsearch_postponed = TRUE; |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
448 return; |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
449 } |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
450 is_state->incsearch_postponed = FALSE; |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
451 |
14515
3648e74dd523
patch 8.1.0271: 'incsearch' doesn't work for :s, :g or :v
Christian Brabandt <cb@256bit.org>
parents:
14503
diff
changeset
|
452 if (search_first_line == 0) |
3648e74dd523
patch 8.1.0271: 'incsearch' doesn't work for :s, :g or :v
Christian Brabandt <cb@256bit.org>
parents:
14503
diff
changeset
|
453 // start at the original cursor position |
3648e74dd523
patch 8.1.0271: 'incsearch' doesn't work for :s, :g or :v
Christian Brabandt <cb@256bit.org>
parents:
14503
diff
changeset
|
454 curwin->w_cursor = is_state->search_start; |
14976
676db1b7fc35
patch 8.1.0499: :2vimgrep causes an ml_get error
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
455 else if (search_first_line > curbuf->b_ml.ml_line_count) |
676db1b7fc35
patch 8.1.0499: :2vimgrep causes an ml_get error
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
456 { |
676db1b7fc35
patch 8.1.0499: :2vimgrep causes an ml_get error
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
457 // start after the last line |
676db1b7fc35
patch 8.1.0499: :2vimgrep causes an ml_get error
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
458 curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; |
676db1b7fc35
patch 8.1.0499: :2vimgrep causes an ml_get error
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
459 curwin->w_cursor.col = MAXCOL; |
676db1b7fc35
patch 8.1.0499: :2vimgrep causes an ml_get error
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
460 } |
14515
3648e74dd523
patch 8.1.0271: 'incsearch' doesn't work for :s, :g or :v
Christian Brabandt <cb@256bit.org>
parents:
14503
diff
changeset
|
461 else |
3648e74dd523
patch 8.1.0271: 'incsearch' doesn't work for :s, :g or :v
Christian Brabandt <cb@256bit.org>
parents:
14503
diff
changeset
|
462 { |
3648e74dd523
patch 8.1.0271: 'incsearch' doesn't work for :s, :g or :v
Christian Brabandt <cb@256bit.org>
parents:
14503
diff
changeset
|
463 // start at the first line in the range |
3648e74dd523
patch 8.1.0271: 'incsearch' doesn't work for :s, :g or :v
Christian Brabandt <cb@256bit.org>
parents:
14503
diff
changeset
|
464 curwin->w_cursor.lnum = search_first_line; |
3648e74dd523
patch 8.1.0271: 'incsearch' doesn't work for :s, :g or :v
Christian Brabandt <cb@256bit.org>
parents:
14503
diff
changeset
|
465 curwin->w_cursor.col = 0; |
3648e74dd523
patch 8.1.0271: 'incsearch' doesn't work for :s, :g or :v
Christian Brabandt <cb@256bit.org>
parents:
14503
diff
changeset
|
466 } |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
467 |
14528
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
468 // Use the previous pattern for ":s//". |
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
469 next_char = ccline.cmdbuff[skiplen + patlen]; |
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
470 use_last_pat = patlen == 0 && skiplen > 0 |
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
471 && ccline.cmdbuff[skiplen - 1] == next_char; |
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
472 |
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
473 // If there is no pattern, don't do anything. |
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
474 if (patlen == 0 && !use_last_pat) |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
475 { |
14687
2982a54aa304
patch 8.1.0356: using :s with 'incsearch' prevents CTRL-R CTRL-W
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
476 found = 0; |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
477 set_no_hlsearch(TRUE); // turn off previous highlight |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
478 redraw_all_later(SOME_VALID); |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
479 } |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
480 else |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
481 { |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
482 int search_flags = SEARCH_OPT + SEARCH_NOOF + SEARCH_PEEK; |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
483 |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
484 cursor_off(); // so the user knows we're busy |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
485 out_flush(); |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
486 ++emsg_off; // so it doesn't beep if bad expr |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
487 #ifdef FEAT_RELTIME |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
488 // Set the time limit to half a second. |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
489 profile_setlimit(500L, &tm); |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
490 #endif |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
491 if (!p_hls) |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
492 search_flags += SEARCH_KEEP; |
14524
e36d6e01708c
patch 8.1.0275: 'incsearch' with :s doesn't start at cursor line
Christian Brabandt <cb@256bit.org>
parents:
14522
diff
changeset
|
493 if (search_first_line != 0) |
e36d6e01708c
patch 8.1.0275: 'incsearch' with :s doesn't start at cursor line
Christian Brabandt <cb@256bit.org>
parents:
14522
diff
changeset
|
494 search_flags += SEARCH_START; |
14515
3648e74dd523
patch 8.1.0271: 'incsearch' doesn't work for :s, :g or :v
Christian Brabandt <cb@256bit.org>
parents:
14503
diff
changeset
|
495 ccline.cmdbuff[skiplen + patlen] = NUL; |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
496 #ifdef FEAT_RELTIME |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
497 CLEAR_FIELD(sia); |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
498 sia.sa_tm = &tm; |
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
499 #endif |
19475
5512aa74cb62
patch 8.2.0295: highlighting for :s wrong when using different separator
Bram Moolenaar <Bram@vim.org>
parents:
18886
diff
changeset
|
500 found = do_search(NULL, firstc == ':' ? '/' : firstc, search_delim, |
14515
3648e74dd523
patch 8.1.0271: 'incsearch' doesn't work for :s, :g or :v
Christian Brabandt <cb@256bit.org>
parents:
14503
diff
changeset
|
501 ccline.cmdbuff + skiplen, count, search_flags, |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
502 #ifdef FEAT_RELTIME |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
503 &sia |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
504 #else |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
505 NULL |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
506 #endif |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
507 ); |
14528
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
508 ccline.cmdbuff[skiplen + patlen] = next_char; |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
509 --emsg_off; |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
510 |
14515
3648e74dd523
patch 8.1.0271: 'incsearch' doesn't work for :s, :g or :v
Christian Brabandt <cb@256bit.org>
parents:
14503
diff
changeset
|
511 if (curwin->w_cursor.lnum < search_first_line |
3648e74dd523
patch 8.1.0271: 'incsearch' doesn't work for :s, :g or :v
Christian Brabandt <cb@256bit.org>
parents:
14503
diff
changeset
|
512 || curwin->w_cursor.lnum > search_last_line) |
14542
116a01c73fd8
patch 8.1.0284: 'cursorline' highlighting wrong with 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
513 { |
14515
3648e74dd523
patch 8.1.0271: 'incsearch' doesn't work for :s, :g or :v
Christian Brabandt <cb@256bit.org>
parents:
14503
diff
changeset
|
514 // match outside of address range |
14687
2982a54aa304
patch 8.1.0356: using :s with 'incsearch' prevents CTRL-R CTRL-W
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
515 found = 0; |
14542
116a01c73fd8
patch 8.1.0284: 'cursorline' highlighting wrong with 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
516 curwin->w_cursor = is_state->search_start; |
116a01c73fd8
patch 8.1.0284: 'cursorline' highlighting wrong with 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
517 } |
14515
3648e74dd523
patch 8.1.0271: 'incsearch' doesn't work for :s, :g or :v
Christian Brabandt <cb@256bit.org>
parents:
14503
diff
changeset
|
518 |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
519 // if interrupted while searching, behave like it failed |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
520 if (got_int) |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
521 { |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
522 (void)vpeekc(); // remove <C-C> from input stream |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
523 got_int = FALSE; // don't abandon the command line |
14687
2982a54aa304
patch 8.1.0356: using :s with 'incsearch' prevents CTRL-R CTRL-W
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
524 found = 0; |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
525 } |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
526 else if (char_avail()) |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
527 // cancelled searching because a char was typed |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
528 is_state->incsearch_postponed = TRUE; |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
529 } |
14687
2982a54aa304
patch 8.1.0356: using :s with 'incsearch' prevents CTRL-R CTRL-W
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
530 if (found != 0) |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
531 highlight_match = TRUE; // highlight position |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
532 else |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
533 highlight_match = FALSE; // remove highlight |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
534 |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
535 // First restore the old curwin values, so the screen is positioned in the |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
536 // same way as the actual search command. |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
537 restore_viewstate(&is_state->old_viewstate); |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
538 changed_cline_bef_curs(); |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
539 update_topline(); |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
540 |
14687
2982a54aa304
patch 8.1.0356: using :s with 'incsearch' prevents CTRL-R CTRL-W
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
541 if (found != 0) |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
542 { |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
543 pos_T save_pos = curwin->w_cursor; |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
544 |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
545 is_state->match_start = curwin->w_cursor; |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
546 set_search_match(&curwin->w_cursor); |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
547 validate_cursor(); |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
548 end_pos = curwin->w_cursor; |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
549 is_state->match_end = end_pos; |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
550 curwin->w_cursor = save_pos; |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
551 } |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
552 else |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
553 end_pos = curwin->w_cursor; // shutup gcc 4 |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
554 |
14615
c6b41d47bac1
patch 8.1.0321: 'incsearch' regression: / highlights everything
Christian Brabandt <cb@256bit.org>
parents:
14613
diff
changeset
|
555 // Disable 'hlsearch' highlighting if the pattern matches everything. |
c6b41d47bac1
patch 8.1.0321: 'incsearch' regression: / highlights everything
Christian Brabandt <cb@256bit.org>
parents:
14613
diff
changeset
|
556 // Avoids a flash when typing "foo\|". |
c6b41d47bac1
patch 8.1.0321: 'incsearch' regression: / highlights everything
Christian Brabandt <cb@256bit.org>
parents:
14613
diff
changeset
|
557 if (!use_last_pat) |
c6b41d47bac1
patch 8.1.0321: 'incsearch' regression: / highlights everything
Christian Brabandt <cb@256bit.org>
parents:
14613
diff
changeset
|
558 { |
c6b41d47bac1
patch 8.1.0321: 'incsearch' regression: / highlights everything
Christian Brabandt <cb@256bit.org>
parents:
14613
diff
changeset
|
559 next_char = ccline.cmdbuff[skiplen + patlen]; |
c6b41d47bac1
patch 8.1.0321: 'incsearch' regression: / highlights everything
Christian Brabandt <cb@256bit.org>
parents:
14613
diff
changeset
|
560 ccline.cmdbuff[skiplen + patlen] = NUL; |
23505
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
561 if (empty_pattern(ccline.cmdbuff + skiplen, search_delim) |
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
562 && !no_hlsearch) |
14774
5e5f2d824189
patch 8.1.0399: 'hlsearch' highlight remains in other window
Christian Brabandt <cb@256bit.org>
parents:
14760
diff
changeset
|
563 { |
5e5f2d824189
patch 8.1.0399: 'hlsearch' highlight remains in other window
Christian Brabandt <cb@256bit.org>
parents:
14760
diff
changeset
|
564 redraw_all_later(SOME_VALID); |
14615
c6b41d47bac1
patch 8.1.0321: 'incsearch' regression: / highlights everything
Christian Brabandt <cb@256bit.org>
parents:
14613
diff
changeset
|
565 set_no_hlsearch(TRUE); |
14774
5e5f2d824189
patch 8.1.0399: 'hlsearch' highlight remains in other window
Christian Brabandt <cb@256bit.org>
parents:
14760
diff
changeset
|
566 } |
14615
c6b41d47bac1
patch 8.1.0321: 'incsearch' regression: / highlights everything
Christian Brabandt <cb@256bit.org>
parents:
14613
diff
changeset
|
567 ccline.cmdbuff[skiplen + patlen] = next_char; |
c6b41d47bac1
patch 8.1.0321: 'incsearch' regression: / highlights everything
Christian Brabandt <cb@256bit.org>
parents:
14613
diff
changeset
|
568 } |
c6b41d47bac1
patch 8.1.0321: 'incsearch' regression: / highlights everything
Christian Brabandt <cb@256bit.org>
parents:
14613
diff
changeset
|
569 |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
570 validate_cursor(); |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
571 // May redraw the status line to show the cursor position. |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
572 if (p_ru && curwin->w_status_height > 0) |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
573 curwin->w_redr_status = TRUE; |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
574 |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
575 update_screen(SOME_VALID); |
18457
71199e360948
patch 8.1.2222: accessing invalid memory
Bram Moolenaar <Bram@vim.org>
parents:
18358
diff
changeset
|
576 highlight_match = FALSE; |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
577 restore_last_search_pattern(); |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
578 |
14687
2982a54aa304
patch 8.1.0356: using :s with 'incsearch' prevents CTRL-R CTRL-W
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
579 // Leave it at the end to make CTRL-R CTRL-W work. But not when beyond the |
2982a54aa304
patch 8.1.0356: using :s with 'incsearch' prevents CTRL-R CTRL-W
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
580 // end of the pattern, e.g. for ":s/pat/". |
2982a54aa304
patch 8.1.0356: using :s with 'incsearch' prevents CTRL-R CTRL-W
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
581 if (ccline.cmdbuff[skiplen + patlen] != NUL) |
2982a54aa304
patch 8.1.0356: using :s with 'incsearch' prevents CTRL-R CTRL-W
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
582 curwin->w_cursor = is_state->search_start; |
2982a54aa304
patch 8.1.0356: using :s with 'incsearch' prevents CTRL-R CTRL-W
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
583 else if (found != 0) |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
584 curwin->w_cursor = end_pos; |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
585 |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
586 msg_starthere(); |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
587 redrawcmdline(); |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
588 is_state->did_incsearch = TRUE; |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
589 } |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
590 |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
591 /* |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
592 * May adjust 'incsearch' highlighting for typing CTRL-G and CTRL-T, go to next |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
593 * or previous match. |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
594 * Returns FAIL when jumping to cmdline_not_changed; |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
595 */ |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
596 static int |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
597 may_adjust_incsearch_highlighting( |
14515
3648e74dd523
patch 8.1.0271: 'incsearch' doesn't work for :s, :g or :v
Christian Brabandt <cb@256bit.org>
parents:
14503
diff
changeset
|
598 int firstc, |
3648e74dd523
patch 8.1.0271: 'incsearch' doesn't work for :s, :g or :v
Christian Brabandt <cb@256bit.org>
parents:
14503
diff
changeset
|
599 long count, |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
600 incsearch_state_T *is_state, |
14515
3648e74dd523
patch 8.1.0271: 'incsearch' doesn't work for :s, :g or :v
Christian Brabandt <cb@256bit.org>
parents:
14503
diff
changeset
|
601 int c) |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
602 { |
14515
3648e74dd523
patch 8.1.0271: 'incsearch' doesn't work for :s, :g or :v
Christian Brabandt <cb@256bit.org>
parents:
14503
diff
changeset
|
603 int skiplen, patlen; |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
604 pos_T t; |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
605 char_u *pat; |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
606 int search_flags = SEARCH_NOOF; |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
607 int i; |
14515
3648e74dd523
patch 8.1.0271: 'incsearch' doesn't work for :s, :g or :v
Christian Brabandt <cb@256bit.org>
parents:
14503
diff
changeset
|
608 int save; |
19475
5512aa74cb62
patch 8.2.0295: highlighting for :s wrong when using different separator
Bram Moolenaar <Bram@vim.org>
parents:
18886
diff
changeset
|
609 int search_delim; |
14515
3648e74dd523
patch 8.1.0271: 'incsearch' doesn't work for :s, :g or :v
Christian Brabandt <cb@256bit.org>
parents:
14503
diff
changeset
|
610 |
14677
7771a1ff8b99
patch 8.1.0351: 'incsearch' for :/foo/s//<Esc> changes last search pattern
Christian Brabandt <cb@256bit.org>
parents:
14652
diff
changeset
|
611 // Parsing range may already set the last search pattern. |
15083
70aa5caa9f0d
patch 8.1.0552: saved last search pattern may not be restored
Bram Moolenaar <Bram@vim.org>
parents:
15064
diff
changeset
|
612 // NOTE: must call restore_last_search_pattern() before returning! |
14677
7771a1ff8b99
patch 8.1.0351: 'incsearch' for :/foo/s//<Esc> changes last search pattern
Christian Brabandt <cb@256bit.org>
parents:
14652
diff
changeset
|
613 save_last_search_pattern(); |
7771a1ff8b99
patch 8.1.0351: 'incsearch' for :/foo/s//<Esc> changes last search pattern
Christian Brabandt <cb@256bit.org>
parents:
14652
diff
changeset
|
614 |
19475
5512aa74cb62
patch 8.2.0295: highlighting for :s wrong when using different separator
Bram Moolenaar <Bram@vim.org>
parents:
18886
diff
changeset
|
615 if (!do_incsearch_highlighting(firstc, &search_delim, is_state, &skiplen, &patlen)) |
14677
7771a1ff8b99
patch 8.1.0351: 'incsearch' for :/foo/s//<Esc> changes last search pattern
Christian Brabandt <cb@256bit.org>
parents:
14652
diff
changeset
|
616 { |
7771a1ff8b99
patch 8.1.0351: 'incsearch' for :/foo/s//<Esc> changes last search pattern
Christian Brabandt <cb@256bit.org>
parents:
14652
diff
changeset
|
617 restore_last_search_pattern(); |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
618 return OK; |
14677
7771a1ff8b99
patch 8.1.0351: 'incsearch' for :/foo/s//<Esc> changes last search pattern
Christian Brabandt <cb@256bit.org>
parents:
14652
diff
changeset
|
619 } |
14515
3648e74dd523
patch 8.1.0271: 'incsearch' doesn't work for :s, :g or :v
Christian Brabandt <cb@256bit.org>
parents:
14503
diff
changeset
|
620 if (patlen == 0 && ccline.cmdbuff[skiplen] == NUL) |
14677
7771a1ff8b99
patch 8.1.0351: 'incsearch' for :/foo/s//<Esc> changes last search pattern
Christian Brabandt <cb@256bit.org>
parents:
14652
diff
changeset
|
621 { |
7771a1ff8b99
patch 8.1.0351: 'incsearch' for :/foo/s//<Esc> changes last search pattern
Christian Brabandt <cb@256bit.org>
parents:
14652
diff
changeset
|
622 restore_last_search_pattern(); |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
623 return FAIL; |
14677
7771a1ff8b99
patch 8.1.0351: 'incsearch' for :/foo/s//<Esc> changes last search pattern
Christian Brabandt <cb@256bit.org>
parents:
14652
diff
changeset
|
624 } |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
625 |
19475
5512aa74cb62
patch 8.2.0295: highlighting for :s wrong when using different separator
Bram Moolenaar <Bram@vim.org>
parents:
18886
diff
changeset
|
626 if (search_delim == ccline.cmdbuff[skiplen]) |
14520
20866abc790b
patch 8.1.0273: invalid memory access when using 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
14515
diff
changeset
|
627 { |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
628 pat = last_search_pattern(); |
14520
20866abc790b
patch 8.1.0273: invalid memory access when using 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
14515
diff
changeset
|
629 skiplen = 0; |
14544
2b2d7ae42fb8
patch 8.1.0285: compiler warning for conversion
Christian Brabandt <cb@256bit.org>
parents:
14542
diff
changeset
|
630 patlen = (int)STRLEN(pat); |
14520
20866abc790b
patch 8.1.0273: invalid memory access when using 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
14515
diff
changeset
|
631 } |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
632 else |
14515
3648e74dd523
patch 8.1.0271: 'incsearch' doesn't work for :s, :g or :v
Christian Brabandt <cb@256bit.org>
parents:
14503
diff
changeset
|
633 pat = ccline.cmdbuff + skiplen; |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
634 |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
635 cursor_off(); |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
636 out_flush(); |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
637 if (c == Ctrl_G) |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
638 { |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
639 t = is_state->match_end; |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
640 if (LT_POS(is_state->match_start, is_state->match_end)) |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
641 // Start searching at the end of the match not at the beginning of |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
642 // the next column. |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
643 (void)decl(&t); |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
644 search_flags += SEARCH_COL; |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
645 } |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
646 else |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
647 t = is_state->match_start; |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
648 if (!p_hls) |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
649 search_flags += SEARCH_KEEP; |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
650 ++emsg_off; |
14515
3648e74dd523
patch 8.1.0271: 'incsearch' doesn't work for :s, :g or :v
Christian Brabandt <cb@256bit.org>
parents:
14503
diff
changeset
|
651 save = pat[patlen]; |
3648e74dd523
patch 8.1.0271: 'incsearch' doesn't work for :s, :g or :v
Christian Brabandt <cb@256bit.org>
parents:
14503
diff
changeset
|
652 pat[patlen] = NUL; |
15239
db5d2429bda3
patch 8.1.0629: "gn" selects the wrong text with a multi-line match
Bram Moolenaar <Bram@vim.org>
parents:
15138
diff
changeset
|
653 i = searchit(curwin, curbuf, &t, NULL, |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
654 c == Ctrl_G ? FORWARD : BACKWARD, |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
655 pat, count, search_flags, RE_SEARCH, NULL); |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
656 --emsg_off; |
14515
3648e74dd523
patch 8.1.0271: 'incsearch' doesn't work for :s, :g or :v
Christian Brabandt <cb@256bit.org>
parents:
14503
diff
changeset
|
657 pat[patlen] = save; |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
658 if (i) |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
659 { |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
660 is_state->search_start = is_state->match_start; |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
661 is_state->match_end = t; |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
662 is_state->match_start = t; |
14515
3648e74dd523
patch 8.1.0271: 'incsearch' doesn't work for :s, :g or :v
Christian Brabandt <cb@256bit.org>
parents:
14503
diff
changeset
|
663 if (c == Ctrl_T && firstc != '?') |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
664 { |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
665 // Move just before the current match, so that when nv_search |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
666 // finishes the cursor will be put back on the match. |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
667 is_state->search_start = t; |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
668 (void)decl(&is_state->search_start); |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
669 } |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
670 else if (c == Ctrl_G && firstc == '?') |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
671 { |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
672 // Move just after the current match, so that when nv_search |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
673 // finishes the cursor will be put back on the match. |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
674 is_state->search_start = t; |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
675 (void)incl(&is_state->search_start); |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
676 } |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
677 if (LT_POS(t, is_state->search_start) && c == Ctrl_G) |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
678 { |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
679 // wrap around |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
680 is_state->search_start = t; |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
681 if (firstc == '?') |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
682 (void)incl(&is_state->search_start); |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
683 else |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
684 (void)decl(&is_state->search_start); |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
685 } |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
686 |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
687 set_search_match(&is_state->match_end); |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
688 curwin->w_cursor = is_state->match_start; |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
689 changed_cline_bef_curs(); |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
690 update_topline(); |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
691 validate_cursor(); |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
692 highlight_match = TRUE; |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
693 save_viewstate(&is_state->old_viewstate); |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
694 update_screen(NOT_VALID); |
18457
71199e360948
patch 8.1.2222: accessing invalid memory
Bram Moolenaar <Bram@vim.org>
parents:
18358
diff
changeset
|
695 highlight_match = FALSE; |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
696 redrawcmdline(); |
17411
9c4ddc78df74
patch 8.1.1704: C-R C-W does not work after C-G when using 'incsearch'
Bram Moolenaar <Bram@vim.org>
parents:
17336
diff
changeset
|
697 curwin->w_cursor = is_state->match_end; |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
698 } |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
699 else |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
700 vim_beep(BO_ERROR); |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
701 restore_last_search_pattern(); |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
702 return FAIL; |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
703 } |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
704 |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
705 /* |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
706 * When CTRL-L typed: add character from the match to the pattern. |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
707 * May set "*c" to the added character. |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
708 * Return OK when jumping to cmdline_not_changed. |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
709 */ |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
710 static int |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
711 may_add_char_to_search(int firstc, int *c, incsearch_state_T *is_state) |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
712 { |
19475
5512aa74cb62
patch 8.2.0295: highlighting for :s wrong when using different separator
Bram Moolenaar <Bram@vim.org>
parents:
18886
diff
changeset
|
713 int skiplen, patlen, search_delim; |
14515
3648e74dd523
patch 8.1.0271: 'incsearch' doesn't work for :s, :g or :v
Christian Brabandt <cb@256bit.org>
parents:
14503
diff
changeset
|
714 |
14677
7771a1ff8b99
patch 8.1.0351: 'incsearch' for :/foo/s//<Esc> changes last search pattern
Christian Brabandt <cb@256bit.org>
parents:
14652
diff
changeset
|
715 // Parsing range may already set the last search pattern. |
15083
70aa5caa9f0d
patch 8.1.0552: saved last search pattern may not be restored
Bram Moolenaar <Bram@vim.org>
parents:
15064
diff
changeset
|
716 // NOTE: must call restore_last_search_pattern() before returning! |
14677
7771a1ff8b99
patch 8.1.0351: 'incsearch' for :/foo/s//<Esc> changes last search pattern
Christian Brabandt <cb@256bit.org>
parents:
14652
diff
changeset
|
717 save_last_search_pattern(); |
7771a1ff8b99
patch 8.1.0351: 'incsearch' for :/foo/s//<Esc> changes last search pattern
Christian Brabandt <cb@256bit.org>
parents:
14652
diff
changeset
|
718 |
20717
abebcc20af26
patch 8.2.0911: crash when opening a buffer for the cmdline window fails
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
719 if (!do_incsearch_highlighting(firstc, &search_delim, is_state, |
abebcc20af26
patch 8.2.0911: crash when opening a buffer for the cmdline window fails
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
720 &skiplen, &patlen)) |
14677
7771a1ff8b99
patch 8.1.0351: 'incsearch' for :/foo/s//<Esc> changes last search pattern
Christian Brabandt <cb@256bit.org>
parents:
14652
diff
changeset
|
721 { |
7771a1ff8b99
patch 8.1.0351: 'incsearch' for :/foo/s//<Esc> changes last search pattern
Christian Brabandt <cb@256bit.org>
parents:
14652
diff
changeset
|
722 restore_last_search_pattern(); |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
723 return FAIL; |
14677
7771a1ff8b99
patch 8.1.0351: 'incsearch' for :/foo/s//<Esc> changes last search pattern
Christian Brabandt <cb@256bit.org>
parents:
14652
diff
changeset
|
724 } |
15083
70aa5caa9f0d
patch 8.1.0552: saved last search pattern may not be restored
Bram Moolenaar <Bram@vim.org>
parents:
15064
diff
changeset
|
725 restore_last_search_pattern(); |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
726 |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
727 // Add a character from under the cursor for 'incsearch'. |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
728 if (is_state->did_incsearch) |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
729 { |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
730 curwin->w_cursor = is_state->match_end; |
16287
a6cffc232b9d
patch 8.1.1148: CTRL-L with 'incsearch' does not pick up char under cursor
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
731 *c = gchar_cursor(); |
a6cffc232b9d
patch 8.1.1148: CTRL-L with 'incsearch' does not pick up char under cursor
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
732 if (*c != NUL) |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
733 { |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
734 // If 'ignorecase' and 'smartcase' are set and the |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
735 // command line has no uppercase characters, convert |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
736 // the character to lowercase. |
14515
3648e74dd523
patch 8.1.0271: 'incsearch' doesn't work for :s, :g or :v
Christian Brabandt <cb@256bit.org>
parents:
14503
diff
changeset
|
737 if (p_ic && p_scs && !pat_has_uppercase(ccline.cmdbuff + skiplen)) |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
738 *c = MB_TOLOWER(*c); |
19475
5512aa74cb62
patch 8.2.0295: highlighting for :s wrong when using different separator
Bram Moolenaar <Bram@vim.org>
parents:
18886
diff
changeset
|
739 if (*c == search_delim || vim_strchr((char_u *)( |
23272
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
23076
diff
changeset
|
740 magic_isset() ? "\\~^$.*[" : "\\^$"), *c) != NULL) |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
741 { |
16287
a6cffc232b9d
patch 8.1.1148: CTRL-L with 'incsearch' does not pick up char under cursor
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
742 // put a backslash before special characters |
a6cffc232b9d
patch 8.1.1148: CTRL-L with 'incsearch' does not pick up char under cursor
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
743 stuffcharReadbuff(*c); |
a6cffc232b9d
patch 8.1.1148: CTRL-L with 'incsearch' does not pick up char under cursor
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
744 *c = '\\'; |
a6cffc232b9d
patch 8.1.1148: CTRL-L with 'incsearch' does not pick up char under cursor
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
745 } |
a6cffc232b9d
patch 8.1.1148: CTRL-L with 'incsearch' does not pick up char under cursor
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
746 // add any composing characters |
a6cffc232b9d
patch 8.1.1148: CTRL-L with 'incsearch' does not pick up char under cursor
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
747 if (mb_char2len(*c) != mb_ptr2len(ml_get_cursor())) |
a6cffc232b9d
patch 8.1.1148: CTRL-L with 'incsearch' does not pick up char under cursor
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
748 { |
a6cffc232b9d
patch 8.1.1148: CTRL-L with 'incsearch' does not pick up char under cursor
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
749 int save_c = *c; |
a6cffc232b9d
patch 8.1.1148: CTRL-L with 'incsearch' does not pick up char under cursor
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
750 |
a6cffc232b9d
patch 8.1.1148: CTRL-L with 'incsearch' does not pick up char under cursor
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
751 while (mb_char2len(*c) != mb_ptr2len(ml_get_cursor())) |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
15083
diff
changeset
|
752 { |
16287
a6cffc232b9d
patch 8.1.1148: CTRL-L with 'incsearch' does not pick up char under cursor
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
753 curwin->w_cursor.col += mb_char2len(*c); |
a6cffc232b9d
patch 8.1.1148: CTRL-L with 'incsearch' does not pick up char under cursor
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
754 *c = gchar_cursor(); |
a6cffc232b9d
patch 8.1.1148: CTRL-L with 'incsearch' does not pick up char under cursor
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
755 stuffcharReadbuff(*c); |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
15083
diff
changeset
|
756 } |
16287
a6cffc232b9d
patch 8.1.1148: CTRL-L with 'incsearch' does not pick up char under cursor
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
757 *c = save_c; |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
758 } |
16287
a6cffc232b9d
patch 8.1.1148: CTRL-L with 'incsearch' does not pick up char under cursor
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
759 return FAIL; |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
760 } |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
761 } |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
762 return OK; |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
763 } |
13794
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
764 #endif |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
765 |
17155
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
766 #ifdef FEAT_ARABIC |
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
767 /* |
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
768 * Return TRUE if the command line has an Arabic character at or after "start" |
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
769 * for "len" bytes. |
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
770 */ |
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
771 static int |
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
772 cmdline_has_arabic(int start, int len) |
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
773 { |
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
774 int j; |
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
775 int mb_l; |
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
776 int u8c; |
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
777 char_u *p; |
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
778 int u8cc[MAX_MCO]; |
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
779 |
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
780 if (!enc_utf8) |
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
781 return FALSE; |
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
782 |
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
783 for (j = start; j < start + len; j += mb_l) |
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
784 { |
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
785 p = ccline.cmdbuff + j; |
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
786 u8c = utfc_ptr2char_len(p, u8cc, start + len - j); |
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
787 mb_l = utfc_ptr2len_len(p, start + len - j); |
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
788 if (ARABIC_CHAR(u8c)) |
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
789 return TRUE; |
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
790 } |
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
791 return FALSE; |
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
792 } |
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
793 #endif |
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
794 |
14858
49b3bdf774ad
patch 8.1.0441: build failure without command line history
Christian Brabandt <cb@256bit.org>
parents:
14854
diff
changeset
|
795 void |
49b3bdf774ad
patch 8.1.0441: build failure without command line history
Christian Brabandt <cb@256bit.org>
parents:
14854
diff
changeset
|
796 cmdline_init(void) |
49b3bdf774ad
patch 8.1.0441: build failure without command line history
Christian Brabandt <cb@256bit.org>
parents:
14854
diff
changeset
|
797 { |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
798 CLEAR_FIELD(ccline); |
14858
49b3bdf774ad
patch 8.1.0441: build failure without command line history
Christian Brabandt <cb@256bit.org>
parents:
14854
diff
changeset
|
799 } |
49b3bdf774ad
patch 8.1.0441: build failure without command line history
Christian Brabandt <cb@256bit.org>
parents:
14854
diff
changeset
|
800 |
13035
89e191a2a8a7
patch 8.0.1393: too much highlighting with 'hlsearch' and 'incsearch' set
Christian Brabandt <cb@256bit.org>
parents:
12960
diff
changeset
|
801 /* |
22169
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
802 * Handle the backslash key pressed in the command-line mode. CTRL-\ CTRL-N |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
803 * goes to Normal mode, CTRL-\ CTRL-G goes to Insert mode when 'insertmode' is |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
804 * set, CTRL-\ e prompts for an expression. |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
805 */ |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
806 static int |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
807 cmdline_handle_backslash_key(int c, int *gotesc) |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
808 { |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
809 ++no_mapping; |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
810 ++allow_keys; |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
811 c = plain_vgetc(); |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
812 --no_mapping; |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
813 --allow_keys; |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
814 |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
815 // CTRL-\ e doesn't work when obtaining an expression, unless it |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
816 // is in a mapping. |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
817 if (c != Ctrl_N && c != Ctrl_G && (c != 'e' |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
818 || (ccline.cmdfirstc == '=' && KeyTyped) |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
819 #ifdef FEAT_EVAL |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
820 || cmdline_star > 0 |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
821 #endif |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
822 )) |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
823 { |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
824 vungetc(c); |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
825 return PROCESS_NEXT_KEY; |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
826 } |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
827 |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
828 #ifdef FEAT_EVAL |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
829 if (c == 'e') |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
830 { |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
831 char_u *p = NULL; |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
832 int len; |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
833 |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
834 /* |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
835 * Replace the command line with the result of an expression. |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
836 * Need to save and restore the current command line, to be |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
837 * able to enter a new one... |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
838 */ |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
839 if (ccline.cmdpos == ccline.cmdlen) |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
840 new_cmdpos = 99999; // keep it at the end |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
841 else |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
842 new_cmdpos = ccline.cmdpos; |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
843 |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
844 c = get_expr_register(); |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
845 if (c == '=') |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
846 { |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
847 // Need to save and restore ccline. And set "textwinlock" |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
848 // to avoid nasty things like going to another buffer when |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
849 // evaluating an expression. |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
850 ++textwinlock; |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
851 p = get_expr_line(); |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
852 --textwinlock; |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
853 |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
854 if (p != NULL) |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
855 { |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
856 len = (int)STRLEN(p); |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
857 if (realloc_cmdbuff(len + 1) == OK) |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
858 { |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
859 ccline.cmdlen = len; |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
860 STRCPY(ccline.cmdbuff, p); |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
861 vim_free(p); |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
862 |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
863 // Restore the cursor or use the position set with |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
864 // set_cmdline_pos(). |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
865 if (new_cmdpos > ccline.cmdlen) |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
866 ccline.cmdpos = ccline.cmdlen; |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
867 else |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
868 ccline.cmdpos = new_cmdpos; |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
869 |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
870 KeyTyped = FALSE; // Don't do p_wc completion. |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
871 redrawcmd(); |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
872 return CMDLINE_CHANGED; |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
873 } |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
874 vim_free(p); |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
875 } |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
876 } |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
877 beep_flush(); |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
878 got_int = FALSE; // don't abandon the command line |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
879 did_emsg = FALSE; |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
880 emsg_on_display = FALSE; |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
881 redrawcmd(); |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
882 return CMDLINE_NOT_CHANGED; |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
883 } |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
884 #endif |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
885 |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
886 if (c == Ctrl_G && p_im && restart_edit == 0) |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
887 restart_edit = 'a'; |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
888 *gotesc = TRUE; // will free ccline.cmdbuff after putting it |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
889 // in history |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
890 return GOTO_NORMAL_MODE; |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
891 } |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
892 |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
893 /* |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
894 * Completion for 'wildchar' or 'wildcharm' key. |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
895 * - hitting <ESC> twice means: abandon command line. |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
896 * - wildcard expansion is only done when the 'wildchar' key is really |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
897 * typed, not when it comes from a macro |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
898 * Returns CMDLINE_CHANGED if command line is changed or CMDLINE_NOT_CHANGED. |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
899 */ |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
900 static int |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
901 cmdline_wildchar_complete( |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
902 int c, |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
903 int escape, |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
904 int *did_wild_list, |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
905 int *wim_index_p, |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
906 expand_T *xp, |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
907 int *gotesc) |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
908 { |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
909 int wim_index = *wim_index_p; |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
910 int res; |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
911 int j; |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
912 int options = WILD_NO_BEEP; |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
913 |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
914 if (wim_flags[wim_index] & WIM_BUFLASTUSED) |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
915 options |= WILD_BUFLASTUSED; |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
916 if (xp->xp_numfiles > 0) // typed p_wc at least twice |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
917 { |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
918 // if 'wildmode' contains "list" may still need to list |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
919 if (xp->xp_numfiles > 1 |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
920 && !*did_wild_list |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
921 && (wim_flags[wim_index] & WIM_LIST)) |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
922 { |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
923 (void)showmatches(xp, FALSE); |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
924 redrawcmd(); |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
925 *did_wild_list = TRUE; |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
926 } |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
927 if (wim_flags[wim_index] & WIM_LONGEST) |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
928 res = nextwild(xp, WILD_LONGEST, options, escape); |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
929 else if (wim_flags[wim_index] & WIM_FULL) |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
930 res = nextwild(xp, WILD_NEXT, options, escape); |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
931 else |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
932 res = OK; // don't insert 'wildchar' now |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
933 } |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
934 else // typed p_wc first time |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
935 { |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
936 wim_index = 0; |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
937 j = ccline.cmdpos; |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
938 // if 'wildmode' first contains "longest", get longest |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
939 // common part |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
940 if (wim_flags[0] & WIM_LONGEST) |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
941 res = nextwild(xp, WILD_LONGEST, options, escape); |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
942 else |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
943 res = nextwild(xp, WILD_EXPAND_KEEP, options, escape); |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
944 |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
945 // if interrupted while completing, behave like it failed |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
946 if (got_int) |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
947 { |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
948 (void)vpeekc(); // remove <C-C> from input stream |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
949 got_int = FALSE; // don't abandon the command line |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
950 (void)ExpandOne(xp, NULL, NULL, 0, WILD_FREE); |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
951 #ifdef FEAT_WILDMENU |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
952 xp->xp_context = EXPAND_NOTHING; |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
953 #endif |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
954 *wim_index_p = wim_index; |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
955 return CMDLINE_CHANGED; |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
956 } |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
957 |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
958 // when more than one match, and 'wildmode' first contains |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
959 // "list", or no change and 'wildmode' contains "longest,list", |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
960 // list all matches |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
961 if (res == OK && xp->xp_numfiles > 1) |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
962 { |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
963 // a "longest" that didn't do anything is skipped (but not |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
964 // "list:longest") |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
965 if (wim_flags[0] == WIM_LONGEST && ccline.cmdpos == j) |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
966 wim_index = 1; |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
967 if ((wim_flags[wim_index] & WIM_LIST) |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
968 #ifdef FEAT_WILDMENU |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
969 || (p_wmnu && (wim_flags[wim_index] & WIM_FULL) != 0) |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
970 #endif |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
971 ) |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
972 { |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
973 if (!(wim_flags[0] & WIM_LONGEST)) |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
974 { |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
975 #ifdef FEAT_WILDMENU |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
976 int p_wmnu_save = p_wmnu; |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
977 p_wmnu = 0; |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
978 #endif |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
979 // remove match |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
980 nextwild(xp, WILD_PREV, 0, escape); |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
981 #ifdef FEAT_WILDMENU |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
982 p_wmnu = p_wmnu_save; |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
983 #endif |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
984 } |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
985 #ifdef FEAT_WILDMENU |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
986 (void)showmatches(xp, p_wmnu |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
987 && ((wim_flags[wim_index] & WIM_LIST) == 0)); |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
988 #else |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
989 (void)showmatches(xp, FALSE); |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
990 #endif |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
991 redrawcmd(); |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
992 *did_wild_list = TRUE; |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
993 if (wim_flags[wim_index] & WIM_LONGEST) |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
994 nextwild(xp, WILD_LONGEST, options, escape); |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
995 else if (wim_flags[wim_index] & WIM_FULL) |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
996 nextwild(xp, WILD_NEXT, options, escape); |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
997 } |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
998 else |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
999 vim_beep(BO_WILD); |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1000 } |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1001 #ifdef FEAT_WILDMENU |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1002 else if (xp->xp_numfiles == -1) |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1003 xp->xp_context = EXPAND_NOTHING; |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1004 #endif |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1005 } |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1006 if (wim_index < 3) |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1007 ++wim_index; |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1008 if (c == ESC) |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1009 *gotesc = TRUE; |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1010 |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1011 *wim_index_p = wim_index; |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1012 return (res == OK) ? CMDLINE_CHANGED : CMDLINE_NOT_CHANGED; |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1013 } |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1014 |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1015 /* |
22145
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1016 * Handle backspace, delete and CTRL-W keys in the command-line mode. |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1017 * Returns: |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1018 * CMDLINE_NOT_CHANGED - if the command line is not changed |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1019 * CMDLINE_CHANGED - if the command line is changed |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1020 * GOTO_NORMAL_MODE - go back to normal mode |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1021 */ |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1022 static int |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1023 cmdline_erase_chars( |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1024 int c, |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1025 int indent |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1026 #ifdef FEAT_SEARCH_EXTRA |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1027 , incsearch_state_T *isp |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1028 #endif |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1029 ) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1030 { |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1031 int i; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1032 int j; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1033 |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1034 if (c == K_KDEL) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1035 c = K_DEL; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1036 |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1037 /* |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1038 * Delete current character is the same as backspace on next |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1039 * character, except at end of line. |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1040 */ |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1041 if (c == K_DEL && ccline.cmdpos != ccline.cmdlen) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1042 ++ccline.cmdpos; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1043 if (has_mbyte && c == K_DEL) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1044 ccline.cmdpos += mb_off_next(ccline.cmdbuff, |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1045 ccline.cmdbuff + ccline.cmdpos); |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1046 if (ccline.cmdpos > 0) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1047 { |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1048 char_u *p; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1049 |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1050 j = ccline.cmdpos; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1051 p = ccline.cmdbuff + j; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1052 if (has_mbyte) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1053 { |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1054 p = mb_prevptr(ccline.cmdbuff, p); |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1055 if (c == Ctrl_W) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1056 { |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1057 while (p > ccline.cmdbuff && vim_isspace(*p)) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1058 p = mb_prevptr(ccline.cmdbuff, p); |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1059 i = mb_get_class(p); |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1060 while (p > ccline.cmdbuff && mb_get_class(p) == i) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1061 p = mb_prevptr(ccline.cmdbuff, p); |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1062 if (mb_get_class(p) != i) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1063 p += (*mb_ptr2len)(p); |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1064 } |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1065 } |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1066 else if (c == Ctrl_W) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1067 { |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1068 while (p > ccline.cmdbuff && vim_isspace(p[-1])) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1069 --p; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1070 i = vim_iswordc(p[-1]); |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1071 while (p > ccline.cmdbuff && !vim_isspace(p[-1]) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1072 && vim_iswordc(p[-1]) == i) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1073 --p; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1074 } |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1075 else |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1076 --p; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1077 ccline.cmdpos = (int)(p - ccline.cmdbuff); |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1078 ccline.cmdlen -= j - ccline.cmdpos; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1079 i = ccline.cmdpos; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1080 while (i < ccline.cmdlen) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1081 ccline.cmdbuff[i++] = ccline.cmdbuff[j++]; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1082 |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1083 // Truncate at the end, required for multi-byte chars. |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1084 ccline.cmdbuff[ccline.cmdlen] = NUL; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1085 #ifdef FEAT_SEARCH_EXTRA |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1086 if (ccline.cmdlen == 0) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1087 { |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1088 isp->search_start = isp->save_cursor; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1089 // save view settings, so that the screen |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1090 // won't be restored at the wrong position |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1091 isp->old_viewstate = isp->init_viewstate; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1092 } |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1093 #endif |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1094 redrawcmd(); |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1095 } |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1096 else if (ccline.cmdlen == 0 && c != Ctrl_W |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1097 && ccline.cmdprompt == NULL && indent == 0) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1098 { |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1099 // In ex and debug mode it doesn't make sense to return. |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1100 if (exmode_active |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1101 #ifdef FEAT_EVAL |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1102 || ccline.cmdfirstc == '>' |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1103 #endif |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1104 ) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1105 return CMDLINE_NOT_CHANGED; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1106 |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1107 VIM_CLEAR(ccline.cmdbuff); // no commandline to return |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1108 if (!cmd_silent) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1109 { |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1110 #ifdef FEAT_RIGHTLEFT |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1111 if (cmdmsg_rl) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1112 msg_col = Columns; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1113 else |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1114 #endif |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1115 msg_col = 0; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1116 msg_putchar(' '); // delete ':' |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1117 } |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1118 #ifdef FEAT_SEARCH_EXTRA |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1119 if (ccline.cmdlen == 0) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1120 isp->search_start = isp->save_cursor; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1121 #endif |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1122 redraw_cmdline = TRUE; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1123 return GOTO_NORMAL_MODE; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1124 } |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1125 return CMDLINE_CHANGED; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1126 } |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1127 |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1128 /* |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1129 * Handle the CTRL-^ key in the command-line mode and toggle the use of the |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1130 * language :lmap mappings and/or Input Method. |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1131 */ |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1132 static void |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1133 cmdline_toggle_langmap(long *b_im_ptr) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1134 { |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1135 if (map_to_exists_mode((char_u *)"", LANGMAP, FALSE)) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1136 { |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1137 // ":lmap" mappings exists, toggle use of mappings. |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1138 State ^= LANGMAP; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1139 #ifdef HAVE_INPUT_METHOD |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1140 im_set_active(FALSE); // Disable input method |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1141 #endif |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1142 if (b_im_ptr != NULL) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1143 { |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1144 if (State & LANGMAP) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1145 *b_im_ptr = B_IMODE_LMAP; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1146 else |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1147 *b_im_ptr = B_IMODE_NONE; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1148 } |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1149 } |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1150 #ifdef HAVE_INPUT_METHOD |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1151 else |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1152 { |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1153 // There are no ":lmap" mappings, toggle IM. When |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1154 // 'imdisable' is set don't try getting the status, it's |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1155 // always off. |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1156 if ((p_imdisable && b_im_ptr != NULL) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1157 ? *b_im_ptr == B_IMODE_IM : im_get_status()) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1158 { |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1159 im_set_active(FALSE); // Disable input method |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1160 if (b_im_ptr != NULL) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1161 *b_im_ptr = B_IMODE_NONE; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1162 } |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1163 else |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1164 { |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1165 im_set_active(TRUE); // Enable input method |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1166 if (b_im_ptr != NULL) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1167 *b_im_ptr = B_IMODE_IM; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1168 } |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1169 } |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1170 #endif |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1171 if (b_im_ptr != NULL) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1172 { |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1173 if (b_im_ptr == &curbuf->b_p_iminsert) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1174 set_iminsert_global(); |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1175 else |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1176 set_imsearch_global(); |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1177 } |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1178 #ifdef CURSOR_SHAPE |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1179 ui_cursor_shape(); // may show different cursor shape |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1180 #endif |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1181 #if defined(FEAT_KEYMAP) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1182 // Show/unshow value of 'keymap' in status lines later. |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1183 status_redraw_curbuf(); |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1184 #endif |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1185 } |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1186 |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1187 /* |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1188 * Handle the CTRL-R key in the command-line mode and insert the contents of a |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1189 * numbered or named register. |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1190 */ |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1191 static int |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1192 cmdline_insert_reg(int *gotesc UNUSED) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1193 { |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1194 int i; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1195 int c; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1196 |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1197 #ifdef USE_ON_FLY_SCROLL |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1198 dont_scroll = TRUE; // disallow scrolling here |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1199 #endif |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1200 putcmdline('"', TRUE); |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1201 ++no_mapping; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1202 ++allow_keys; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1203 i = c = plain_vgetc(); // CTRL-R <char> |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1204 if (i == Ctrl_O) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1205 i = Ctrl_R; // CTRL-R CTRL-O == CTRL-R CTRL-R |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1206 if (i == Ctrl_R) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1207 c = plain_vgetc(); // CTRL-R CTRL-R <char> |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1208 extra_char = NUL; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1209 --no_mapping; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1210 --allow_keys; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1211 #ifdef FEAT_EVAL |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1212 /* |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1213 * Insert the result of an expression. |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1214 * Need to save the current command line, to be able to enter |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1215 * a new one... |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1216 */ |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1217 new_cmdpos = -1; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1218 if (c == '=') |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1219 { |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1220 if (ccline.cmdfirstc == '=' // can't do this recursively |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1221 || cmdline_star > 0) // or when typing a password |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1222 { |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1223 beep_flush(); |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1224 c = ESC; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1225 } |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1226 else |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1227 c = get_expr_register(); |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1228 } |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1229 #endif |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1230 if (c != ESC) // use ESC to cancel inserting register |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1231 { |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1232 cmdline_paste(c, i == Ctrl_R, FALSE); |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1233 |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1234 #ifdef FEAT_EVAL |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1235 // When there was a serious error abort getting the |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1236 // command line. |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1237 if (aborting()) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1238 { |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1239 *gotesc = TRUE; // will free ccline.cmdbuff after |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1240 // putting it in history |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1241 return GOTO_NORMAL_MODE; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1242 } |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1243 #endif |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1244 KeyTyped = FALSE; // Don't do p_wc completion. |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1245 #ifdef FEAT_EVAL |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1246 if (new_cmdpos >= 0) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1247 { |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1248 // set_cmdline_pos() was used |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1249 if (new_cmdpos > ccline.cmdlen) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1250 ccline.cmdpos = ccline.cmdlen; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1251 else |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1252 ccline.cmdpos = new_cmdpos; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1253 } |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1254 #endif |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1255 } |
24663
ce7a80bd0fd5
patch 8.2.2870: CmdlineChange event triggered twice for CTRL-R
Bram Moolenaar <Bram@vim.org>
parents:
24628
diff
changeset
|
1256 // remove the double quote |
22145
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1257 redrawcmd(); |
24663
ce7a80bd0fd5
patch 8.2.2870: CmdlineChange event triggered twice for CTRL-R
Bram Moolenaar <Bram@vim.org>
parents:
24628
diff
changeset
|
1258 |
ce7a80bd0fd5
patch 8.2.2870: CmdlineChange event triggered twice for CTRL-R
Bram Moolenaar <Bram@vim.org>
parents:
24628
diff
changeset
|
1259 // The text has been stuffed, the command line didn't change yet. |
ce7a80bd0fd5
patch 8.2.2870: CmdlineChange event triggered twice for CTRL-R
Bram Moolenaar <Bram@vim.org>
parents:
24628
diff
changeset
|
1260 return CMDLINE_NOT_CHANGED; |
22145
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1261 } |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1262 |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1263 /* |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1264 * Handle the Left and Right mouse clicks in the command-line mode. |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1265 */ |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1266 static void |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1267 cmdline_left_right_mouse(int c, int *ignore_drag_release) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1268 { |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1269 if (c == K_LEFTRELEASE || c == K_RIGHTRELEASE) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1270 *ignore_drag_release = TRUE; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1271 else |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1272 *ignore_drag_release = FALSE; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1273 # ifdef FEAT_GUI |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1274 // When GUI is active, also move when 'mouse' is empty |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1275 if (!gui.in_use) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1276 # endif |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1277 if (!mouse_has(MOUSE_COMMAND)) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1278 return; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1279 # ifdef FEAT_CLIPBOARD |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1280 if (mouse_row < cmdline_row && clip_star.available) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1281 { |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1282 int button, is_click, is_drag; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1283 |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1284 /* |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1285 * Handle modeless selection. |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1286 */ |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1287 button = get_mouse_button(KEY2TERMCAP1(c), |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1288 &is_click, &is_drag); |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1289 if (mouse_model_popup() && button == MOUSE_LEFT |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1290 && (mod_mask & MOD_MASK_SHIFT)) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1291 { |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1292 // Translate shift-left to right button. |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1293 button = MOUSE_RIGHT; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1294 mod_mask &= ~MOD_MASK_SHIFT; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1295 } |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1296 clip_modeless(button, is_click, is_drag); |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1297 return; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1298 } |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1299 # endif |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1300 |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1301 set_cmdspos(); |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1302 for (ccline.cmdpos = 0; ccline.cmdpos < ccline.cmdlen; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1303 ++ccline.cmdpos) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1304 { |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1305 int i; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1306 |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1307 i = cmdline_charsize(ccline.cmdpos); |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1308 if (mouse_row <= cmdline_row + ccline.cmdspos / Columns |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1309 && mouse_col < ccline.cmdspos % Columns + i) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1310 break; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1311 if (has_mbyte) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1312 { |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1313 // Count ">" for double-wide char that doesn't fit. |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1314 correct_cmdspos(ccline.cmdpos, i); |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1315 ccline.cmdpos += (*mb_ptr2len)(ccline.cmdbuff |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1316 + ccline.cmdpos) - 1; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1317 } |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1318 ccline.cmdspos += i; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1319 } |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1320 } |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1321 |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1322 /* |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1323 * Handle the Up, Down, Page Up, Page down, CTRL-N and CTRL-P key in the |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1324 * command-line mode. The pressed key is in 'c'. |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1325 * Returns: |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1326 * CMDLINE_NOT_CHANGED - if the command line is not changed |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1327 * CMDLINE_CHANGED - if the command line is changed |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1328 * GOTO_NORMAL_MODE - go back to normal mode |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1329 */ |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1330 static int |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1331 cmdline_browse_history( |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1332 int c, |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1333 int firstc, |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1334 char_u **curcmdstr, |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1335 int histype, |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1336 int *hiscnt_p, |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1337 expand_T *xp) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1338 { |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1339 int i; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1340 int j; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1341 char_u *lookfor = *curcmdstr; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1342 int hiscnt = *hiscnt_p; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1343 int res; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1344 |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1345 if (get_hislen() == 0 || firstc == NUL) // no history |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1346 return CMDLINE_NOT_CHANGED; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1347 |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1348 i = hiscnt; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1349 |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1350 // save current command string so it can be restored later |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1351 if (lookfor == NULL) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1352 { |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1353 if ((lookfor = vim_strsave(ccline.cmdbuff)) == NULL) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1354 return CMDLINE_NOT_CHANGED; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1355 lookfor[ccline.cmdpos] = NUL; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1356 } |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1357 |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1358 j = (int)STRLEN(lookfor); |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1359 for (;;) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1360 { |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1361 // one step backwards |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1362 if (c == K_UP|| c == K_S_UP || c == Ctrl_P |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1363 || c == K_PAGEUP || c == K_KPAGEUP) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1364 { |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1365 if (hiscnt == get_hislen()) // first time |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1366 hiscnt = *get_hisidx(histype); |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1367 else if (hiscnt == 0 && *get_hisidx(histype) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1368 != get_hislen() - 1) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1369 hiscnt = get_hislen() - 1; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1370 else if (hiscnt != *get_hisidx(histype) + 1) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1371 --hiscnt; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1372 else // at top of list |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1373 { |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1374 hiscnt = i; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1375 break; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1376 } |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1377 } |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1378 else // one step forwards |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1379 { |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1380 // on last entry, clear the line |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1381 if (hiscnt == *get_hisidx(histype)) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1382 { |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1383 hiscnt = get_hislen(); |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1384 break; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1385 } |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1386 |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1387 // not on a history line, nothing to do |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1388 if (hiscnt == get_hislen()) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1389 break; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1390 if (hiscnt == get_hislen() - 1) // wrap around |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1391 hiscnt = 0; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1392 else |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1393 ++hiscnt; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1394 } |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1395 if (hiscnt < 0 || get_histentry(histype)[hiscnt].hisstr |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1396 == NULL) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1397 { |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1398 hiscnt = i; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1399 break; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1400 } |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1401 if ((c != K_UP && c != K_DOWN) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1402 || hiscnt == i |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1403 || STRNCMP(get_histentry(histype)[hiscnt].hisstr, |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1404 lookfor, (size_t)j) == 0) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1405 break; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1406 } |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1407 |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1408 if (hiscnt != i) // jumped to other entry |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1409 { |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1410 char_u *p; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1411 int len; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1412 int old_firstc; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1413 |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1414 VIM_CLEAR(ccline.cmdbuff); |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1415 xp->xp_context = EXPAND_NOTHING; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1416 if (hiscnt == get_hislen()) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1417 p = lookfor; // back to the old one |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1418 else |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1419 p = get_histentry(histype)[hiscnt].hisstr; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1420 |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1421 if (histype == HIST_SEARCH |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1422 && p != lookfor |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1423 && (old_firstc = p[STRLEN(p) + 1]) != firstc) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1424 { |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1425 // Correct for the separator character used when |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1426 // adding the history entry vs the one used now. |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1427 // First loop: count length. |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1428 // Second loop: copy the characters. |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1429 for (i = 0; i <= 1; ++i) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1430 { |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1431 len = 0; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1432 for (j = 0; p[j] != NUL; ++j) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1433 { |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1434 // Replace old sep with new sep, unless it is |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1435 // escaped. |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1436 if (p[j] == old_firstc |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1437 && (j == 0 || p[j - 1] != '\\')) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1438 { |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1439 if (i > 0) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1440 ccline.cmdbuff[len] = firstc; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1441 } |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1442 else |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1443 { |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1444 // Escape new sep, unless it is already |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1445 // escaped. |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1446 if (p[j] == firstc |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1447 && (j == 0 || p[j - 1] != '\\')) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1448 { |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1449 if (i > 0) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1450 ccline.cmdbuff[len] = '\\'; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1451 ++len; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1452 } |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1453 if (i > 0) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1454 ccline.cmdbuff[len] = p[j]; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1455 } |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1456 ++len; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1457 } |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1458 if (i == 0) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1459 { |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1460 alloc_cmdbuff(len); |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1461 if (ccline.cmdbuff == NULL) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1462 { |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1463 res = GOTO_NORMAL_MODE; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1464 goto done; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1465 } |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1466 } |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1467 } |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1468 ccline.cmdbuff[len] = NUL; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1469 } |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1470 else |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1471 { |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1472 alloc_cmdbuff((int)STRLEN(p)); |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1473 if (ccline.cmdbuff == NULL) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1474 { |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1475 res = GOTO_NORMAL_MODE; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1476 goto done; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1477 } |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1478 STRCPY(ccline.cmdbuff, p); |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1479 } |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1480 |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1481 ccline.cmdpos = ccline.cmdlen = (int)STRLEN(ccline.cmdbuff); |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1482 redrawcmd(); |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1483 res = CMDLINE_CHANGED; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1484 goto done; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1485 } |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1486 beep_flush(); |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1487 res = CMDLINE_NOT_CHANGED; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1488 |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1489 done: |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1490 *curcmdstr = lookfor; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1491 *hiscnt_p = hiscnt; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1492 return res; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1493 } |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1494 |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1495 /* |
22169
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1496 * Initialize the current command-line info. |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1497 */ |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1498 static int |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1499 init_ccline(int firstc, int indent) |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1500 { |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1501 ccline.overstrike = FALSE; // always start in insert mode |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1502 |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1503 /* |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1504 * set some variables for redrawcmd() |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1505 */ |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1506 ccline.cmdfirstc = (firstc == '@' ? 0 : firstc); |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1507 ccline.cmdindent = (firstc > 0 ? indent : 0); |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1508 |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1509 // alloc initial ccline.cmdbuff |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1510 alloc_cmdbuff(exmode_active ? 250 : indent + 1); |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1511 if (ccline.cmdbuff == NULL) |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1512 return FAIL; |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1513 ccline.cmdlen = ccline.cmdpos = 0; |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1514 ccline.cmdbuff[0] = NUL; |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1515 sb_text_start_cmdline(); |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1516 |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1517 // autoindent for :insert and :append |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1518 if (firstc <= 0) |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1519 { |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1520 vim_memset(ccline.cmdbuff, ' ', indent); |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1521 ccline.cmdbuff[indent] = NUL; |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1522 ccline.cmdpos = indent; |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1523 ccline.cmdspos = indent; |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1524 ccline.cmdlen = indent; |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1525 } |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1526 |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1527 return OK; |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1528 } |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1529 |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1530 /* |
7 | 1531 * getcmdline() - accept a command line starting with firstc. |
1532 * | |
1533 * firstc == ':' get ":" command line. | |
1534 * firstc == '/' or '?' get search pattern | |
1535 * firstc == '=' get expression | |
1536 * firstc == '@' get text for input() function | |
1537 * firstc == '>' get text for debug mode | |
1538 * firstc == NUL get text for :insert command | |
1539 * firstc == -1 like NUL, and break on CTRL-C | |
1540 * | |
1541 * The line is collected in ccline.cmdbuff, which is reallocated to fit the | |
1542 * command line. | |
1543 * | |
1544 * Careful: getcmdline() can be called recursively! | |
1545 * | |
1546 * Return pointer to allocated string if there is a commandline, NULL | |
1547 * otherwise. | |
1548 */ | |
1549 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1550 getcmdline( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1551 int firstc, |
14854
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
1552 long count, // only used for incremental search |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17155
diff
changeset
|
1553 int indent, // indent for inside conditionals |
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17155
diff
changeset
|
1554 int do_concat UNUSED) |
14854
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
1555 { |
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
1556 return getcmdline_int(firstc, count, indent, TRUE); |
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
1557 } |
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
1558 |
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
1559 static char_u * |
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
1560 getcmdline_int( |
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
1561 int firstc, |
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
1562 long count UNUSED, // only used for incremental search |
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
1563 int indent, // indent for inside conditionals |
22169
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1564 int clear_ccline) // clear ccline first |
7 | 1565 { |
1566 int c; | |
1567 int i; | |
1568 int j; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1569 int gotesc = FALSE; // TRUE when <ESC> just typed |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1570 int do_abbr; // when TRUE check for abbr. |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1571 char_u *lookfor = NULL; // string to match |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1572 int hiscnt; // current history line in use |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1573 int histype; // history type to be used |
7 | 1574 #ifdef FEAT_SEARCH_EXTRA |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
1575 incsearch_state_T is_state; |
7 | 1576 #endif |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1577 int did_wild_list = FALSE; // did wild_list() recently |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1578 int wim_index = 0; // index in wim_flags[] |
7 | 1579 int res; |
1580 int save_msg_scroll = msg_scroll; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1581 int save_State = State; // remember State when called |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1582 int some_key_typed = FALSE; // one of the keys was typed |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1583 // mouse drag and release events are ignored, unless they are |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1584 // preceded with a mouse down event |
7 | 1585 int ignore_drag_release = TRUE; |
1586 #ifdef FEAT_EVAL | |
1587 int break_ctrl_c = FALSE; | |
1588 #endif | |
1589 expand_T xpc; | |
1590 long *b_im_ptr = NULL; | |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
1591 cmdline_info_T save_ccline; |
14854
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
1592 int did_save_ccline = FALSE; |
12656
0a9dacb8826a
patch 8.0.1206: no autocmd for entering or leaving the command line
Christian Brabandt <cb@256bit.org>
parents:
12529
diff
changeset
|
1593 int cmdline_type; |
7 | 1594 |
14854
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
1595 if (ccline.cmdbuff != NULL) |
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
1596 { |
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
1597 // Being called recursively. Since ccline is global, we need to save |
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
1598 // the current buffer and restore it when returning. |
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
1599 save_cmdline(&save_ccline); |
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
1600 did_save_ccline = TRUE; |
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
1601 } |
22169
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1602 if (clear_ccline) |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
1603 CLEAR_FIELD(ccline); |
14854
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
1604 |
7 | 1605 #ifdef FEAT_EVAL |
1606 if (firstc == -1) | |
1607 { | |
1608 firstc = NUL; | |
1609 break_ctrl_c = TRUE; | |
1610 } | |
1611 #endif | |
1612 #ifdef FEAT_RIGHTLEFT | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1613 // start without Hebrew mapping for a command line |
7 | 1614 if (firstc == ':' || firstc == '=' || firstc == '>') |
1615 cmd_hkmap = 0; | |
1616 #endif | |
1617 | |
1618 #ifdef FEAT_SEARCH_EXTRA | |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
1619 init_incsearch_state(&is_state); |
7 | 1620 #endif |
1621 | |
22169
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1622 if (init_ccline(firstc, indent) != OK) |
14854
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
1623 goto theend; // out of memory |
164 | 1624 |
7 | 1625 ExpandInit(&xpc); |
1718 | 1626 ccline.xpc = &xpc; |
7 | 1627 |
1628 #ifdef FEAT_RIGHTLEFT | |
1629 if (curwin->w_p_rl && *curwin->w_p_rlc == 's' | |
1630 && (firstc == '/' || firstc == '?')) | |
1631 cmdmsg_rl = TRUE; | |
1632 else | |
1633 cmdmsg_rl = FALSE; | |
1634 #endif | |
1635 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1636 redir_off = TRUE; // don't redirect the typed command |
7 | 1637 if (!cmd_silent) |
1638 { | |
1639 i = msg_scrolled; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1640 msg_scrolled = 0; // avoid wait_return message |
7 | 1641 gotocmdline(TRUE); |
1642 msg_scrolled += i; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1643 redrawcmdprompt(); // draw prompt or indent |
7 | 1644 set_cmdspos(); |
1645 } | |
1646 xpc.xp_context = EXPAND_NOTHING; | |
1647 xpc.xp_backslash = XP_BS_NONE; | |
632 | 1648 #ifndef BACKSLASH_IN_FILENAME |
1649 xpc.xp_shell = FALSE; | |
1650 #endif | |
7 | 1651 |
531 | 1652 #if defined(FEAT_EVAL) |
1653 if (ccline.input_fn) | |
1654 { | |
1655 xpc.xp_context = ccline.xp_context; | |
1656 xpc.xp_pattern = ccline.cmdbuff; | |
1657 xpc.xp_arg = ccline.xp_arg; | |
1658 } | |
1659 #endif | |
1660 | |
7 | 1661 /* |
1662 * Avoid scrolling when called by a recursive do_cmdline(), e.g. when | |
1663 * doing ":@0" when register 0 doesn't contain a CR. | |
1664 */ | |
1665 msg_scroll = FALSE; | |
1666 | |
1667 State = CMDLINE; | |
1668 | |
1669 if (firstc == '/' || firstc == '?' || firstc == '@') | |
1670 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1671 // Use ":lmap" mappings for search pattern and input(). |
7 | 1672 if (curbuf->b_p_imsearch == B_IMODE_USE_INSERT) |
1673 b_im_ptr = &curbuf->b_p_iminsert; | |
1674 else | |
1675 b_im_ptr = &curbuf->b_p_imsearch; | |
1676 if (*b_im_ptr == B_IMODE_LMAP) | |
1677 State |= LANGMAP; | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13256
diff
changeset
|
1678 #ifdef HAVE_INPUT_METHOD |
7 | 1679 im_set_active(*b_im_ptr == B_IMODE_IM); |
1680 #endif | |
1681 } | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13256
diff
changeset
|
1682 #ifdef HAVE_INPUT_METHOD |
7 | 1683 else if (p_imcmdline) |
1684 im_set_active(TRUE); | |
1685 #endif | |
1686 | |
1687 setmouse(); | |
1688 #ifdef CURSOR_SHAPE | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1689 ui_cursor_shape(); // may show different cursor shape |
7 | 1690 #endif |
1691 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1692 // When inside an autocommand for writing "exiting" may be set and |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1693 // terminal mode set to cooked. Need to set raw mode here then. |
571 | 1694 settmode(TMODE_RAW); |
1695 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1696 // Trigger CmdlineEnter autocommands. |
12656
0a9dacb8826a
patch 8.0.1206: no autocmd for entering or leaving the command line
Christian Brabandt <cb@256bit.org>
parents:
12529
diff
changeset
|
1697 cmdline_type = firstc == NUL ? '-' : firstc; |
0a9dacb8826a
patch 8.0.1206: no autocmd for entering or leaving the command line
Christian Brabandt <cb@256bit.org>
parents:
12529
diff
changeset
|
1698 trigger_cmd_autocmd(cmdline_type, EVENT_CMDLINEENTER); |
0a9dacb8826a
patch 8.0.1206: no autocmd for entering or leaving the command line
Christian Brabandt <cb@256bit.org>
parents:
12529
diff
changeset
|
1699 |
7 | 1700 init_history(); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1701 hiscnt = get_hislen(); // set hiscnt to impossible history value |
7 | 1702 histype = hist_char2type(firstc); |
1703 | |
1704 #ifdef FEAT_DIGRAPHS | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1705 do_digraph(-1); // init digraph typeahead |
7 | 1706 #endif |
1707 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1708 // If something above caused an error, reset the flags, we do want to type |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1709 // and execute commands. Display may be messed up a bit. |
5993 | 1710 if (did_emsg) |
1711 redrawcmd(); | |
24291
93b401236991
patch 8.2.2686: status line is not updated when going to cmdline mode
Bram Moolenaar <Bram@vim.org>
parents:
23899
diff
changeset
|
1712 |
24297
6b7ab048eaae
patch 8.2.2689: tiny build fails
Bram Moolenaar <Bram@vim.org>
parents:
24291
diff
changeset
|
1713 #ifdef FEAT_STL_OPT |
24291
93b401236991
patch 8.2.2686: status line is not updated when going to cmdline mode
Bram Moolenaar <Bram@vim.org>
parents:
23899
diff
changeset
|
1714 // Redraw the statusline in case it uses the current mode using the mode() |
93b401236991
patch 8.2.2686: status line is not updated when going to cmdline mode
Bram Moolenaar <Bram@vim.org>
parents:
23899
diff
changeset
|
1715 // function. |
24394
5858745d393a
patch 8.2.2737: status line not updated when local 'statusline' option set
Bram Moolenaar <Bram@vim.org>
parents:
24297
diff
changeset
|
1716 if (!cmd_silent && msg_scrolled == 0) |
24291
93b401236991
patch 8.2.2686: status line is not updated when going to cmdline mode
Bram Moolenaar <Bram@vim.org>
parents:
23899
diff
changeset
|
1717 { |
24394
5858745d393a
patch 8.2.2737: status line not updated when local 'statusline' option set
Bram Moolenaar <Bram@vim.org>
parents:
24297
diff
changeset
|
1718 int found_one = FALSE; |
5858745d393a
patch 8.2.2737: status line not updated when local 'statusline' option set
Bram Moolenaar <Bram@vim.org>
parents:
24297
diff
changeset
|
1719 win_T *wp; |
5858745d393a
patch 8.2.2737: status line not updated when local 'statusline' option set
Bram Moolenaar <Bram@vim.org>
parents:
24297
diff
changeset
|
1720 |
5858745d393a
patch 8.2.2737: status line not updated when local 'statusline' option set
Bram Moolenaar <Bram@vim.org>
parents:
24297
diff
changeset
|
1721 FOR_ALL_WINDOWS(wp) |
5858745d393a
patch 8.2.2737: status line not updated when local 'statusline' option set
Bram Moolenaar <Bram@vim.org>
parents:
24297
diff
changeset
|
1722 if (*p_stl != NUL || *wp->w_p_stl != NUL) |
5858745d393a
patch 8.2.2737: status line not updated when local 'statusline' option set
Bram Moolenaar <Bram@vim.org>
parents:
24297
diff
changeset
|
1723 { |
5858745d393a
patch 8.2.2737: status line not updated when local 'statusline' option set
Bram Moolenaar <Bram@vim.org>
parents:
24297
diff
changeset
|
1724 wp->w_redr_status = TRUE; |
5858745d393a
patch 8.2.2737: status line not updated when local 'statusline' option set
Bram Moolenaar <Bram@vim.org>
parents:
24297
diff
changeset
|
1725 found_one = TRUE; |
5858745d393a
patch 8.2.2737: status line not updated when local 'statusline' option set
Bram Moolenaar <Bram@vim.org>
parents:
24297
diff
changeset
|
1726 } |
5858745d393a
patch 8.2.2737: status line not updated when local 'statusline' option set
Bram Moolenaar <Bram@vim.org>
parents:
24297
diff
changeset
|
1727 if (found_one) |
5858745d393a
patch 8.2.2737: status line not updated when local 'statusline' option set
Bram Moolenaar <Bram@vim.org>
parents:
24297
diff
changeset
|
1728 redraw_statuslines(); |
24291
93b401236991
patch 8.2.2686: status line is not updated when going to cmdline mode
Bram Moolenaar <Bram@vim.org>
parents:
23899
diff
changeset
|
1729 } |
24297
6b7ab048eaae
patch 8.2.2689: tiny build fails
Bram Moolenaar <Bram@vim.org>
parents:
24291
diff
changeset
|
1730 #endif |
24291
93b401236991
patch 8.2.2686: status line is not updated when going to cmdline mode
Bram Moolenaar <Bram@vim.org>
parents:
23899
diff
changeset
|
1731 |
5993 | 1732 did_emsg = FALSE; |
1733 got_int = FALSE; | |
1734 | |
7 | 1735 /* |
1736 * Collect the command string, handling editing keys. | |
1737 */ | |
1738 for (;;) | |
1739 { | |
24628
447426630e44
patch 8.2.2853: window is not updated after using <Cmd> mapping
Bram Moolenaar <Bram@vim.org>
parents:
24624
diff
changeset
|
1740 int trigger_cmdlinechanged = TRUE; |
447426630e44
patch 8.2.2853: window is not updated after using <Cmd> mapping
Bram Moolenaar <Bram@vim.org>
parents:
24624
diff
changeset
|
1741 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1742 redir_off = TRUE; // Don't redirect the typed command. |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1743 // Repeated, because a ":redir" inside |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1744 // completion may switch it on. |
7 | 1745 #ifdef USE_ON_FLY_SCROLL |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1746 dont_scroll = FALSE; // allow scrolling here |
7 | 1747 #endif |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1748 quit_more = FALSE; // reset after CTRL-D which had a more-prompt |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1749 |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1750 did_emsg = FALSE; // There can't really be a reason why an error |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1751 // that occurs while typing a command should |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1752 // cause the command not to be executed. |
13600
75e35ebdb7a4
patch 8.0.1672: error during completion causes command to be cancelled
Christian Brabandt <cb@256bit.org>
parents:
13551
diff
changeset
|
1753 |
18098
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18043
diff
changeset
|
1754 // Trigger SafeState if nothing is pending. |
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18043
diff
changeset
|
1755 may_trigger_safestate(xpc.xp_numfiles <= 0); |
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18043
diff
changeset
|
1756 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1757 // Get a character. Ignore K_IGNORE and K_NOP, they should not do |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1758 // anything, such as stop completion. |
1472 | 1759 do |
22872
5a7db84713dc
patch 8.2.1983: ml_get error when using <Cmd> to open a terminal
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1760 { |
5a7db84713dc
patch 8.2.1983: ml_get error when using <Cmd> to open a terminal
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1761 cursorcmd(); // set the cursor on the right spot |
1472 | 1762 c = safe_vgetc(); |
22872
5a7db84713dc
patch 8.2.1983: ml_get error when using <Cmd> to open a terminal
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1763 } while (c == K_IGNORE || c == K_NOP); |
1472 | 1764 |
24624
c6aaf1742634
patch 8.2.2851: using <Cmd> mapping on the command line triggers CmdlineChanged
Bram Moolenaar <Bram@vim.org>
parents:
24394
diff
changeset
|
1765 if (c == K_COMMAND) |
c6aaf1742634
patch 8.2.2851: using <Cmd> mapping on the command line triggers CmdlineChanged
Bram Moolenaar <Bram@vim.org>
parents:
24394
diff
changeset
|
1766 { |
c6aaf1742634
patch 8.2.2851: using <Cmd> mapping on the command line triggers CmdlineChanged
Bram Moolenaar <Bram@vim.org>
parents:
24394
diff
changeset
|
1767 int clen = ccline.cmdlen; |
c6aaf1742634
patch 8.2.2851: using <Cmd> mapping on the command line triggers CmdlineChanged
Bram Moolenaar <Bram@vim.org>
parents:
24394
diff
changeset
|
1768 |
c6aaf1742634
patch 8.2.2851: using <Cmd> mapping on the command line triggers CmdlineChanged
Bram Moolenaar <Bram@vim.org>
parents:
24394
diff
changeset
|
1769 if (do_cmdline(NULL, getcmdkeycmd, NULL, DOCMD_NOWAIT) == OK) |
c6aaf1742634
patch 8.2.2851: using <Cmd> mapping on the command line triggers CmdlineChanged
Bram Moolenaar <Bram@vim.org>
parents:
24394
diff
changeset
|
1770 { |
c6aaf1742634
patch 8.2.2851: using <Cmd> mapping on the command line triggers CmdlineChanged
Bram Moolenaar <Bram@vim.org>
parents:
24394
diff
changeset
|
1771 if (clen == ccline.cmdlen) |
24628
447426630e44
patch 8.2.2853: window is not updated after using <Cmd> mapping
Bram Moolenaar <Bram@vim.org>
parents:
24624
diff
changeset
|
1772 trigger_cmdlinechanged = FALSE; |
24624
c6aaf1742634
patch 8.2.2851: using <Cmd> mapping on the command line triggers CmdlineChanged
Bram Moolenaar <Bram@vim.org>
parents:
24394
diff
changeset
|
1773 goto cmdline_changed; |
c6aaf1742634
patch 8.2.2851: using <Cmd> mapping on the command line triggers CmdlineChanged
Bram Moolenaar <Bram@vim.org>
parents:
24394
diff
changeset
|
1774 } |
c6aaf1742634
patch 8.2.2851: using <Cmd> mapping on the command line triggers CmdlineChanged
Bram Moolenaar <Bram@vim.org>
parents:
24394
diff
changeset
|
1775 } |
22862
6d50182e7e24
patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
1776 |
7 | 1777 if (KeyTyped) |
1778 { | |
1779 some_key_typed = TRUE; | |
1780 #ifdef FEAT_RIGHTLEFT | |
1781 if (cmd_hkmap) | |
1782 c = hkmap(c); | |
1783 if (cmdmsg_rl && !KeyStuffed) | |
1784 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1785 // Invert horizontal movements and operations. Only when |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1786 // typed by the user directly, not when the result of a |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1787 // mapping. |
7 | 1788 switch (c) |
1789 { | |
1790 case K_RIGHT: c = K_LEFT; break; | |
1791 case K_S_RIGHT: c = K_S_LEFT; break; | |
1792 case K_C_RIGHT: c = K_C_LEFT; break; | |
1793 case K_LEFT: c = K_RIGHT; break; | |
1794 case K_S_LEFT: c = K_S_RIGHT; break; | |
1795 case K_C_LEFT: c = K_C_RIGHT; break; | |
1796 } | |
1797 } | |
1798 #endif | |
1799 } | |
1800 | |
1801 /* | |
1802 * Ignore got_int when CTRL-C was typed here. | |
1803 * Don't ignore it in :global, we really need to break then, e.g., for | |
1804 * ":g/pat/normal /pat" (without the <CR>). | |
1805 * Don't ignore it for the input() function. | |
1806 */ | |
1807 if ((c == Ctrl_C | |
1808 #ifdef UNIX | |
1809 || c == intr_char | |
1810 #endif | |
1811 ) | |
1812 #if defined(FEAT_EVAL) || defined(FEAT_CRYPT) | |
1813 && firstc != '@' | |
1814 #endif | |
1815 #ifdef FEAT_EVAL | |
1816 && !break_ctrl_c | |
1817 #endif | |
1818 && !global_busy) | |
1819 got_int = FALSE; | |
1820 | |
17652
9efb4dda9720
patch 8.1.1823: command line history code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17588
diff
changeset
|
1821 // free old command line when finished moving around in the history |
9efb4dda9720
patch 8.1.1823: command line history code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17588
diff
changeset
|
1822 // list |
7 | 1823 if (lookfor != NULL |
180 | 1824 && c != K_S_DOWN && c != K_S_UP |
230 | 1825 && c != K_DOWN && c != K_UP |
7 | 1826 && c != K_PAGEDOWN && c != K_PAGEUP |
1827 && c != K_KPAGEDOWN && c != K_KPAGEUP | |
230 | 1828 && c != K_LEFT && c != K_RIGHT |
7 | 1829 && (xpc.xp_numfiles > 0 || (c != Ctrl_P && c != Ctrl_N))) |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13142
diff
changeset
|
1830 VIM_CLEAR(lookfor); |
7 | 1831 |
1832 /* | |
1718 | 1833 * When there are matching completions to select <S-Tab> works like |
1834 * CTRL-P (unless 'wc' is <S-Tab>). | |
7 | 1835 */ |
1718 | 1836 if (c != p_wc && c == K_S_TAB && xpc.xp_numfiles > 0) |
7 | 1837 c = Ctrl_P; |
1838 | |
1839 #ifdef FEAT_WILDMENU | |
22075
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22061
diff
changeset
|
1840 c = wildmenu_translate_key(&ccline, c, &xpc, did_wild_list); |
7 | 1841 #endif |
1842 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1843 // free expanded names when finished walking through matches |
7 | 1844 if (xpc.xp_numfiles != -1 |
1845 && !(c == p_wc && KeyTyped) && c != p_wcm | |
1846 && c != Ctrl_N && c != Ctrl_P && c != Ctrl_A | |
1847 && c != Ctrl_L) | |
1848 { | |
1849 (void)ExpandOne(&xpc, NULL, NULL, 0, WILD_FREE); | |
1850 did_wild_list = FALSE; | |
1851 #ifdef FEAT_WILDMENU | |
230 | 1852 if (!p_wmnu || (c != K_UP && c != K_DOWN)) |
7 | 1853 #endif |
1854 xpc.xp_context = EXPAND_NOTHING; | |
1855 wim_index = 0; | |
1856 #ifdef FEAT_WILDMENU | |
22075
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22061
diff
changeset
|
1857 wildmenu_cleanup(&ccline); |
7 | 1858 #endif |
1859 } | |
1860 | |
1861 #ifdef FEAT_WILDMENU | |
22075
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22061
diff
changeset
|
1862 c = wildmenu_process_key(&ccline, c, &xpc); |
eb878f85967e
patch 8.2.1587: loop for handling keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22061
diff
changeset
|
1863 #endif |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1864 |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1865 // CTRL-\ CTRL-N goes to Normal mode, CTRL-\ CTRL-G goes to Insert |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1866 // mode when 'insertmode' is set, CTRL-\ e prompts for an expression. |
7 | 1867 if (c == Ctrl_BSL) |
1868 { | |
22169
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1869 res = cmdline_handle_backslash_key(c, &gotesc); |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1870 if (res == CMDLINE_CHANGED) |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1871 goto cmdline_changed; |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1872 else if (res == CMDLINE_NOT_CHANGED) |
2636 | 1873 goto cmdline_not_changed; |
22169
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1874 else if (res == GOTO_NORMAL_MODE) |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1875 goto returncmd; // back to cmd mode |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1876 c = Ctrl_BSL; // backslash key not processed by |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1877 // cmdline_handle_backslash_key() |
7 | 1878 } |
1879 | |
1880 #ifdef FEAT_CMDWIN | |
1881 if (c == cedit_key || c == K_CMDWIN) | |
1882 { | |
18793
7a1606ceec7d
patch 8.1.2385: opening cmdline window with feedkeys() does not work
Bram Moolenaar <Bram@vim.org>
parents:
18779
diff
changeset
|
1883 // TODO: why is ex_normal_busy checked here? |
7a1606ceec7d
patch 8.1.2385: opening cmdline window with feedkeys() does not work
Bram Moolenaar <Bram@vim.org>
parents:
18779
diff
changeset
|
1884 if ((c == K_CMDWIN || ex_normal_busy == 0) && got_int == FALSE) |
6211 | 1885 { |
1886 /* | |
1887 * Open a window to edit the command line (and history). | |
1888 */ | |
11321
f57dce6b934b
patch 8.0.0546: swap file exists briefly when opening the command window
Christian Brabandt <cb@256bit.org>
parents:
11285
diff
changeset
|
1889 c = open_cmdwin(); |
6211 | 1890 some_key_typed = TRUE; |
1891 } | |
7 | 1892 } |
1893 # ifdef FEAT_DIGRAPHS | |
1894 else | |
1895 # endif | |
1896 #endif | |
1897 #ifdef FEAT_DIGRAPHS | |
1898 c = do_digraph(c); | |
1899 #endif | |
1900 | |
1901 if (c == '\n' || c == '\r' || c == K_KENTER || (c == ESC | |
1902 && (!KeyTyped || vim_strchr(p_cpo, CPO_ESC) != NULL))) | |
1903 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1904 // In Ex mode a backslash escapes a newline. |
168 | 1905 if (exmode_active |
1906 && c != ESC | |
1318 | 1907 && ccline.cmdpos == ccline.cmdlen |
168 | 1908 && ccline.cmdpos > 0 |
1909 && ccline.cmdbuff[ccline.cmdpos - 1] == '\\') | |
1910 { | |
1911 if (c == K_KENTER) | |
1912 c = '\n'; | |
1913 } | |
1914 else | |
7 | 1915 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1916 gotesc = FALSE; // Might have typed ESC previously, don't |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1917 // truncate the cmdline now. |
168 | 1918 if (ccheck_abbr(c + ABBR_OFF)) |
1919 goto cmdline_changed; | |
1920 if (!cmd_silent) | |
1921 { | |
1922 windgoto(msg_row, 0); | |
1923 out_flush(); | |
1924 } | |
1925 break; | |
7 | 1926 } |
1927 } | |
1928 | |
22169
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1929 // Completion for 'wildchar' or 'wildcharm' key. |
7 | 1930 if ((c == p_wc && !gotesc && KeyTyped) || c == p_wcm) |
1931 { | |
22169
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1932 res = cmdline_wildchar_complete(c, firstc != '@', &did_wild_list, |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1933 &wim_index, &xpc, &gotesc); |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1934 if (res == CMDLINE_CHANGED) |
7 | 1935 goto cmdline_changed; |
1936 } | |
1937 | |
1938 gotesc = FALSE; | |
1939 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1940 // <S-Tab> goes to last match, in a clumsy way |
7 | 1941 if (c == K_S_TAB && KeyTyped) |
1942 { | |
3961 | 1943 if (nextwild(&xpc, WILD_EXPAND_KEEP, 0, firstc != '@') == OK |
1944 && nextwild(&xpc, WILD_PREV, 0, firstc != '@') == OK | |
1945 && nextwild(&xpc, WILD_PREV, 0, firstc != '@') == OK) | |
7 | 1946 goto cmdline_changed; |
1947 } | |
1948 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1949 if (c == NUL || c == K_ZERO) // NUL is stored as NL |
7 | 1950 c = NL; |
1951 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1952 do_abbr = TRUE; // default: check for abbreviation |
7 | 1953 |
1954 /* | |
1955 * Big switch for a typed command line character. | |
1956 */ | |
1957 switch (c) | |
1958 { | |
1959 case K_BS: | |
1960 case Ctrl_H: | |
1961 case K_DEL: | |
1962 case K_KDEL: | |
1963 case Ctrl_W: | |
22145
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1964 res = cmdline_erase_chars(c, indent |
9971
98b39d2eb895
commit https://github.com/vim/vim/commit/4d6f32cbfbaf324ac4a25c0206a5db0e9f7a48f7
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1965 #ifdef FEAT_SEARCH_EXTRA |
22145
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1966 , &is_state |
7 | 1967 #endif |
22145
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1968 ); |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1969 if (res == CMDLINE_NOT_CHANGED) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1970 goto cmdline_not_changed; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1971 else if (res == GOTO_NORMAL_MODE) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1972 goto returncmd; // back to cmd mode |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1973 goto cmdline_changed; |
7 | 1974 |
1975 case K_INS: | |
1976 case K_KINS: | |
1977 ccline.overstrike = !ccline.overstrike; | |
1978 #ifdef CURSOR_SHAPE | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1979 ui_cursor_shape(); // may show different cursor shape |
7 | 1980 #endif |
1981 goto cmdline_not_changed; | |
1982 | |
1983 case Ctrl_HAT: | |
22145
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1984 cmdline_toggle_langmap(b_im_ptr); |
7 | 1985 goto cmdline_not_changed; |
1986 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1987 // case '@': only in very old vi |
7 | 1988 case Ctrl_U: |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1989 // delete all characters left of the cursor |
7 | 1990 j = ccline.cmdpos; |
1991 ccline.cmdlen -= j; | |
1992 i = ccline.cmdpos = 0; | |
1993 while (i < ccline.cmdlen) | |
1994 ccline.cmdbuff[i++] = ccline.cmdbuff[j++]; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1995 // Truncate at the end, required for multi-byte chars. |
7 | 1996 ccline.cmdbuff[ccline.cmdlen] = NUL; |
9971
98b39d2eb895
commit https://github.com/vim/vim/commit/4d6f32cbfbaf324ac4a25c0206a5db0e9f7a48f7
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1997 #ifdef FEAT_SEARCH_EXTRA |
98b39d2eb895
commit https://github.com/vim/vim/commit/4d6f32cbfbaf324ac4a25c0206a5db0e9f7a48f7
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1998 if (ccline.cmdlen == 0) |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
1999 is_state.search_start = is_state.save_cursor; |
9971
98b39d2eb895
commit https://github.com/vim/vim/commit/4d6f32cbfbaf324ac4a25c0206a5db0e9f7a48f7
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
2000 #endif |
7 | 2001 redrawcmd(); |
2002 goto cmdline_changed; | |
2003 | |
2004 #ifdef FEAT_CLIPBOARD | |
2005 case Ctrl_Y: | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2006 // Copy the modeless selection, if there is one. |
7 | 2007 if (clip_star.state != SELECT_CLEARED) |
2008 { | |
2009 if (clip_star.state == SELECT_DONE) | |
2010 clip_copy_modeless_selection(TRUE); | |
2011 goto cmdline_not_changed; | |
2012 } | |
2013 break; | |
2014 #endif | |
2015 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2016 case ESC: // get here if p_wc != ESC or when ESC typed twice |
7 | 2017 case Ctrl_C: |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2018 // In exmode it doesn't make sense to return. Except when |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2019 // ":normal" runs out of characters. |
161 | 2020 if (exmode_active |
7850
10f17a228661
commit https://github.com/vim/vim/commit/e2c3810c2ae290bbc2cba18eb47cc2d44e4b9797
Christian Brabandt <cb@256bit.org>
parents:
7819
diff
changeset
|
2021 && (ex_normal_busy == 0 || typebuf.tb_len > 0)) |
7 | 2022 goto cmdline_not_changed; |
2023 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2024 gotesc = TRUE; // will free ccline.cmdbuff after |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2025 // putting it in history |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2026 goto returncmd; // back to cmd mode |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2027 |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2028 case Ctrl_R: // insert register |
22145
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
2029 res = cmdline_insert_reg(&gotesc); |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
2030 if (res == CMDLINE_NOT_CHANGED) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
2031 goto cmdline_not_changed; |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
2032 else if (res == GOTO_NORMAL_MODE) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
2033 goto returncmd; |
7 | 2034 goto cmdline_changed; |
2035 | |
2036 case Ctrl_D: | |
2037 if (showmatches(&xpc, FALSE) == EXPAND_NOTHING) | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2038 break; // Use ^D as normal char instead |
7 | 2039 |
2040 redrawcmd(); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2041 continue; // don't do incremental search now |
7 | 2042 |
2043 case K_RIGHT: | |
2044 case K_S_RIGHT: | |
2045 case K_C_RIGHT: | |
2046 do | |
2047 { | |
2048 if (ccline.cmdpos >= ccline.cmdlen) | |
2049 break; | |
2050 i = cmdline_charsize(ccline.cmdpos); | |
2051 if (KeyTyped && ccline.cmdspos + i >= Columns * Rows) | |
2052 break; | |
2053 ccline.cmdspos += i; | |
2054 if (has_mbyte) | |
474 | 2055 ccline.cmdpos += (*mb_ptr2len)(ccline.cmdbuff |
7 | 2056 + ccline.cmdpos); |
2057 else | |
2058 ++ccline.cmdpos; | |
2059 } | |
180 | 2060 while ((c == K_S_RIGHT || c == K_C_RIGHT |
2061 || (mod_mask & (MOD_MASK_SHIFT|MOD_MASK_CTRL))) | |
7 | 2062 && ccline.cmdbuff[ccline.cmdpos] != ' '); |
2063 if (has_mbyte) | |
2064 set_cmdspos_cursor(); | |
2065 goto cmdline_not_changed; | |
2066 | |
2067 case K_LEFT: | |
2068 case K_S_LEFT: | |
2069 case K_C_LEFT: | |
1456 | 2070 if (ccline.cmdpos == 0) |
2071 goto cmdline_not_changed; | |
7 | 2072 do |
2073 { | |
2074 --ccline.cmdpos; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2075 if (has_mbyte) // move to first byte of char |
7 | 2076 ccline.cmdpos -= (*mb_head_off)(ccline.cmdbuff, |
2077 ccline.cmdbuff + ccline.cmdpos); | |
2078 ccline.cmdspos -= cmdline_charsize(ccline.cmdpos); | |
2079 } | |
1456 | 2080 while (ccline.cmdpos > 0 |
2081 && (c == K_S_LEFT || c == K_C_LEFT | |
180 | 2082 || (mod_mask & (MOD_MASK_SHIFT|MOD_MASK_CTRL))) |
7 | 2083 && ccline.cmdbuff[ccline.cmdpos - 1] != ' '); |
2084 if (has_mbyte) | |
2085 set_cmdspos_cursor(); | |
2086 goto cmdline_not_changed; | |
2087 | |
2088 case K_IGNORE: | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2089 // Ignore mouse event or open_cmdwin() result. |
1472 | 2090 goto cmdline_not_changed; |
7 | 2091 |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
2092 #ifdef FEAT_GUI_MSWIN |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2093 // On MS-Windows ignore <M-F4>, we get it when closing the window |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2094 // was cancelled. |
625 | 2095 case K_F4: |
2096 if (mod_mask == MOD_MASK_ALT) | |
2097 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2098 redrawcmd(); // somehow the cmdline is cleared |
625 | 2099 goto cmdline_not_changed; |
2100 } | |
2101 break; | |
2102 #endif | |
2103 | |
7 | 2104 case K_MIDDLEDRAG: |
2105 case K_MIDDLERELEASE: | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2106 goto cmdline_not_changed; // Ignore mouse |
7 | 2107 |
2108 case K_MIDDLEMOUSE: | |
2109 # ifdef FEAT_GUI | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2110 // When GUI is active, also paste when 'mouse' is empty |
7 | 2111 if (!gui.in_use) |
2112 # endif | |
2113 if (!mouse_has(MOUSE_COMMAND)) | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2114 goto cmdline_not_changed; // Ignore mouse |
692 | 2115 # ifdef FEAT_CLIPBOARD |
7 | 2116 if (clip_star.available) |
1015 | 2117 cmdline_paste('*', TRUE, TRUE); |
7 | 2118 else |
692 | 2119 # endif |
1015 | 2120 cmdline_paste(0, TRUE, TRUE); |
7 | 2121 redrawcmd(); |
2122 goto cmdline_changed; | |
2123 | |
692 | 2124 # ifdef FEAT_DND |
7 | 2125 case K_DROP: |
1015 | 2126 cmdline_paste('~', TRUE, FALSE); |
7 | 2127 redrawcmd(); |
2128 goto cmdline_changed; | |
692 | 2129 # endif |
7 | 2130 |
2131 case K_LEFTDRAG: | |
2132 case K_LEFTRELEASE: | |
2133 case K_RIGHTDRAG: | |
2134 case K_RIGHTRELEASE: | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2135 // Ignore drag and release events when the button-down wasn't |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2136 // seen before. |
7 | 2137 if (ignore_drag_release) |
2138 goto cmdline_not_changed; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2139 // FALLTHROUGH |
7 | 2140 case K_LEFTMOUSE: |
2141 case K_RIGHTMOUSE: | |
22145
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
2142 cmdline_left_right_mouse(c, &ignore_drag_release); |
7 | 2143 goto cmdline_not_changed; |
2144 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2145 // Mouse scroll wheel: ignored here |
7 | 2146 case K_MOUSEDOWN: |
2147 case K_MOUSEUP: | |
2409
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
2148 case K_MOUSELEFT: |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
2149 case K_MOUSERIGHT: |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2150 // Alternate buttons ignored here |
7 | 2151 case K_X1MOUSE: |
2152 case K_X1DRAG: | |
2153 case K_X1RELEASE: | |
2154 case K_X2MOUSE: | |
2155 case K_X2DRAG: | |
2156 case K_X2RELEASE: | |
12865
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12855
diff
changeset
|
2157 case K_MOUSEMOVE: |
7 | 2158 goto cmdline_not_changed; |
2159 | |
2160 #ifdef FEAT_GUI | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2161 case K_LEFTMOUSE_NM: // mousefocus click, ignored |
7 | 2162 case K_LEFTRELEASE_NM: |
2163 goto cmdline_not_changed; | |
2164 | |
2165 case K_VER_SCROLLBAR: | |
540 | 2166 if (msg_scrolled == 0) |
7 | 2167 { |
2168 gui_do_scroll(); | |
2169 redrawcmd(); | |
2170 } | |
2171 goto cmdline_not_changed; | |
2172 | |
2173 case K_HOR_SCROLLBAR: | |
540 | 2174 if (msg_scrolled == 0) |
7 | 2175 { |
2409
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
2176 gui_do_horiz_scroll(scrollbar_value, FALSE); |
7 | 2177 redrawcmd(); |
2178 } | |
2179 goto cmdline_not_changed; | |
2180 #endif | |
692 | 2181 #ifdef FEAT_GUI_TABLINE |
2182 case K_TABLINE: | |
2183 case K_TABMENU: | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2184 // Don't want to change any tabs here. Make sure the same tab |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2185 // is still selected. |
692 | 2186 if (gui_use_tabline()) |
2187 gui_mch_set_curtab(tabpage_index(curtab)); | |
2188 goto cmdline_not_changed; | |
2189 #endif | |
2190 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2191 case K_SELECT: // end of Select mode mapping - ignore |
7 | 2192 goto cmdline_not_changed; |
2193 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2194 case Ctrl_B: // begin of command line |
7 | 2195 case K_HOME: |
2196 case K_KHOME: | |
2197 case K_S_HOME: | |
2198 case K_C_HOME: | |
2199 ccline.cmdpos = 0; | |
2200 set_cmdspos(); | |
2201 goto cmdline_not_changed; | |
2202 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2203 case Ctrl_E: // end of command line |
7 | 2204 case K_END: |
2205 case K_KEND: | |
2206 case K_S_END: | |
2207 case K_C_END: | |
2208 ccline.cmdpos = ccline.cmdlen; | |
2209 set_cmdspos_cursor(); | |
2210 goto cmdline_not_changed; | |
2211 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2212 case Ctrl_A: // all matches |
3961 | 2213 if (nextwild(&xpc, WILD_ALL, 0, firstc != '@') == FAIL) |
7 | 2214 break; |
2215 goto cmdline_changed; | |
2216 | |
772 | 2217 case Ctrl_L: |
2218 #ifdef FEAT_SEARCH_EXTRA | |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
2219 if (may_add_char_to_search(firstc, &c, &is_state) == OK) |
772 | 2220 goto cmdline_not_changed; |
2221 #endif | |
2222 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2223 // completion: longest common part |
3961 | 2224 if (nextwild(&xpc, WILD_LONGEST, 0, firstc != '@') == FAIL) |
7 | 2225 break; |
2226 goto cmdline_changed; | |
2227 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2228 case Ctrl_N: // next match |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2229 case Ctrl_P: // previous match |
9976
e448370630b2
commit https://github.com/vim/vim/commit/7df0f6313a46b80d760c9a80241922544333351c
Christian Brabandt <cb@256bit.org>
parents:
9971
diff
changeset
|
2230 if (xpc.xp_numfiles > 0) |
7 | 2231 { |
3961 | 2232 if (nextwild(&xpc, (c == Ctrl_P) ? WILD_PREV : WILD_NEXT, |
2233 0, firstc != '@') == FAIL) | |
7 | 2234 break; |
9990
6a1793d9c895
commit https://github.com/vim/vim/commit/1195669f9e434fa9ab8b57ee9470bf951e4990b8
Christian Brabandt <cb@256bit.org>
parents:
9976
diff
changeset
|
2235 goto cmdline_not_changed; |
7 | 2236 } |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2237 // FALLTHROUGH |
7 | 2238 case K_UP: |
2239 case K_DOWN: | |
2240 case K_S_UP: | |
2241 case K_S_DOWN: | |
2242 case K_PAGEUP: | |
2243 case K_KPAGEUP: | |
2244 case K_PAGEDOWN: | |
2245 case K_KPAGEDOWN: | |
22145
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
2246 res = cmdline_browse_history(c, firstc, &lookfor, histype, |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
2247 &hiscnt, &xpc); |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
2248 if (res == CMDLINE_CHANGED) |
7 | 2249 goto cmdline_changed; |
22145
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
2250 else if (res == GOTO_NORMAL_MODE) |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
2251 goto returncmd; |
9990
6a1793d9c895
commit https://github.com/vim/vim/commit/1195669f9e434fa9ab8b57ee9470bf951e4990b8
Christian Brabandt <cb@256bit.org>
parents:
9976
diff
changeset
|
2252 goto cmdline_not_changed; |
6a1793d9c895
commit https://github.com/vim/vim/commit/1195669f9e434fa9ab8b57ee9470bf951e4990b8
Christian Brabandt <cb@256bit.org>
parents:
9976
diff
changeset
|
2253 |
10094
61dc69646af6
commit https://github.com/vim/vim/commit/349e7d94e6bbb253bb87adad9039f095128ab543
Christian Brabandt <cb@256bit.org>
parents:
10082
diff
changeset
|
2254 #ifdef FEAT_SEARCH_EXTRA |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2255 case Ctrl_G: // next match |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2256 case Ctrl_T: // previous match |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
2257 if (may_adjust_incsearch_highlighting( |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
2258 firstc, count, &is_state, c) == FAIL) |
10094
61dc69646af6
commit https://github.com/vim/vim/commit/349e7d94e6bbb253bb87adad9039f095128ab543
Christian Brabandt <cb@256bit.org>
parents:
10082
diff
changeset
|
2259 goto cmdline_not_changed; |
61dc69646af6
commit https://github.com/vim/vim/commit/349e7d94e6bbb253bb87adad9039f095128ab543
Christian Brabandt <cb@256bit.org>
parents:
10082
diff
changeset
|
2260 break; |
7 | 2261 #endif |
2262 | |
2263 case Ctrl_V: | |
2264 case Ctrl_Q: | |
2265 { | |
18717
14d2a210fab1
patch 8.1.2350: other text for CTRL-V in Insert mode with modifyOtherKeys
Bram Moolenaar <Bram@vim.org>
parents:
18709
diff
changeset
|
2266 ignore_drag_release = TRUE; |
14d2a210fab1
patch 8.1.2350: other text for CTRL-V in Insert mode with modifyOtherKeys
Bram Moolenaar <Bram@vim.org>
parents:
18709
diff
changeset
|
2267 putcmdline('^', TRUE); |
23076
5fbac68bda23
patch 8.2.2084: CTRL-V U doesn't work to enter a Unicode character
Bram Moolenaar <Bram@vim.org>
parents:
22872
diff
changeset
|
2268 |
5fbac68bda23
patch 8.2.2084: CTRL-V U doesn't work to enter a Unicode character
Bram Moolenaar <Bram@vim.org>
parents:
22872
diff
changeset
|
2269 // Get next (two) character(s). Do not change any |
5fbac68bda23
patch 8.2.2084: CTRL-V U doesn't work to enter a Unicode character
Bram Moolenaar <Bram@vim.org>
parents:
22872
diff
changeset
|
2270 // modifyOtherKeys ESC sequence to a normal key for |
5fbac68bda23
patch 8.2.2084: CTRL-V U doesn't work to enter a Unicode character
Bram Moolenaar <Bram@vim.org>
parents:
22872
diff
changeset
|
2271 // CTRL-SHIFT-V. |
5fbac68bda23
patch 8.2.2084: CTRL-V U doesn't work to enter a Unicode character
Bram Moolenaar <Bram@vim.org>
parents:
22872
diff
changeset
|
2272 c = get_literal(mod_mask & MOD_MASK_SHIFT); |
5fbac68bda23
patch 8.2.2084: CTRL-V U doesn't work to enter a Unicode character
Bram Moolenaar <Bram@vim.org>
parents:
22872
diff
changeset
|
2273 |
18717
14d2a210fab1
patch 8.1.2350: other text for CTRL-V in Insert mode with modifyOtherKeys
Bram Moolenaar <Bram@vim.org>
parents:
18709
diff
changeset
|
2274 do_abbr = FALSE; // don't do abbreviation now |
14d2a210fab1
patch 8.1.2350: other text for CTRL-V in Insert mode with modifyOtherKeys
Bram Moolenaar <Bram@vim.org>
parents:
18709
diff
changeset
|
2275 extra_char = NUL; |
14d2a210fab1
patch 8.1.2350: other text for CTRL-V in Insert mode with modifyOtherKeys
Bram Moolenaar <Bram@vim.org>
parents:
18709
diff
changeset
|
2276 // may need to remove ^ when composing char was typed |
14d2a210fab1
patch 8.1.2350: other text for CTRL-V in Insert mode with modifyOtherKeys
Bram Moolenaar <Bram@vim.org>
parents:
18709
diff
changeset
|
2277 if (enc_utf8 && utf_iscomposing(c) && !cmd_silent) |
14d2a210fab1
patch 8.1.2350: other text for CTRL-V in Insert mode with modifyOtherKeys
Bram Moolenaar <Bram@vim.org>
parents:
18709
diff
changeset
|
2278 { |
14d2a210fab1
patch 8.1.2350: other text for CTRL-V in Insert mode with modifyOtherKeys
Bram Moolenaar <Bram@vim.org>
parents:
18709
diff
changeset
|
2279 draw_cmdline(ccline.cmdpos, |
14d2a210fab1
patch 8.1.2350: other text for CTRL-V in Insert mode with modifyOtherKeys
Bram Moolenaar <Bram@vim.org>
parents:
18709
diff
changeset
|
2280 ccline.cmdlen - ccline.cmdpos); |
14d2a210fab1
patch 8.1.2350: other text for CTRL-V in Insert mode with modifyOtherKeys
Bram Moolenaar <Bram@vim.org>
parents:
18709
diff
changeset
|
2281 msg_putchar(' '); |
14d2a210fab1
patch 8.1.2350: other text for CTRL-V in Insert mode with modifyOtherKeys
Bram Moolenaar <Bram@vim.org>
parents:
18709
diff
changeset
|
2282 cursorcmd(); |
14d2a210fab1
patch 8.1.2350: other text for CTRL-V in Insert mode with modifyOtherKeys
Bram Moolenaar <Bram@vim.org>
parents:
18709
diff
changeset
|
2283 } |
7 | 2284 } |
18717
14d2a210fab1
patch 8.1.2350: other text for CTRL-V in Insert mode with modifyOtherKeys
Bram Moolenaar <Bram@vim.org>
parents:
18709
diff
changeset
|
2285 |
7 | 2286 break; |
2287 | |
2288 #ifdef FEAT_DIGRAPHS | |
2289 case Ctrl_K: | |
2290 ignore_drag_release = TRUE; | |
2291 putcmdline('?', TRUE); | |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18251
diff
changeset
|
2292 # ifdef USE_ON_FLY_SCROLL |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2293 dont_scroll = TRUE; // disallow scrolling here |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18251
diff
changeset
|
2294 # endif |
7 | 2295 c = get_digraph(TRUE); |
11664
e3bfe624ba0a
patch 8.0.0714: when a timer causes a command line redraw " goes missing
Christian Brabandt <cb@256bit.org>
parents:
11647
diff
changeset
|
2296 extra_char = NUL; |
7 | 2297 if (c != NUL) |
2298 break; | |
2299 | |
2300 redrawcmd(); | |
2301 goto cmdline_not_changed; | |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18251
diff
changeset
|
2302 #endif // FEAT_DIGRAPHS |
7 | 2303 |
2304 #ifdef FEAT_RIGHTLEFT | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2305 case Ctrl__: // CTRL-_: switch language mode |
7 | 2306 if (!p_ari) |
2307 break; | |
15850
a6ca8cf07a98
patch 8.1.0932: Farsi support is outdated and unused
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
2308 cmd_hkmap = !cmd_hkmap; |
7 | 2309 goto cmdline_not_changed; |
2310 #endif | |
2311 | |
10676
b8c04c007d39
patch 8.0.0228: pasting in xterm on the command line has PasteStart
Christian Brabandt <cb@256bit.org>
parents:
10565
diff
changeset
|
2312 case K_PS: |
b8c04c007d39
patch 8.0.0228: pasting in xterm on the command line has PasteStart
Christian Brabandt <cb@256bit.org>
parents:
10565
diff
changeset
|
2313 bracketed_paste(PASTE_CMDLINE, FALSE, NULL); |
b8c04c007d39
patch 8.0.0228: pasting in xterm on the command line has PasteStart
Christian Brabandt <cb@256bit.org>
parents:
10565
diff
changeset
|
2314 goto cmdline_changed; |
b8c04c007d39
patch 8.0.0228: pasting in xterm on the command line has PasteStart
Christian Brabandt <cb@256bit.org>
parents:
10565
diff
changeset
|
2315 |
7 | 2316 default: |
2317 #ifdef UNIX | |
2318 if (c == intr_char) | |
2319 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2320 gotesc = TRUE; // will free ccline.cmdbuff after |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2321 // putting it in history |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2322 goto returncmd; // back to Normal mode |
7 | 2323 } |
2324 #endif | |
2325 /* | |
2326 * Normal character with no special meaning. Just set mod_mask | |
2327 * to 0x0 so that typing Shift-Space in the GUI doesn't enter | |
2328 * the string <S-Space>. This should only happen after ^V. | |
2329 */ | |
2330 if (!IS_SPECIAL(c)) | |
2331 mod_mask = 0x0; | |
2332 break; | |
2333 } | |
2334 /* | |
2335 * End of switch on command line character. | |
2336 * We come here if we have a normal character. | |
2337 */ | |
2338 | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15575
diff
changeset
|
2339 if (do_abbr && (IS_SPECIAL(c) || !vim_iswordc(c)) |
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15575
diff
changeset
|
2340 && (ccheck_abbr( |
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15575
diff
changeset
|
2341 // Add ABBR_OFF for characters above 0x100, this is |
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15575
diff
changeset
|
2342 // what check_abbr() expects. |
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15575
diff
changeset
|
2343 (has_mbyte && c >= 0x100) ? (c + ABBR_OFF) : c) |
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15575
diff
changeset
|
2344 || c == Ctrl_RSB)) |
7 | 2345 goto cmdline_changed; |
2346 | |
2347 /* | |
2348 * put the character in the command line | |
2349 */ | |
2350 if (IS_SPECIAL(c) || mod_mask != 0) | |
2351 put_on_cmdline(get_special_key_name(c, mod_mask), -1, TRUE); | |
2352 else | |
2353 { | |
2354 if (has_mbyte) | |
2355 { | |
2356 j = (*mb_char2bytes)(c, IObuff); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2357 IObuff[j] = NUL; // exclude composing chars |
7 | 2358 put_on_cmdline(IObuff, j, TRUE); |
2359 } | |
2360 else | |
2361 { | |
2362 IObuff[0] = c; | |
2363 put_on_cmdline(IObuff, 1, TRUE); | |
2364 } | |
2365 } | |
2366 goto cmdline_changed; | |
2367 | |
2368 /* | |
2369 * This part implements incremental searches for "/" and "?" | |
2370 * Jump to cmdline_not_changed when a character has been read but the command | |
2371 * line did not change. Then we only search and redraw if something changed in | |
2372 * the past. | |
2373 * Jump to cmdline_changed when the command line did change. | |
2374 * (Sorry for the goto's, I know it is ugly). | |
2375 */ | |
2376 cmdline_not_changed: | |
2377 #ifdef FEAT_SEARCH_EXTRA | |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
2378 if (!is_state.incsearch_postponed) |
7 | 2379 continue; |
2380 #endif | |
2381 | |
2382 cmdline_changed: | |
22872
5a7db84713dc
patch 8.2.1983: ml_get error when using <Cmd> to open a terminal
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
2383 #ifdef FEAT_SEARCH_EXTRA |
5a7db84713dc
patch 8.2.1983: ml_get error when using <Cmd> to open a terminal
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
2384 // If the window changed incremental search state is not valid. |
5a7db84713dc
patch 8.2.1983: ml_get error when using <Cmd> to open a terminal
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
2385 if (is_state.winid != curwin->w_id) |
5a7db84713dc
patch 8.2.1983: ml_get error when using <Cmd> to open a terminal
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
2386 init_incsearch_state(&is_state); |
5a7db84713dc
patch 8.2.1983: ml_get error when using <Cmd> to open a terminal
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
2387 #endif |
24628
447426630e44
patch 8.2.2853: window is not updated after using <Cmd> mapping
Bram Moolenaar <Bram@vim.org>
parents:
24624
diff
changeset
|
2388 if (trigger_cmdlinechanged) |
447426630e44
patch 8.2.2853: window is not updated after using <Cmd> mapping
Bram Moolenaar <Bram@vim.org>
parents:
24624
diff
changeset
|
2389 // Trigger CmdlineChanged autocommands. |
447426630e44
patch 8.2.2853: window is not updated after using <Cmd> mapping
Bram Moolenaar <Bram@vim.org>
parents:
24624
diff
changeset
|
2390 trigger_cmd_autocmd(cmdline_type, EVENT_CMDLINECHANGED); |
13142
59a16624400a
patch 8.0.1445: cannot act on edits in the command line
Christian Brabandt <cb@256bit.org>
parents:
13107
diff
changeset
|
2391 |
7 | 2392 #ifdef FEAT_SEARCH_EXTRA |
22061
d6120c97f57c
patch 8.2.1580: wildmenu does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
21883
diff
changeset
|
2393 if (xpc.xp_context == EXPAND_NOTHING) |
d6120c97f57c
patch 8.2.1580: wildmenu does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
21883
diff
changeset
|
2394 may_do_incsearch_highlighting(firstc, count, &is_state); |
7 | 2395 #endif |
2396 | |
2397 #ifdef FEAT_RIGHTLEFT | |
2398 if (cmdmsg_rl | |
2399 # ifdef FEAT_ARABIC | |
17155
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2400 || (p_arshape && !p_tbidi |
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2401 && cmdline_has_arabic(0, ccline.cmdlen)) |
7 | 2402 # endif |
2403 ) | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2404 // Always redraw the whole command line to fix shaping and |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2405 // right-left typing. Not efficient, but it works. |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2406 // Do it only when there are no characters left to read |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2407 // to avoid useless intermediate redraws. |
3374 | 2408 if (vpeekc() == NUL) |
2409 redrawcmd(); | |
7 | 2410 #endif |
2411 } | |
2412 | |
2413 returncmd: | |
2414 | |
2415 #ifdef FEAT_RIGHTLEFT | |
2416 cmdmsg_rl = FALSE; | |
2417 #endif | |
2418 | |
2419 ExpandCleanup(&xpc); | |
1718 | 2420 ccline.xpc = NULL; |
7 | 2421 |
2422 #ifdef FEAT_SEARCH_EXTRA | |
14528
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
2423 finish_incsearch_highlighting(gotesc, &is_state, FALSE); |
7 | 2424 #endif |
2425 | |
2426 if (ccline.cmdbuff != NULL) | |
2427 { | |
2428 /* | |
2429 * Put line in history buffer (":" and "=" only when it was typed). | |
2430 */ | |
2431 if (ccline.cmdlen && firstc != NUL | |
2432 && (some_key_typed || histype == HIST_SEARCH)) | |
2433 { | |
2434 add_to_history(histype, ccline.cmdbuff, TRUE, | |
2435 histype == HIST_SEARCH ? firstc : NUL); | |
2436 if (firstc == ':') | |
2437 { | |
2438 vim_free(new_last_cmdline); | |
2439 new_last_cmdline = vim_strsave(ccline.cmdbuff); | |
2440 } | |
2441 } | |
2442 | |
12664
42cd1f315e8b
patch 8.0.1210: CTRL-G and CTRL-T are ignored with typeahead
Christian Brabandt <cb@256bit.org>
parents:
12656
diff
changeset
|
2443 if (gotesc) |
42cd1f315e8b
patch 8.0.1210: CTRL-G and CTRL-T are ignored with typeahead
Christian Brabandt <cb@256bit.org>
parents:
12656
diff
changeset
|
2444 abandon_cmdline(); |
7 | 2445 } |
2446 | |
2447 /* | |
2448 * If the screen was shifted up, redraw the whole screen (later). | |
2449 * If the line is too long, clear it, so ruler and shown command do | |
2450 * not get printed in the middle of it. | |
2451 */ | |
2452 msg_check(); | |
2453 msg_scroll = save_msg_scroll; | |
2454 redir_off = FALSE; | |
2455 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2456 // When the command line was typed, no need for a wait-return prompt. |
7 | 2457 if (some_key_typed) |
2458 need_wait_return = FALSE; | |
2459 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2460 // Trigger CmdlineLeave autocommands. |
12656
0a9dacb8826a
patch 8.0.1206: no autocmd for entering or leaving the command line
Christian Brabandt <cb@256bit.org>
parents:
12529
diff
changeset
|
2461 trigger_cmd_autocmd(cmdline_type, EVENT_CMDLINELEAVE); |
0a9dacb8826a
patch 8.0.1206: no autocmd for entering or leaving the command line
Christian Brabandt <cb@256bit.org>
parents:
12529
diff
changeset
|
2462 |
7 | 2463 State = save_State; |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13256
diff
changeset
|
2464 #ifdef HAVE_INPUT_METHOD |
7 | 2465 if (b_im_ptr != NULL && *b_im_ptr != B_IMODE_LMAP) |
2466 im_save_status(b_im_ptr); | |
2467 im_set_active(FALSE); | |
2468 #endif | |
2469 setmouse(); | |
2470 #ifdef CURSOR_SHAPE | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2471 ui_cursor_shape(); // may show different cursor shape |
7 | 2472 #endif |
11163
f4d1fad4ac00
patch 8.0.0468: after aborting an Ex command g< does not work
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
2473 sb_text_end_cmdline(); |
7 | 2474 |
14854
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
2475 theend: |
95 | 2476 { |
2477 char_u *p = ccline.cmdbuff; | |
2478 | |
14854
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
2479 if (did_save_ccline) |
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
2480 restore_cmdline(&save_ccline); |
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
2481 else |
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
2482 ccline.cmdbuff = NULL; |
95 | 2483 return p; |
2484 } | |
7 | 2485 } |
2486 | |
2487 #if (defined(FEAT_CRYPT) || defined(FEAT_EVAL)) || defined(PROTO) | |
2488 /* | |
2489 * Get a command line with a prompt. | |
2490 * This is prepared to be called recursively from getcmdline() (e.g. by | |
2491 * f_input() when evaluating an expression from CTRL-R =). | |
2492 * Returns the command line in allocated memory, or NULL. | |
2493 */ | |
2494 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2495 getcmdline_prompt( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2496 int firstc, |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2497 char_u *prompt, // command line prompt |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2498 int attr, // attributes for prompt |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2499 int xp_context, // type of expansion |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2500 char_u *xp_arg) // user-defined expansion argument |
7 | 2501 { |
2502 char_u *s; | |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
2503 cmdline_info_T save_ccline; |
14854
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
2504 int did_save_ccline = FALSE; |
7 | 2505 int msg_col_save = msg_col; |
8694
f2e81ae5ab48
commit https://github.com/vim/vim/commit/6135d0d803084f6c2dd8672df1bef4c6e58f9e19
Christian Brabandt <cb@256bit.org>
parents:
8647
diff
changeset
|
2506 int msg_silent_save = msg_silent; |
7 | 2507 |
14854
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
2508 if (ccline.cmdbuff != NULL) |
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
2509 { |
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
2510 // Save the values of the current cmdline and restore them below. |
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
2511 save_cmdline(&save_ccline); |
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
2512 did_save_ccline = TRUE; |
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
2513 } |
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
2514 |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
2515 CLEAR_FIELD(ccline); |
7 | 2516 ccline.cmdprompt = prompt; |
2517 ccline.cmdattr = attr; | |
531 | 2518 # ifdef FEAT_EVAL |
2519 ccline.xp_context = xp_context; | |
2520 ccline.xp_arg = xp_arg; | |
2521 ccline.input_fn = (firstc == '@'); | |
2522 # endif | |
8694
f2e81ae5ab48
commit https://github.com/vim/vim/commit/6135d0d803084f6c2dd8672df1bef4c6e58f9e19
Christian Brabandt <cb@256bit.org>
parents:
8647
diff
changeset
|
2523 msg_silent = 0; |
14854
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
2524 s = getcmdline_int(firstc, 1L, 0, FALSE); |
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
2525 |
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
2526 if (did_save_ccline) |
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
2527 restore_cmdline(&save_ccline); |
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
2528 |
8694
f2e81ae5ab48
commit https://github.com/vim/vim/commit/6135d0d803084f6c2dd8672df1bef4c6e58f9e19
Christian Brabandt <cb@256bit.org>
parents:
8647
diff
changeset
|
2529 msg_silent = msg_silent_save; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2530 // Restore msg_col, the prompt from input() may have changed it. |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2531 // But only if called recursively and the commandline is therefore being |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2532 // restored to an old one; if not, the input() prompt stays on the screen, |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2533 // so we need its modified msg_col left intact. |
3020 | 2534 if (ccline.cmdbuff != NULL) |
2535 msg_col = msg_col_save; | |
7 | 2536 |
2537 return s; | |
2538 } | |
2539 #endif | |
2540 | |
632 | 2541 /* |
18679
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2542 * Read the 'wildmode' option, fill wim_flags[]. |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2543 */ |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2544 int |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2545 check_opt_wim(void) |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2546 { |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2547 char_u new_wim_flags[4]; |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2548 char_u *p; |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2549 int i; |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2550 int idx = 0; |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2551 |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2552 for (i = 0; i < 4; ++i) |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2553 new_wim_flags[i] = 0; |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2554 |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2555 for (p = p_wim; *p; ++p) |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2556 { |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2557 for (i = 0; ASCII_ISALPHA(p[i]); ++i) |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2558 ; |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2559 if (p[i] != NUL && p[i] != ',' && p[i] != ':') |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2560 return FAIL; |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2561 if (i == 7 && STRNCMP(p, "longest", 7) == 0) |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2562 new_wim_flags[idx] |= WIM_LONGEST; |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2563 else if (i == 4 && STRNCMP(p, "full", 4) == 0) |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2564 new_wim_flags[idx] |= WIM_FULL; |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2565 else if (i == 4 && STRNCMP(p, "list", 4) == 0) |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2566 new_wim_flags[idx] |= WIM_LIST; |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2567 else if (i == 8 && STRNCMP(p, "lastused", 8) == 0) |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2568 new_wim_flags[idx] |= WIM_BUFLASTUSED; |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2569 else |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2570 return FAIL; |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2571 p += i; |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2572 if (*p == NUL) |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2573 break; |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2574 if (*p == ',') |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2575 { |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2576 if (idx == 3) |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2577 return FAIL; |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2578 ++idx; |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2579 } |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2580 } |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2581 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2582 // fill remaining entries with last flag |
18679
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2583 while (idx < 3) |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2584 { |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2585 new_wim_flags[idx + 1] = new_wim_flags[idx]; |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2586 ++idx; |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2587 } |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2588 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2589 // only when there are no errors, wim_flags[] is changed |
18679
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2590 for (i = 0; i < 4; ++i) |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2591 wim_flags[i] = new_wim_flags[i]; |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2592 return OK; |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2593 } |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2594 |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2595 /* |
634 | 2596 * Return TRUE when the text must not be changed and we can't switch to |
20229
06a1dd50463e
patch 8.2.0670: cannot change window when evaluating 'completefunc'
Bram Moolenaar <Bram@vim.org>
parents:
20213
diff
changeset
|
2597 * another window or buffer. TRUE when editing the command line, evaluating |
634 | 2598 * 'balloonexpr', etc. |
632 | 2599 */ |
2600 int | |
20229
06a1dd50463e
patch 8.2.0670: cannot change window when evaluating 'completefunc'
Bram Moolenaar <Bram@vim.org>
parents:
20213
diff
changeset
|
2601 text_and_win_locked(void) |
632 | 2602 { |
2603 #ifdef FEAT_CMDWIN | |
2604 if (cmdwin_type != 0) | |
2605 return TRUE; | |
2606 #endif | |
20229
06a1dd50463e
patch 8.2.0670: cannot change window when evaluating 'completefunc'
Bram Moolenaar <Bram@vim.org>
parents:
20213
diff
changeset
|
2607 return textwinlock != 0; |
632 | 2608 } |
2609 | |
2610 /* | |
2611 * Give an error message for a command that isn't allowed while the cmdline | |
2612 * window is open or editing the cmdline in another way. | |
2613 */ | |
2614 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2615 text_locked_msg(void) |
632 | 2616 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
2617 emsg(_(get_text_locked_msg())); |
10082
7fc6103c6651
commit https://github.com/vim/vim/commit/5a49789a9b1f6447aeafbbbdd5b235dd10c471d5
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2618 } |
7fc6103c6651
commit https://github.com/vim/vim/commit/5a49789a9b1f6447aeafbbbdd5b235dd10c471d5
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2619 |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
2620 char * |
10082
7fc6103c6651
commit https://github.com/vim/vim/commit/5a49789a9b1f6447aeafbbbdd5b235dd10c471d5
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2621 get_text_locked_msg(void) |
7fc6103c6651
commit https://github.com/vim/vim/commit/5a49789a9b1f6447aeafbbbdd5b235dd10c471d5
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2622 { |
632 | 2623 #ifdef FEAT_CMDWIN |
2624 if (cmdwin_type != 0) | |
10082
7fc6103c6651
commit https://github.com/vim/vim/commit/5a49789a9b1f6447aeafbbbdd5b235dd10c471d5
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2625 return e_cmdwin; |
7fc6103c6651
commit https://github.com/vim/vim/commit/5a49789a9b1f6447aeafbbbdd5b235dd10c471d5
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2626 #endif |
20229
06a1dd50463e
patch 8.2.0670: cannot change window when evaluating 'completefunc'
Bram Moolenaar <Bram@vim.org>
parents:
20213
diff
changeset
|
2627 if (textwinlock != 0) |
06a1dd50463e
patch 8.2.0670: cannot change window when evaluating 'completefunc'
Bram Moolenaar <Bram@vim.org>
parents:
20213
diff
changeset
|
2628 return e_textwinlock; |
20118
252d2bb90394
patch 8.2.0614: get ml_get error when deleting a line in 'completefunc'
Bram Moolenaar <Bram@vim.org>
parents:
20045
diff
changeset
|
2629 return e_textlock; |
632 | 2630 } |
2631 | |
819 | 2632 /* |
20229
06a1dd50463e
patch 8.2.0670: cannot change window when evaluating 'completefunc'
Bram Moolenaar <Bram@vim.org>
parents:
20213
diff
changeset
|
2633 * Return TRUE when the text must not be changed and/or we cannot switch to |
06a1dd50463e
patch 8.2.0670: cannot change window when evaluating 'completefunc'
Bram Moolenaar <Bram@vim.org>
parents:
20213
diff
changeset
|
2634 * another window. TRUE while evaluating 'completefunc'. |
06a1dd50463e
patch 8.2.0670: cannot change window when evaluating 'completefunc'
Bram Moolenaar <Bram@vim.org>
parents:
20213
diff
changeset
|
2635 */ |
06a1dd50463e
patch 8.2.0670: cannot change window when evaluating 'completefunc'
Bram Moolenaar <Bram@vim.org>
parents:
20213
diff
changeset
|
2636 int |
06a1dd50463e
patch 8.2.0670: cannot change window when evaluating 'completefunc'
Bram Moolenaar <Bram@vim.org>
parents:
20213
diff
changeset
|
2637 text_locked(void) |
06a1dd50463e
patch 8.2.0670: cannot change window when evaluating 'completefunc'
Bram Moolenaar <Bram@vim.org>
parents:
20213
diff
changeset
|
2638 { |
06a1dd50463e
patch 8.2.0670: cannot change window when evaluating 'completefunc'
Bram Moolenaar <Bram@vim.org>
parents:
20213
diff
changeset
|
2639 return text_and_win_locked() || textlock != 0; |
06a1dd50463e
patch 8.2.0670: cannot change window when evaluating 'completefunc'
Bram Moolenaar <Bram@vim.org>
parents:
20213
diff
changeset
|
2640 } |
06a1dd50463e
patch 8.2.0670: cannot change window when evaluating 'completefunc'
Bram Moolenaar <Bram@vim.org>
parents:
20213
diff
changeset
|
2641 |
06a1dd50463e
patch 8.2.0670: cannot change window when evaluating 'completefunc'
Bram Moolenaar <Bram@vim.org>
parents:
20213
diff
changeset
|
2642 /* |
1834 | 2643 * Check if "curbuf_lock" or "allbuf_lock" is set and return TRUE when it is |
2644 * and give an error message. | |
819 | 2645 */ |
2646 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2647 curbuf_locked(void) |
819 | 2648 { |
2649 if (curbuf_lock > 0) | |
2650 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
2651 emsg(_("E788: Not allowed to edit another buffer now")); |
819 | 2652 return TRUE; |
2653 } | |
1834 | 2654 return allbuf_locked(); |
2655 } | |
2656 | |
2657 /* | |
2658 * Check if "allbuf_lock" is set and return TRUE when it is and give an error | |
2659 * message. | |
2660 */ | |
2661 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2662 allbuf_locked(void) |
1834 | 2663 { |
2664 if (allbuf_lock > 0) | |
2665 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
2666 emsg(_("E811: Not allowed to change buffer information now")); |
1834 | 2667 return TRUE; |
2668 } | |
819 | 2669 return FALSE; |
2670 } | |
2671 | |
7 | 2672 static int |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2673 cmdline_charsize(int idx) |
7 | 2674 { |
2675 #if defined(FEAT_CRYPT) || defined(FEAT_EVAL) | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2676 if (cmdline_star > 0) // showing '*', always 1 position |
7 | 2677 return 1; |
2678 #endif | |
2679 return ptr2cells(ccline.cmdbuff + idx); | |
2680 } | |
2681 | |
2682 /* | |
2683 * Compute the offset of the cursor on the command line for the prompt and | |
2684 * indent. | |
2685 */ | |
2686 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2687 set_cmdspos(void) |
7 | 2688 { |
531 | 2689 if (ccline.cmdfirstc != NUL) |
7 | 2690 ccline.cmdspos = 1 + ccline.cmdindent; |
2691 else | |
2692 ccline.cmdspos = 0 + ccline.cmdindent; | |
2693 } | |
2694 | |
2695 /* | |
2696 * Compute the screen position for the cursor on the command line. | |
2697 */ | |
2698 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2699 set_cmdspos_cursor(void) |
7 | 2700 { |
2701 int i, m, c; | |
2702 | |
2703 set_cmdspos(); | |
2704 if (KeyTyped) | |
534 | 2705 { |
7 | 2706 m = Columns * Rows; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2707 if (m < 0) // overflow, Columns or Rows at weird value |
534 | 2708 m = MAXCOL; |
2709 } | |
7 | 2710 else |
2711 m = MAXCOL; | |
2712 for (i = 0; i < ccline.cmdlen && i < ccline.cmdpos; ++i) | |
2713 { | |
2714 c = cmdline_charsize(i); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2715 // Count ">" for double-wide multi-byte char that doesn't fit. |
7 | 2716 if (has_mbyte) |
2717 correct_cmdspos(i, c); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2718 // If the cmdline doesn't fit, show cursor on last visible char. |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2719 // Don't move the cursor itself, so we can still append. |
7 | 2720 if ((ccline.cmdspos += c) >= m) |
2721 { | |
2722 ccline.cmdspos -= c; | |
2723 break; | |
2724 } | |
2725 if (has_mbyte) | |
474 | 2726 i += (*mb_ptr2len)(ccline.cmdbuff + i) - 1; |
7 | 2727 } |
2728 } | |
2729 | |
2730 /* | |
2731 * Check if the character at "idx", which is "cells" wide, is a multi-byte | |
2732 * character that doesn't fit, so that a ">" must be displayed. | |
2733 */ | |
2734 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2735 correct_cmdspos(int idx, int cells) |
7 | 2736 { |
474 | 2737 if ((*mb_ptr2len)(ccline.cmdbuff + idx) > 1 |
7 | 2738 && (*mb_ptr2cells)(ccline.cmdbuff + idx) > 1 |
2739 && ccline.cmdspos % Columns + cells > Columns) | |
2740 ccline.cmdspos++; | |
2741 } | |
2742 | |
2743 /* | |
2744 * Get an Ex command line for the ":" command. | |
2745 */ | |
2746 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2747 getexline( |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2748 int c, // normally ':', NUL for ":append" |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2749 void *cookie UNUSED, |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2750 int indent, // indent for inside conditionals |
21883
a427f5f26419
patch 8.2.1491: Vim9: crash when compiling heredoc lines start with comment
Bram Moolenaar <Bram@vim.org>
parents:
20733
diff
changeset
|
2751 getline_opt_T options) |
7 | 2752 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2753 // When executing a register, remove ':' that's in front of each line. |
7 | 2754 if (exec_from_reg && vpeekc() == ':') |
2755 (void)vgetc(); | |
21883
a427f5f26419
patch 8.2.1491: Vim9: crash when compiling heredoc lines start with comment
Bram Moolenaar <Bram@vim.org>
parents:
20733
diff
changeset
|
2756 return getcmdline(c, 1L, indent, options); |
7 | 2757 } |
2758 | |
2759 /* | |
2760 * Get an Ex command line for Ex mode. | |
2761 * In Ex mode we only use the OS supplied line editing features and no | |
2762 * mappings or abbreviations. | |
168 | 2763 * Returns a string in allocated memory or NULL. |
7 | 2764 */ |
2765 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2766 getexmodeline( |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2767 int promptc, // normally ':', NUL for ":append" and '?' for |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2768 // :s prompt |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2769 void *cookie UNUSED, |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2770 int indent, // indent for inside conditionals |
21883
a427f5f26419
patch 8.2.1491: Vim9: crash when compiling heredoc lines start with comment
Bram Moolenaar <Bram@vim.org>
parents:
20733
diff
changeset
|
2771 getline_opt_T options UNUSED) |
7 | 2772 { |
168 | 2773 garray_T line_ga; |
2774 char_u *pend; | |
2775 int startcol = 0; | |
1329 | 2776 int c1 = 0; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2777 int escaped = FALSE; // CTRL-V typed |
168 | 2778 int vcol = 0; |
2779 char_u *p; | |
1329 | 2780 int prev_char; |
5966 | 2781 int len; |
7 | 2782 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2783 // Switch cursor on now. This avoids that it happens after the "\n", which |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2784 // confuses the system function that computes tabstops. |
7 | 2785 cursor_on(); |
2786 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2787 // always start in column 0; write a newline if necessary |
7 | 2788 compute_cmdrow(); |
168 | 2789 if ((msg_col || msg_didout) && promptc != '?') |
7 | 2790 msg_putchar('\n'); |
168 | 2791 if (promptc == ':') |
7 | 2792 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2793 // indent that is only displayed, not in the line itself |
168 | 2794 if (p_prompt) |
2795 msg_putchar(':'); | |
7 | 2796 while (indent-- > 0) |
2797 msg_putchar(' '); | |
2798 startcol = msg_col; | |
2799 } | |
2800 | |
2801 ga_init2(&line_ga, 1, 30); | |
2802 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2803 // autoindent for :insert and :append is in the line itself |
168 | 2804 if (promptc <= 0) |
164 | 2805 { |
2806 vcol = indent; | |
2807 while (indent >= 8) | |
2808 { | |
2809 ga_append(&line_ga, TAB); | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
2810 msg_puts(" "); |
164 | 2811 indent -= 8; |
2812 } | |
2813 while (indent-- > 0) | |
2814 { | |
2815 ga_append(&line_ga, ' '); | |
2816 msg_putchar(' '); | |
2817 } | |
2818 } | |
168 | 2819 ++no_mapping; |
2820 ++allow_keys; | |
164 | 2821 |
7 | 2822 /* |
2823 * Get the line, one character at a time. | |
2824 */ | |
2825 got_int = FALSE; | |
168 | 2826 while (!got_int) |
7 | 2827 { |
6733
5f6077b10738
patch 7.4.690 for Problem: Memory access errors when changing indent in Ex mode. Also missing
Bram Moolenaar <bram@vim.org>
parents:
6695
diff
changeset
|
2828 long sw; |
5f6077b10738
patch 7.4.690 for Problem: Memory access errors when changing indent in Ex mode. Also missing
Bram Moolenaar <bram@vim.org>
parents:
6695
diff
changeset
|
2829 char_u *s; |
5f6077b10738
patch 7.4.690 for Problem: Memory access errors when changing indent in Ex mode. Also missing
Bram Moolenaar <bram@vim.org>
parents:
6695
diff
changeset
|
2830 |
7 | 2831 if (ga_grow(&line_ga, 40) == FAIL) |
2832 break; | |
2833 | |
10970
ab9f7bbe4439
patch 8.0.0374: invalid memory access when using :sc in Ex mode
Christian Brabandt <cb@256bit.org>
parents:
10942
diff
changeset
|
2834 /* |
ab9f7bbe4439
patch 8.0.0374: invalid memory access when using :sc in Ex mode
Christian Brabandt <cb@256bit.org>
parents:
10942
diff
changeset
|
2835 * Get one character at a time. |
ab9f7bbe4439
patch 8.0.0374: invalid memory access when using :sc in Ex mode
Christian Brabandt <cb@256bit.org>
parents:
10942
diff
changeset
|
2836 */ |
1329 | 2837 prev_char = c1; |
10970
ab9f7bbe4439
patch 8.0.0374: invalid memory access when using :sc in Ex mode
Christian Brabandt <cb@256bit.org>
parents:
10942
diff
changeset
|
2838 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2839 // Check for a ":normal" command and no more characters left. |
10970
ab9f7bbe4439
patch 8.0.0374: invalid memory access when using :sc in Ex mode
Christian Brabandt <cb@256bit.org>
parents:
10942
diff
changeset
|
2840 if (ex_normal_busy > 0 && typebuf.tb_len == 0) |
ab9f7bbe4439
patch 8.0.0374: invalid memory access when using :sc in Ex mode
Christian Brabandt <cb@256bit.org>
parents:
10942
diff
changeset
|
2841 c1 = '\n'; |
ab9f7bbe4439
patch 8.0.0374: invalid memory access when using :sc in Ex mode
Christian Brabandt <cb@256bit.org>
parents:
10942
diff
changeset
|
2842 else |
ab9f7bbe4439
patch 8.0.0374: invalid memory access when using :sc in Ex mode
Christian Brabandt <cb@256bit.org>
parents:
10942
diff
changeset
|
2843 c1 = vgetc(); |
7 | 2844 |
2845 /* | |
168 | 2846 * Handle line editing. |
2847 * Previously this was left to the system, putting the terminal in | |
2848 * cooked mode, but then CTRL-D and CTRL-T can't be used properly. | |
7 | 2849 */ |
168 | 2850 if (got_int) |
2851 { | |
2852 msg_putchar('\n'); | |
2853 break; | |
2854 } | |
2855 | |
10676
b8c04c007d39
patch 8.0.0228: pasting in xterm on the command line has PasteStart
Christian Brabandt <cb@256bit.org>
parents:
10565
diff
changeset
|
2856 if (c1 == K_PS) |
b8c04c007d39
patch 8.0.0228: pasting in xterm on the command line has PasteStart
Christian Brabandt <cb@256bit.org>
parents:
10565
diff
changeset
|
2857 { |
b8c04c007d39
patch 8.0.0228: pasting in xterm on the command line has PasteStart
Christian Brabandt <cb@256bit.org>
parents:
10565
diff
changeset
|
2858 bracketed_paste(PASTE_EX, FALSE, &line_ga); |
b8c04c007d39
patch 8.0.0228: pasting in xterm on the command line has PasteStart
Christian Brabandt <cb@256bit.org>
parents:
10565
diff
changeset
|
2859 goto redraw; |
b8c04c007d39
patch 8.0.0228: pasting in xterm on the command line has PasteStart
Christian Brabandt <cb@256bit.org>
parents:
10565
diff
changeset
|
2860 } |
b8c04c007d39
patch 8.0.0228: pasting in xterm on the command line has PasteStart
Christian Brabandt <cb@256bit.org>
parents:
10565
diff
changeset
|
2861 |
168 | 2862 if (!escaped) |
7 | 2863 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2864 // CR typed means "enter", which is NL |
168 | 2865 if (c1 == '\r') |
2866 c1 = '\n'; | |
2867 | |
2868 if (c1 == BS || c1 == K_BS | |
2869 || c1 == DEL || c1 == K_DEL || c1 == K_KDEL) | |
7 | 2870 { |
168 | 2871 if (line_ga.ga_len > 0) |
2872 { | |
5966 | 2873 if (has_mbyte) |
2874 { | |
2875 p = (char_u *)line_ga.ga_data; | |
2876 p[line_ga.ga_len] = NUL; | |
2877 len = (*mb_head_off)(p, p + line_ga.ga_len - 1) + 1; | |
2878 line_ga.ga_len -= len; | |
2879 } | |
2880 else | |
2881 --line_ga.ga_len; | |
168 | 2882 goto redraw; |
2883 } | |
2884 continue; | |
7 | 2885 } |
2886 | |
168 | 2887 if (c1 == Ctrl_U) |
7 | 2888 { |
168 | 2889 msg_col = startcol; |
2890 msg_clr_eos(); | |
2891 line_ga.ga_len = 0; | |
6733
5f6077b10738
patch 7.4.690 for Problem: Memory access errors when changing indent in Ex mode. Also missing
Bram Moolenaar <bram@vim.org>
parents:
6695
diff
changeset
|
2892 goto redraw; |
168 | 2893 } |
2894 | |
2895 if (c1 == Ctrl_T) | |
2896 { | |
6733
5f6077b10738
patch 7.4.690 for Problem: Memory access errors when changing indent in Ex mode. Also missing
Bram Moolenaar <bram@vim.org>
parents:
6695
diff
changeset
|
2897 sw = get_sw_value(curbuf); |
168 | 2898 p = (char_u *)line_ga.ga_data; |
2899 p[line_ga.ga_len] = NUL; | |
5995 | 2900 indent = get_indent_str(p, 8, FALSE); |
3740 | 2901 indent += sw - indent % sw; |
168 | 2902 add_indent: |
5995 | 2903 while (get_indent_str(p, 8, FALSE) < indent) |
7 | 2904 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2905 (void)ga_grow(&line_ga, 2); // one more for the NUL |
6733
5f6077b10738
patch 7.4.690 for Problem: Memory access errors when changing indent in Ex mode. Also missing
Bram Moolenaar <bram@vim.org>
parents:
6695
diff
changeset
|
2906 p = (char_u *)line_ga.ga_data; |
5f6077b10738
patch 7.4.690 for Problem: Memory access errors when changing indent in Ex mode. Also missing
Bram Moolenaar <bram@vim.org>
parents:
6695
diff
changeset
|
2907 s = skipwhite(p); |
168 | 2908 mch_memmove(s + 1, s, line_ga.ga_len - (s - p) + 1); |
2909 *s = ' '; | |
2910 ++line_ga.ga_len; | |
7 | 2911 } |
168 | 2912 redraw: |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2913 // redraw the line |
168 | 2914 msg_col = startcol; |
2915 vcol = 0; | |
5966 | 2916 p = (char_u *)line_ga.ga_data; |
2917 p[line_ga.ga_len] = NUL; | |
2918 while (p < (char_u *)line_ga.ga_data + line_ga.ga_len) | |
7 | 2919 { |
168 | 2920 if (*p == TAB) |
7 | 2921 { |
168 | 2922 do |
2923 msg_putchar(' '); | |
16162
cd5c83115ec6
patch 8.1.1086: too many curly braces
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
2924 while (++vcol % 8); |
5966 | 2925 ++p; |
7 | 2926 } |
168 | 2927 else |
164 | 2928 { |
18251
c8a53c0daeed
patch 8.1.2120: some MB_ macros are more complicated than necessary
Bram Moolenaar <Bram@vim.org>
parents:
18227
diff
changeset
|
2929 len = mb_ptr2len(p); |
5966 | 2930 msg_outtrans_len(p, len); |
2931 vcol += ptr2cells(p); | |
2932 p += len; | |
7 | 2933 } |
2934 } | |
168 | 2935 msg_clr_eos(); |
1329 | 2936 windgoto(msg_row, msg_col); |
168 | 2937 continue; |
2938 } | |
2939 | |
2940 if (c1 == Ctrl_D) | |
2941 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2942 // Delete one shiftwidth. |
168 | 2943 p = (char_u *)line_ga.ga_data; |
2944 if (prev_char == '0' || prev_char == '^') | |
7 | 2945 { |
168 | 2946 if (prev_char == '^') |
2947 ex_keep_indent = TRUE; | |
2948 indent = 0; | |
2949 p[--line_ga.ga_len] = NUL; | |
7 | 2950 } |
2951 else | |
2952 { | |
168 | 2953 p[line_ga.ga_len] = NUL; |
5995 | 2954 indent = get_indent_str(p, 8, FALSE); |
6733
5f6077b10738
patch 7.4.690 for Problem: Memory access errors when changing indent in Ex mode. Also missing
Bram Moolenaar <bram@vim.org>
parents:
6695
diff
changeset
|
2955 if (indent > 0) |
5f6077b10738
patch 7.4.690 for Problem: Memory access errors when changing indent in Ex mode. Also missing
Bram Moolenaar <bram@vim.org>
parents:
6695
diff
changeset
|
2956 { |
5f6077b10738
patch 7.4.690 for Problem: Memory access errors when changing indent in Ex mode. Also missing
Bram Moolenaar <bram@vim.org>
parents:
6695
diff
changeset
|
2957 --indent; |
5f6077b10738
patch 7.4.690 for Problem: Memory access errors when changing indent in Ex mode. Also missing
Bram Moolenaar <bram@vim.org>
parents:
6695
diff
changeset
|
2958 indent -= indent % get_sw_value(curbuf); |
5f6077b10738
patch 7.4.690 for Problem: Memory access errors when changing indent in Ex mode. Also missing
Bram Moolenaar <bram@vim.org>
parents:
6695
diff
changeset
|
2959 } |
168 | 2960 } |
5995 | 2961 while (get_indent_str(p, 8, FALSE) > indent) |
168 | 2962 { |
6733
5f6077b10738
patch 7.4.690 for Problem: Memory access errors when changing indent in Ex mode. Also missing
Bram Moolenaar <bram@vim.org>
parents:
6695
diff
changeset
|
2963 s = skipwhite(p); |
168 | 2964 mch_memmove(s - 1, s, line_ga.ga_len - (s - p) + 1); |
2965 --line_ga.ga_len; | |
7 | 2966 } |
168 | 2967 goto add_indent; |
2968 } | |
2969 | |
2970 if (c1 == Ctrl_V || c1 == Ctrl_Q) | |
2971 { | |
2972 escaped = TRUE; | |
2973 continue; | |
7 | 2974 } |
168 | 2975 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2976 // Ignore special key codes: mouse movement, K_IGNORE, etc. |
168 | 2977 if (IS_SPECIAL(c1)) |
2978 continue; | |
7 | 2979 } |
168 | 2980 |
2981 if (IS_SPECIAL(c1)) | |
2982 c1 = '?'; | |
5966 | 2983 if (has_mbyte) |
2984 len = (*mb_char2bytes)(c1, | |
2985 (char_u *)line_ga.ga_data + line_ga.ga_len); | |
2986 else | |
2987 { | |
2988 len = 1; | |
2989 ((char_u *)line_ga.ga_data)[line_ga.ga_len] = c1; | |
2990 } | |
168 | 2991 if (c1 == '\n') |
2992 msg_putchar('\n'); | |
2993 else if (c1 == TAB) | |
2994 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2995 // Don't use chartabsize(), 'ts' can be different |
168 | 2996 do |
2997 msg_putchar(' '); | |
16162
cd5c83115ec6
patch 8.1.1086: too many curly braces
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
2998 while (++vcol % 8); |
168 | 2999 } |
7 | 3000 else |
3001 { | |
168 | 3002 msg_outtrans_len( |
5966 | 3003 ((char_u *)line_ga.ga_data) + line_ga.ga_len, len); |
168 | 3004 vcol += char2cells(c1); |
7 | 3005 } |
5966 | 3006 line_ga.ga_len += len; |
168 | 3007 escaped = FALSE; |
3008 | |
3009 windgoto(msg_row, msg_col); | |
164 | 3010 pend = (char_u *)(line_ga.ga_data) + line_ga.ga_len; |
168 | 3011 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3012 // We are done when a NL is entered, but not when it comes after an |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3013 // odd number of backslashes, that results in a NUL. |
2590 | 3014 if (line_ga.ga_len > 0 && pend[-1] == '\n') |
7 | 3015 { |
2590 | 3016 int bcount = 0; |
3017 | |
3018 while (line_ga.ga_len - 2 >= bcount && pend[-2 - bcount] == '\\') | |
3019 ++bcount; | |
3020 | |
3021 if (bcount > 0) | |
3022 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3023 // Halve the number of backslashes: "\NL" -> "NUL", "\\NL" -> |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3024 // "\NL", etc. |
2590 | 3025 line_ga.ga_len -= (bcount + 1) / 2; |
3026 pend -= (bcount + 1) / 2; | |
3027 pend[-1] = '\n'; | |
3028 } | |
3029 | |
3030 if ((bcount & 1) == 0) | |
3031 { | |
3032 --line_ga.ga_len; | |
3033 --pend; | |
3034 *pend = NUL; | |
3035 break; | |
3036 } | |
7 | 3037 } |
3038 } | |
3039 | |
168 | 3040 --no_mapping; |
3041 --allow_keys; | |
3042 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3043 // make following messages go to the next line |
7 | 3044 msg_didout = FALSE; |
3045 msg_col = 0; | |
3046 if (msg_row < Rows - 1) | |
3047 ++msg_row; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3048 emsg_on_display = FALSE; // don't want ui_delay() |
7 | 3049 |
3050 if (got_int) | |
3051 ga_clear(&line_ga); | |
3052 | |
3053 return (char_u *)line_ga.ga_data; | |
3054 } | |
3055 | |
502 | 3056 # if defined(MCH_CURSOR_SHAPE) || defined(FEAT_GUI) \ |
3057 || defined(FEAT_MOUSESHAPE) || defined(PROTO) | |
7 | 3058 /* |
3059 * Return TRUE if ccline.overstrike is on. | |
3060 */ | |
3061 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3062 cmdline_overstrike(void) |
7 | 3063 { |
3064 return ccline.overstrike; | |
3065 } | |
3066 | |
3067 /* | |
3068 * Return TRUE if the cursor is at the end of the cmdline. | |
3069 */ | |
3070 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3071 cmdline_at_end(void) |
7 | 3072 { |
3073 return (ccline.cmdpos >= ccline.cmdlen); | |
3074 } | |
3075 #endif | |
3076 | |
574 | 3077 #if (defined(FEAT_XIM) && (defined(FEAT_GUI_GTK))) || defined(PROTO) |
7 | 3078 /* |
3079 * Return the virtual column number at the current cursor position. | |
3080 * This is used by the IM code to obtain the start of the preedit string. | |
3081 */ | |
3082 colnr_T | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3083 cmdline_getvcol_cursor(void) |
7 | 3084 { |
3085 if (ccline.cmdbuff == NULL || ccline.cmdpos > ccline.cmdlen) | |
3086 return MAXCOL; | |
3087 | |
3088 if (has_mbyte) | |
3089 { | |
3090 colnr_T col; | |
3091 int i = 0; | |
3092 | |
3093 for (col = 0; i < ccline.cmdpos; ++col) | |
474 | 3094 i += (*mb_ptr2len)(ccline.cmdbuff + i); |
7 | 3095 |
3096 return col; | |
3097 } | |
3098 else | |
3099 return ccline.cmdpos; | |
3100 } | |
3101 #endif | |
3102 | |
3103 #if defined(FEAT_XIM) && defined(FEAT_GUI_GTK) | |
3104 /* | |
3105 * If part of the command line is an IM preedit string, redraw it with | |
3106 * IM feedback attributes. The cursor position is restored after drawing. | |
3107 */ | |
3108 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3109 redrawcmd_preedit(void) |
7 | 3110 { |
3111 if ((State & CMDLINE) | |
3112 && xic != NULL | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3113 // && im_get_status() doesn't work when using SCIM |
7 | 3114 && !p_imdisable |
3115 && im_is_preediting()) | |
3116 { | |
3117 int cmdpos = 0; | |
3118 int cmdspos; | |
3119 int old_row; | |
3120 int old_col; | |
3121 colnr_T col; | |
3122 | |
3123 old_row = msg_row; | |
3124 old_col = msg_col; | |
531 | 3125 cmdspos = ((ccline.cmdfirstc != NUL) ? 1 : 0) + ccline.cmdindent; |
7 | 3126 |
3127 if (has_mbyte) | |
3128 { | |
3129 for (col = 0; col < preedit_start_col | |
3130 && cmdpos < ccline.cmdlen; ++col) | |
3131 { | |
3132 cmdspos += (*mb_ptr2cells)(ccline.cmdbuff + cmdpos); | |
474 | 3133 cmdpos += (*mb_ptr2len)(ccline.cmdbuff + cmdpos); |
7 | 3134 } |
3135 } | |
3136 else | |
3137 { | |
3138 cmdspos += preedit_start_col; | |
3139 cmdpos += preedit_start_col; | |
3140 } | |
3141 | |
3142 msg_row = cmdline_row + (cmdspos / (int)Columns); | |
3143 msg_col = cmdspos % (int)Columns; | |
3144 if (msg_row >= Rows) | |
3145 msg_row = Rows - 1; | |
3146 | |
3147 for (col = 0; cmdpos < ccline.cmdlen; ++col) | |
3148 { | |
3149 int char_len; | |
3150 int char_attr; | |
3151 | |
3152 char_attr = im_get_feedback_attr(col); | |
3153 if (char_attr < 0) | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3154 break; // end of preedit string |
7 | 3155 |
3156 if (has_mbyte) | |
474 | 3157 char_len = (*mb_ptr2len)(ccline.cmdbuff + cmdpos); |
7 | 3158 else |
3159 char_len = 1; | |
3160 | |
3161 msg_outtrans_len_attr(ccline.cmdbuff + cmdpos, char_len, char_attr); | |
3162 cmdpos += char_len; | |
3163 } | |
3164 | |
3165 msg_row = old_row; | |
3166 msg_col = old_col; | |
3167 } | |
3168 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3169 #endif // FEAT_XIM && FEAT_GUI_GTK |
7 | 3170 |
3171 /* | |
3172 * Allocate a new command line buffer. | |
3173 * Assigns the new buffer to ccline.cmdbuff and ccline.cmdbufflen. | |
3174 */ | |
3175 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3176 alloc_cmdbuff(int len) |
7 | 3177 { |
3178 /* | |
3179 * give some extra space to avoid having to allocate all the time | |
3180 */ | |
3181 if (len < 80) | |
3182 len = 100; | |
3183 else | |
3184 len += 20; | |
3185 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3186 ccline.cmdbuff = alloc(len); // caller should check for out-of-memory |
7 | 3187 ccline.cmdbufflen = len; |
3188 } | |
3189 | |
3190 /* | |
3191 * Re-allocate the command line to length len + something extra. | |
3192 * return FAIL for failure, OK otherwise | |
3193 */ | |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
3194 int |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3195 realloc_cmdbuff(int len) |
7 | 3196 { |
3197 char_u *p; | |
3198 | |
2557
029ace8dff7d
Now really fix using expressions in the command line (hopefully).
Bram Moolenaar <bram@vim.org>
parents:
2556
diff
changeset
|
3199 if (len < ccline.cmdbufflen) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3200 return OK; // no need to resize |
2557
029ace8dff7d
Now really fix using expressions in the command line (hopefully).
Bram Moolenaar <bram@vim.org>
parents:
2556
diff
changeset
|
3201 |
7 | 3202 p = ccline.cmdbuff; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3203 alloc_cmdbuff(len); // will get some more |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3204 if (ccline.cmdbuff == NULL) // out of memory |
7 | 3205 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3206 ccline.cmdbuff = p; // keep the old one |
7 | 3207 return FAIL; |
3208 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3209 // There isn't always a NUL after the command, but it may need to be |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3210 // there, thus copy up to the NUL and add a NUL. |
2556
e065501c703a
Fix illegal memory access when using expressions in the command line.
Bram Moolenaar <bram@vim.org>
parents:
2534
diff
changeset
|
3211 mch_memmove(ccline.cmdbuff, p, (size_t)ccline.cmdlen); |
e065501c703a
Fix illegal memory access when using expressions in the command line.
Bram Moolenaar <bram@vim.org>
parents:
2534
diff
changeset
|
3212 ccline.cmdbuff[ccline.cmdlen] = NUL; |
7 | 3213 vim_free(p); |
1718 | 3214 |
3215 if (ccline.xpc != NULL | |
3216 && ccline.xpc->xp_pattern != NULL | |
3217 && ccline.xpc->xp_context != EXPAND_NOTHING | |
3218 && ccline.xpc->xp_context != EXPAND_UNSUCCESSFUL) | |
3219 { | |
1754 | 3220 int i = (int)(ccline.xpc->xp_pattern - p); |
1718 | 3221 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3222 // If xp_pattern points inside the old cmdbuff it needs to be adjusted |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3223 // to point into the newly allocated memory. |
1718 | 3224 if (i >= 0 && i <= ccline.cmdlen) |
3225 ccline.xpc->xp_pattern = ccline.cmdbuff + i; | |
3226 } | |
3227 | |
7 | 3228 return OK; |
3229 } | |
3230 | |
359 | 3231 #if defined(FEAT_ARABIC) || defined(PROTO) |
3232 static char_u *arshape_buf = NULL; | |
3233 | |
3234 # if defined(EXITFREE) || defined(PROTO) | |
3235 void | |
17266
a9556c0ba457
patch 8.1.1632: build with EXITFREE but without +arabic fails
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
3236 free_arshape_buf(void) |
359 | 3237 { |
3238 vim_free(arshape_buf); | |
3239 } | |
3240 # endif | |
3241 #endif | |
3242 | |
7 | 3243 /* |
3244 * Draw part of the cmdline at the current cursor position. But draw stars | |
3245 * when cmdline_star is TRUE. | |
3246 */ | |
3247 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3248 draw_cmdline(int start, int len) |
7 | 3249 { |
3250 #if defined(FEAT_CRYPT) || defined(FEAT_EVAL) | |
3251 int i; | |
3252 | |
3253 if (cmdline_star > 0) | |
3254 for (i = 0; i < len; ++i) | |
3255 { | |
3256 msg_putchar('*'); | |
3257 if (has_mbyte) | |
474 | 3258 i += (*mb_ptr2len)(ccline.cmdbuff + start + i) - 1; |
7 | 3259 } |
3260 else | |
3261 #endif | |
3262 #ifdef FEAT_ARABIC | |
17155
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3263 if (p_arshape && !p_tbidi && cmdline_has_arabic(start, len)) |
7 | 3264 { |
3265 static int buflen = 0; | |
3266 char_u *p; | |
3267 int j; | |
3268 int newlen = 0; | |
3269 int mb_l; | |
719 | 3270 int pc, pc1 = 0; |
7 | 3271 int prev_c = 0; |
3272 int prev_c1 = 0; | |
714 | 3273 int u8c; |
3274 int u8cc[MAX_MCO]; | |
7 | 3275 int nc = 0; |
3276 | |
3277 /* | |
3278 * Do arabic shaping into a temporary buffer. This is very | |
3279 * inefficient! | |
3280 */ | |
507 | 3281 if (len * 2 + 2 > buflen) |
7 | 3282 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3283 // Re-allocate the buffer. We keep it around to avoid a lot of |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3284 // alloc()/free() calls. |
359 | 3285 vim_free(arshape_buf); |
507 | 3286 buflen = len * 2 + 2; |
359 | 3287 arshape_buf = alloc(buflen); |
3288 if (arshape_buf == NULL) | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3289 return; // out of memory |
7 | 3290 } |
3291 | |
507 | 3292 if (utf_iscomposing(utf_ptr2char(ccline.cmdbuff + start))) |
3293 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3294 // Prepend a space to draw the leading composing char on. |
507 | 3295 arshape_buf[0] = ' '; |
3296 newlen = 1; | |
3297 } | |
3298 | |
7 | 3299 for (j = start; j < start + len; j += mb_l) |
3300 { | |
3301 p = ccline.cmdbuff + j; | |
714 | 3302 u8c = utfc_ptr2char_len(p, u8cc, start + len - j); |
474 | 3303 mb_l = utfc_ptr2len_len(p, start + len - j); |
7 | 3304 if (ARABIC_CHAR(u8c)) |
3305 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3306 // Do Arabic shaping. |
7 | 3307 if (cmdmsg_rl) |
3308 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3309 // displaying from right to left |
7 | 3310 pc = prev_c; |
3311 pc1 = prev_c1; | |
714 | 3312 prev_c1 = u8cc[0]; |
7 | 3313 if (j + mb_l >= start + len) |
3314 nc = NUL; | |
3315 else | |
3316 nc = utf_ptr2char(p + mb_l); | |
3317 } | |
3318 else | |
3319 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3320 // displaying from left to right |
7 | 3321 if (j + mb_l >= start + len) |
3322 pc = NUL; | |
3323 else | |
714 | 3324 { |
3325 int pcc[MAX_MCO]; | |
3326 | |
3327 pc = utfc_ptr2char_len(p + mb_l, pcc, | |
7 | 3328 start + len - j - mb_l); |
714 | 3329 pc1 = pcc[0]; |
3330 } | |
7 | 3331 nc = prev_c; |
3332 } | |
3333 prev_c = u8c; | |
3334 | |
714 | 3335 u8c = arabic_shape(u8c, NULL, &u8cc[0], pc, pc1, nc); |
7 | 3336 |
359 | 3337 newlen += (*mb_char2bytes)(u8c, arshape_buf + newlen); |
714 | 3338 if (u8cc[0] != 0) |
7 | 3339 { |
714 | 3340 newlen += (*mb_char2bytes)(u8cc[0], arshape_buf + newlen); |
3341 if (u8cc[1] != 0) | |
3342 newlen += (*mb_char2bytes)(u8cc[1], | |
359 | 3343 arshape_buf + newlen); |
7 | 3344 } |
3345 } | |
3346 else | |
3347 { | |
3348 prev_c = u8c; | |
359 | 3349 mch_memmove(arshape_buf + newlen, p, mb_l); |
7 | 3350 newlen += mb_l; |
3351 } | |
3352 } | |
3353 | |
359 | 3354 msg_outtrans_len(arshape_buf, newlen); |
7 | 3355 } |
3356 else | |
3357 #endif | |
3358 msg_outtrans_len(ccline.cmdbuff + start, len); | |
3359 } | |
3360 | |
3361 /* | |
3362 * Put a character on the command line. Shifts the following text to the | |
3363 * right when "shift" is TRUE. Used for CTRL-V, CTRL-K, etc. | |
3364 * "c" must be printable (fit in one display cell)! | |
3365 */ | |
3366 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3367 putcmdline(int c, int shift) |
7 | 3368 { |
3369 if (cmd_silent) | |
3370 return; | |
3371 msg_no_more = TRUE; | |
3372 msg_putchar(c); | |
3373 if (shift) | |
3374 draw_cmdline(ccline.cmdpos, ccline.cmdlen - ccline.cmdpos); | |
3375 msg_no_more = FALSE; | |
3376 cursorcmd(); | |
11674
d093e4167733
patch 8.0.0720: unfinished mapping not displayed when running timer
Christian Brabandt <cb@256bit.org>
parents:
11664
diff
changeset
|
3377 extra_char = c; |
d093e4167733
patch 8.0.0720: unfinished mapping not displayed when running timer
Christian Brabandt <cb@256bit.org>
parents:
11664
diff
changeset
|
3378 extra_char_shift = shift; |
7 | 3379 } |
3380 | |
3381 /* | |
3382 * Undo a putcmdline(c, FALSE). | |
3383 */ | |
3384 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3385 unputcmdline(void) |
7 | 3386 { |
3387 if (cmd_silent) | |
3388 return; | |
3389 msg_no_more = TRUE; | |
3390 if (ccline.cmdlen == ccline.cmdpos) | |
3391 msg_putchar(' '); | |
3558 | 3392 else if (has_mbyte) |
3393 draw_cmdline(ccline.cmdpos, | |
3394 (*mb_ptr2len)(ccline.cmdbuff + ccline.cmdpos)); | |
7 | 3395 else |
3396 draw_cmdline(ccline.cmdpos, 1); | |
3397 msg_no_more = FALSE; | |
3398 cursorcmd(); | |
11674
d093e4167733
patch 8.0.0720: unfinished mapping not displayed when running timer
Christian Brabandt <cb@256bit.org>
parents:
11664
diff
changeset
|
3399 extra_char = NUL; |
7 | 3400 } |
3401 | |
3402 /* | |
3403 * Put the given string, of the given length, onto the command line. | |
3404 * If len is -1, then STRLEN() is used to calculate the length. | |
3405 * If 'redraw' is TRUE then the new part of the command line, and the remaining | |
3406 * part will be redrawn, otherwise it will not. If this function is called | |
3407 * twice in a row, then 'redraw' should be FALSE and redrawcmd() should be | |
3408 * called afterwards. | |
3409 */ | |
3410 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3411 put_on_cmdline(char_u *str, int len, int redraw) |
7 | 3412 { |
3413 int retval; | |
3414 int i; | |
3415 int m; | |
3416 int c; | |
3417 | |
3418 if (len < 0) | |
3419 len = (int)STRLEN(str); | |
3420 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3421 // Check if ccline.cmdbuff needs to be longer |
7 | 3422 if (ccline.cmdlen + len + 1 >= ccline.cmdbufflen) |
2557
029ace8dff7d
Now really fix using expressions in the command line (hopefully).
Bram Moolenaar <bram@vim.org>
parents:
2556
diff
changeset
|
3423 retval = realloc_cmdbuff(ccline.cmdlen + len + 1); |
7 | 3424 else |
3425 retval = OK; | |
3426 if (retval == OK) | |
3427 { | |
3428 if (!ccline.overstrike) | |
3429 { | |
3430 mch_memmove(ccline.cmdbuff + ccline.cmdpos + len, | |
3431 ccline.cmdbuff + ccline.cmdpos, | |
3432 (size_t)(ccline.cmdlen - ccline.cmdpos)); | |
3433 ccline.cmdlen += len; | |
3434 } | |
3435 else | |
3436 { | |
3437 if (has_mbyte) | |
3438 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3439 // Count nr of characters in the new string. |
7 | 3440 m = 0; |
474 | 3441 for (i = 0; i < len; i += (*mb_ptr2len)(str + i)) |
7 | 3442 ++m; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3443 // Count nr of bytes in cmdline that are overwritten by these |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3444 // characters. |
7 | 3445 for (i = ccline.cmdpos; i < ccline.cmdlen && m > 0; |
474 | 3446 i += (*mb_ptr2len)(ccline.cmdbuff + i)) |
7 | 3447 --m; |
3448 if (i < ccline.cmdlen) | |
3449 { | |
3450 mch_memmove(ccline.cmdbuff + ccline.cmdpos + len, | |
3451 ccline.cmdbuff + i, (size_t)(ccline.cmdlen - i)); | |
3452 ccline.cmdlen += ccline.cmdpos + len - i; | |
3453 } | |
3454 else | |
3455 ccline.cmdlen = ccline.cmdpos + len; | |
3456 } | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15575
diff
changeset
|
3457 else if (ccline.cmdpos + len > ccline.cmdlen) |
7 | 3458 ccline.cmdlen = ccline.cmdpos + len; |
3459 } | |
3460 mch_memmove(ccline.cmdbuff + ccline.cmdpos, str, (size_t)len); | |
3461 ccline.cmdbuff[ccline.cmdlen] = NUL; | |
3462 | |
3463 if (enc_utf8) | |
3464 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3465 // When the inserted text starts with a composing character, |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3466 // backup to the character before it. There could be two of them. |
7 | 3467 i = 0; |
3468 c = utf_ptr2char(ccline.cmdbuff + ccline.cmdpos); | |
3469 while (ccline.cmdpos > 0 && utf_iscomposing(c)) | |
3470 { | |
3471 i = (*mb_head_off)(ccline.cmdbuff, | |
3472 ccline.cmdbuff + ccline.cmdpos - 1) + 1; | |
3473 ccline.cmdpos -= i; | |
3474 len += i; | |
3475 c = utf_ptr2char(ccline.cmdbuff + ccline.cmdpos); | |
3476 } | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15575
diff
changeset
|
3477 #ifdef FEAT_ARABIC |
7 | 3478 if (i == 0 && ccline.cmdpos > 0 && arabic_maycombine(c)) |
3479 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3480 // Check the previous character for Arabic combining pair. |
7 | 3481 i = (*mb_head_off)(ccline.cmdbuff, |
3482 ccline.cmdbuff + ccline.cmdpos - 1) + 1; | |
3483 if (arabic_combine(utf_ptr2char(ccline.cmdbuff | |
3484 + ccline.cmdpos - i), c)) | |
3485 { | |
3486 ccline.cmdpos -= i; | |
3487 len += i; | |
3488 } | |
3489 else | |
3490 i = 0; | |
3491 } | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15575
diff
changeset
|
3492 #endif |
7 | 3493 if (i != 0) |
3494 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3495 // Also backup the cursor position. |
7 | 3496 i = ptr2cells(ccline.cmdbuff + ccline.cmdpos); |
3497 ccline.cmdspos -= i; | |
3498 msg_col -= i; | |
3499 if (msg_col < 0) | |
3500 { | |
3501 msg_col += Columns; | |
3502 --msg_row; | |
3503 } | |
3504 } | |
3505 } | |
3506 | |
3507 if (redraw && !cmd_silent) | |
3508 { | |
3509 msg_no_more = TRUE; | |
3510 i = cmdline_row; | |
3114 | 3511 cursorcmd(); |
7 | 3512 draw_cmdline(ccline.cmdpos, ccline.cmdlen - ccline.cmdpos); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3513 // Avoid clearing the rest of the line too often. |
7 | 3514 if (cmdline_row != i || ccline.overstrike) |
3515 msg_clr_eos(); | |
3516 msg_no_more = FALSE; | |
3517 } | |
15850
a6ca8cf07a98
patch 8.1.0932: Farsi support is outdated and unused
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
3518 if (KeyTyped) |
a6ca8cf07a98
patch 8.1.0932: Farsi support is outdated and unused
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
3519 { |
a6ca8cf07a98
patch 8.1.0932: Farsi support is outdated and unused
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
3520 m = Columns * Rows; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3521 if (m < 0) // overflow, Columns or Rows at weird value |
15850
a6ca8cf07a98
patch 8.1.0932: Farsi support is outdated and unused
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
3522 m = MAXCOL; |
a6ca8cf07a98
patch 8.1.0932: Farsi support is outdated and unused
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
3523 } |
a6ca8cf07a98
patch 8.1.0932: Farsi support is outdated and unused
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
3524 else |
a6ca8cf07a98
patch 8.1.0932: Farsi support is outdated and unused
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
3525 m = MAXCOL; |
a6ca8cf07a98
patch 8.1.0932: Farsi support is outdated and unused
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
3526 for (i = 0; i < len; ++i) |
7 | 3527 { |
15850
a6ca8cf07a98
patch 8.1.0932: Farsi support is outdated and unused
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
3528 c = cmdline_charsize(ccline.cmdpos); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3529 // count ">" for a double-wide char that doesn't fit. |
15850
a6ca8cf07a98
patch 8.1.0932: Farsi support is outdated and unused
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
3530 if (has_mbyte) |
a6ca8cf07a98
patch 8.1.0932: Farsi support is outdated and unused
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
3531 correct_cmdspos(ccline.cmdpos, c); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3532 // Stop cursor at the end of the screen, but do increment the |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3533 // insert position, so that entering a very long command |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3534 // works, even though you can't see it. |
15850
a6ca8cf07a98
patch 8.1.0932: Farsi support is outdated and unused
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
3535 if (ccline.cmdspos + c < m) |
a6ca8cf07a98
patch 8.1.0932: Farsi support is outdated and unused
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
3536 ccline.cmdspos += c; |
a6ca8cf07a98
patch 8.1.0932: Farsi support is outdated and unused
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
3537 |
a6ca8cf07a98
patch 8.1.0932: Farsi support is outdated and unused
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
3538 if (has_mbyte) |
7 | 3539 { |
15850
a6ca8cf07a98
patch 8.1.0932: Farsi support is outdated and unused
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
3540 c = (*mb_ptr2len)(ccline.cmdbuff + ccline.cmdpos) - 1; |
a6ca8cf07a98
patch 8.1.0932: Farsi support is outdated and unused
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
3541 if (c > len - i - 1) |
a6ca8cf07a98
patch 8.1.0932: Farsi support is outdated and unused
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
3542 c = len - i - 1; |
a6ca8cf07a98
patch 8.1.0932: Farsi support is outdated and unused
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
3543 ccline.cmdpos += c; |
a6ca8cf07a98
patch 8.1.0932: Farsi support is outdated and unused
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
3544 i += c; |
7 | 3545 } |
15850
a6ca8cf07a98
patch 8.1.0932: Farsi support is outdated and unused
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
3546 ++ccline.cmdpos; |
7 | 3547 } |
3548 } | |
3549 if (redraw) | |
3550 msg_check(); | |
3551 return retval; | |
3552 } | |
3553 | |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
3554 static cmdline_info_T prev_ccline; |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
3555 static int prev_ccline_used = FALSE; |
95 | 3556 |
3557 /* | |
3558 * Save ccline, because obtaining the "=" register may execute "normal :cmd" | |
3559 * and overwrite it. But get_cmdline_str() may need it, thus make it | |
3560 * available globally in prev_ccline. | |
3561 */ | |
3562 static void | |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
3563 save_cmdline(cmdline_info_T *ccp) |
95 | 3564 { |
3565 if (!prev_ccline_used) | |
3566 { | |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
3567 CLEAR_FIELD(prev_ccline); |
95 | 3568 prev_ccline_used = TRUE; |
3569 } | |
3570 *ccp = prev_ccline; | |
3571 prev_ccline = ccline; | |
14854
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
3572 ccline.cmdbuff = NULL; // signal that ccline is not in use |
95 | 3573 } |
3574 | |
3575 /* | |
1214 | 3576 * Restore ccline after it has been saved with save_cmdline(). |
95 | 3577 */ |
3578 static void | |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
3579 restore_cmdline(cmdline_info_T *ccp) |
95 | 3580 { |
3581 ccline = prev_ccline; | |
3582 prev_ccline = *ccp; | |
3583 } | |
3584 | |
15 | 3585 /* |
7336
4c5f53a60543
commit https://github.com/vim/vim/commit/6f62fed349bf829da2adb02619dc9acba13c8ab6
Christian Brabandt <cb@256bit.org>
parents:
7250
diff
changeset
|
3586 * Paste a yank register into the command line. |
4c5f53a60543
commit https://github.com/vim/vim/commit/6f62fed349bf829da2adb02619dc9acba13c8ab6
Christian Brabandt <cb@256bit.org>
parents:
7250
diff
changeset
|
3587 * Used by CTRL-R command in command-line mode. |
15 | 3588 * insert_reg() can't be used here, because special characters from the |
3589 * register contents will be interpreted as commands. | |
3590 * | |
7336
4c5f53a60543
commit https://github.com/vim/vim/commit/6f62fed349bf829da2adb02619dc9acba13c8ab6
Christian Brabandt <cb@256bit.org>
parents:
7250
diff
changeset
|
3591 * Return FAIL for failure, OK otherwise. |
15 | 3592 */ |
3593 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3594 cmdline_paste( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3595 int regname, |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3596 int literally, // Insert text literally instead of "as typed" |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3597 int remcr) // remove trailing CR |
15 | 3598 { |
3599 long i; | |
3600 char_u *arg; | |
772 | 3601 char_u *p; |
15 | 3602 int allocated; |
3603 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3604 // check for valid regname; also accept special characters for CTRL-R in |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3605 // the command line |
15 | 3606 if (regname != Ctrl_F && regname != Ctrl_P && regname != Ctrl_W |
13831
1f95ec5de238
patch 8.0.1787: cannot insert the whole cursor line
Christian Brabandt <cb@256bit.org>
parents:
13794
diff
changeset
|
3607 && regname != Ctrl_A && regname != Ctrl_L |
1f95ec5de238
patch 8.0.1787: cannot insert the whole cursor line
Christian Brabandt <cb@256bit.org>
parents:
13794
diff
changeset
|
3608 && !valid_yank_reg(regname, FALSE)) |
15 | 3609 return FAIL; |
3610 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3611 // A register containing CTRL-R can cause an endless loop. Allow using |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3612 // CTRL-C to break the loop. |
15 | 3613 line_breakcheck(); |
3614 if (got_int) | |
3615 return FAIL; | |
3616 | |
3617 #ifdef FEAT_CLIPBOARD | |
3618 regname = may_get_selection(regname); | |
3619 #endif | |
3620 | |
20229
06a1dd50463e
patch 8.2.0670: cannot change window when evaluating 'completefunc'
Bram Moolenaar <Bram@vim.org>
parents:
20213
diff
changeset
|
3621 // Need to set "textwinlock" to avoid nasty things like going to another |
14854
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
3622 // buffer when evaluating an expression. |
20229
06a1dd50463e
patch 8.2.0670: cannot change window when evaluating 'completefunc'
Bram Moolenaar <Bram@vim.org>
parents:
20213
diff
changeset
|
3623 ++textwinlock; |
15 | 3624 i = get_spec_reg(regname, &arg, &allocated, TRUE); |
20229
06a1dd50463e
patch 8.2.0670: cannot change window when evaluating 'completefunc'
Bram Moolenaar <Bram@vim.org>
parents:
20213
diff
changeset
|
3625 --textwinlock; |
15 | 3626 |
3627 if (i) | |
3628 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3629 // Got the value of a special register in "arg". |
15 | 3630 if (arg == NULL) |
3631 return FAIL; | |
772 | 3632 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3633 // When 'incsearch' is set and CTRL-R CTRL-W used: skip the duplicate |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3634 // part of the word. |
772 | 3635 p = arg; |
3636 if (p_is && regname == Ctrl_W) | |
3637 { | |
3638 char_u *w; | |
3639 int len; | |
3640 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3641 // Locate start of last word in the cmd buffer. |
2937 | 3642 for (w = ccline.cmdbuff + ccline.cmdpos; w > ccline.cmdbuff; ) |
772 | 3643 { |
3644 if (has_mbyte) | |
3645 { | |
3646 len = (*mb_head_off)(ccline.cmdbuff, w - 1) + 1; | |
3647 if (!vim_iswordc(mb_ptr2char(w - len))) | |
3648 break; | |
3649 w -= len; | |
3650 } | |
3651 else | |
3652 { | |
3653 if (!vim_iswordc(w[-1])) | |
3654 break; | |
3655 --w; | |
3656 } | |
3657 } | |
2937 | 3658 len = (int)((ccline.cmdbuff + ccline.cmdpos) - w); |
772 | 3659 if (p_ic ? STRNICMP(w, arg, len) == 0 : STRNCMP(w, arg, len) == 0) |
3660 p += len; | |
3661 } | |
3662 | |
3663 cmdline_paste_str(p, literally); | |
15 | 3664 if (allocated) |
3665 vim_free(arg); | |
3666 return OK; | |
3667 } | |
3668 | |
1015 | 3669 return cmdline_paste_reg(regname, literally, remcr); |
15 | 3670 } |
3671 | |
3672 /* | |
3673 * Put a string on the command line. | |
3674 * When "literally" is TRUE, insert literally. | |
3675 * When "literally" is FALSE, insert as typed, but don't leave the command | |
3676 * line. | |
3677 */ | |
3678 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3679 cmdline_paste_str(char_u *s, int literally) |
15 | 3680 { |
3681 int c, cv; | |
3682 | |
3683 if (literally) | |
3684 put_on_cmdline(s, -1, TRUE); | |
3685 else | |
3686 while (*s != NUL) | |
3687 { | |
3688 cv = *s; | |
3689 if (cv == Ctrl_V && s[1]) | |
3690 ++s; | |
3691 if (has_mbyte) | |
1606 | 3692 c = mb_cptr2char_adv(&s); |
15 | 3693 else |
3694 c = *s++; | |
3628 | 3695 if (cv == Ctrl_V || c == ESC || c == Ctrl_C |
3696 || c == CAR || c == NL || c == Ctrl_L | |
15 | 3697 #ifdef UNIX |
3698 || c == intr_char | |
3699 #endif | |
3700 || (c == Ctrl_BSL && *s == Ctrl_N)) | |
3701 stuffcharReadbuff(Ctrl_V); | |
3702 stuffcharReadbuff(c); | |
3703 } | |
3704 } | |
3705 | |
7 | 3706 /* |
9066
c7bdd383275d
commit https://github.com/vim/vim/commit/89c79b99328b66f77f1d12dc8c6701dfe2c57f15
Christian Brabandt <cb@256bit.org>
parents:
8765
diff
changeset
|
3707 * This function is called when the screen size changes and with incremental |
c7bdd383275d
commit https://github.com/vim/vim/commit/89c79b99328b66f77f1d12dc8c6701dfe2c57f15
Christian Brabandt <cb@256bit.org>
parents:
8765
diff
changeset
|
3708 * search and in other situations where the command line may have been |
c7bdd383275d
commit https://github.com/vim/vim/commit/89c79b99328b66f77f1d12dc8c6701dfe2c57f15
Christian Brabandt <cb@256bit.org>
parents:
8765
diff
changeset
|
3709 * overwritten. |
7 | 3710 */ |
3711 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3712 redrawcmdline(void) |
7 | 3713 { |
11416
32aed0993813
patch 8.0.0592: if a job writes to a buffer screen is not updated
Christian Brabandt <cb@256bit.org>
parents:
11321
diff
changeset
|
3714 redrawcmdline_ex(TRUE); |
32aed0993813
patch 8.0.0592: if a job writes to a buffer screen is not updated
Christian Brabandt <cb@256bit.org>
parents:
11321
diff
changeset
|
3715 } |
32aed0993813
patch 8.0.0592: if a job writes to a buffer screen is not updated
Christian Brabandt <cb@256bit.org>
parents:
11321
diff
changeset
|
3716 |
32aed0993813
patch 8.0.0592: if a job writes to a buffer screen is not updated
Christian Brabandt <cb@256bit.org>
parents:
11321
diff
changeset
|
3717 void |
32aed0993813
patch 8.0.0592: if a job writes to a buffer screen is not updated
Christian Brabandt <cb@256bit.org>
parents:
11321
diff
changeset
|
3718 redrawcmdline_ex(int do_compute_cmdrow) |
32aed0993813
patch 8.0.0592: if a job writes to a buffer screen is not updated
Christian Brabandt <cb@256bit.org>
parents:
11321
diff
changeset
|
3719 { |
7 | 3720 if (cmd_silent) |
3721 return; | |
3722 need_wait_return = FALSE; | |
11416
32aed0993813
patch 8.0.0592: if a job writes to a buffer screen is not updated
Christian Brabandt <cb@256bit.org>
parents:
11321
diff
changeset
|
3723 if (do_compute_cmdrow) |
32aed0993813
patch 8.0.0592: if a job writes to a buffer screen is not updated
Christian Brabandt <cb@256bit.org>
parents:
11321
diff
changeset
|
3724 compute_cmdrow(); |
7 | 3725 redrawcmd(); |
3726 cursorcmd(); | |
3727 } | |
3728 | |
3729 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3730 redrawcmdprompt(void) |
7 | 3731 { |
3732 int i; | |
3733 | |
3734 if (cmd_silent) | |
3735 return; | |
531 | 3736 if (ccline.cmdfirstc != NUL) |
7 | 3737 msg_putchar(ccline.cmdfirstc); |
3738 if (ccline.cmdprompt != NULL) | |
3739 { | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
3740 msg_puts_attr((char *)ccline.cmdprompt, ccline.cmdattr); |
7 | 3741 ccline.cmdindent = msg_col + (msg_row - cmdline_row) * Columns; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3742 // do the reverse of set_cmdspos() |
531 | 3743 if (ccline.cmdfirstc != NUL) |
7 | 3744 --ccline.cmdindent; |
3745 } | |
3746 else | |
3747 for (i = ccline.cmdindent; i > 0; --i) | |
3748 msg_putchar(' '); | |
3749 } | |
3750 | |
3751 /* | |
3752 * Redraw what is currently on the command line. | |
3753 */ | |
3754 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3755 redrawcmd(void) |
7 | 3756 { |
3757 if (cmd_silent) | |
3758 return; | |
3759 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3760 // when 'incsearch' is set there may be no command line while redrawing |
683 | 3761 if (ccline.cmdbuff == NULL) |
3762 { | |
3763 windgoto(cmdline_row, 0); | |
3764 msg_clr_eos(); | |
3765 return; | |
3766 } | |
3767 | |
7 | 3768 msg_start(); |
3769 redrawcmdprompt(); | |
3770 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3771 // Don't use more prompt, truncate the cmdline if it doesn't fit. |
7 | 3772 msg_no_more = TRUE; |
3773 draw_cmdline(0, ccline.cmdlen); | |
3774 msg_clr_eos(); | |
3775 msg_no_more = FALSE; | |
3776 | |
3777 set_cmdspos_cursor(); | |
11664
e3bfe624ba0a
patch 8.0.0714: when a timer causes a command line redraw " goes missing
Christian Brabandt <cb@256bit.org>
parents:
11647
diff
changeset
|
3778 if (extra_char != NUL) |
11674
d093e4167733
patch 8.0.0720: unfinished mapping not displayed when running timer
Christian Brabandt <cb@256bit.org>
parents:
11664
diff
changeset
|
3779 putcmdline(extra_char, extra_char_shift); |
7 | 3780 |
3781 /* | |
3782 * An emsg() before may have set msg_scroll. This is used in normal mode, | |
3783 * in cmdline mode we can reset them now. | |
3784 */ | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3785 msg_scroll = FALSE; // next message overwrites cmdline |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3786 |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3787 // Typing ':' at the more prompt may set skip_redraw. We don't want this |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3788 // in cmdline mode |
7 | 3789 skip_redraw = FALSE; |
3790 } | |
3791 | |
3792 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3793 compute_cmdrow(void) |
7 | 3794 { |
540 | 3795 if (exmode_active || msg_scrolled != 0) |
7 | 3796 cmdline_row = Rows - 1; |
3797 else | |
3798 cmdline_row = W_WINROW(lastwin) + lastwin->w_height | |
12529
158917d728b4
patch 8.0.1143: macros always expand to the same thing
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
3799 + lastwin->w_status_height; |
7 | 3800 } |
3801 | |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
3802 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3803 cursorcmd(void) |
7 | 3804 { |
3805 if (cmd_silent) | |
3806 return; | |
3807 | |
3808 #ifdef FEAT_RIGHTLEFT | |
3809 if (cmdmsg_rl) | |
3810 { | |
3811 msg_row = cmdline_row + (ccline.cmdspos / (int)(Columns - 1)); | |
3812 msg_col = (int)Columns - (ccline.cmdspos % (int)(Columns - 1)) - 1; | |
3813 if (msg_row <= 0) | |
3814 msg_row = Rows - 1; | |
3815 } | |
3816 else | |
3817 #endif | |
3818 { | |
3819 msg_row = cmdline_row + (ccline.cmdspos / (int)Columns); | |
3820 msg_col = ccline.cmdspos % (int)Columns; | |
3821 if (msg_row >= Rows) | |
3822 msg_row = Rows - 1; | |
3823 } | |
3824 | |
3825 windgoto(msg_row, msg_col); | |
3826 #if defined(FEAT_XIM) && defined(FEAT_GUI_GTK) | |
12293
1ff5e5dfa9b0
patch 8.0.1026: GTK on-the-spot input has problems
Christian Brabandt <cb@256bit.org>
parents:
11995
diff
changeset
|
3827 if (p_imst == IM_ON_THE_SPOT) |
1ff5e5dfa9b0
patch 8.0.1026: GTK on-the-spot input has problems
Christian Brabandt <cb@256bit.org>
parents:
11995
diff
changeset
|
3828 redrawcmd_preedit(); |
7 | 3829 #endif |
3830 #ifdef MCH_CURSOR_SHAPE | |
3831 mch_update_cursor(); | |
3832 #endif | |
3833 } | |
3834 | |
3835 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3836 gotocmdline(int clr) |
7 | 3837 { |
3838 msg_start(); | |
3839 #ifdef FEAT_RIGHTLEFT | |
3840 if (cmdmsg_rl) | |
3841 msg_col = Columns - 1; | |
3842 else | |
3843 #endif | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3844 msg_col = 0; // always start in column 0 |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3845 if (clr) // clear the bottom line(s) |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3846 msg_clr_eos(); // will reset clear_cmdline |
7 | 3847 windgoto(cmdline_row, 0); |
3848 } | |
3849 | |
3850 /* | |
3851 * Check the word in front of the cursor for an abbreviation. | |
3852 * Called when the non-id character "c" has been entered. | |
3853 * When an abbreviation is recognized it is removed from the text with | |
3854 * backspaces and the replacement string is inserted, followed by "c". | |
3855 */ | |
3856 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3857 ccheck_abbr(int c) |
7 | 3858 { |
13933
bea665293ea0
patch 8.0.1837: one character cmdline abbreviation not triggered after '<,'>
Christian Brabandt <cb@256bit.org>
parents:
13831
diff
changeset
|
3859 int spos = 0; |
bea665293ea0
patch 8.0.1837: one character cmdline abbreviation not triggered after '<,'>
Christian Brabandt <cb@256bit.org>
parents:
13831
diff
changeset
|
3860 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3861 if (p_paste || no_abbr) // no abbreviations or in paste mode |
7 | 3862 return FALSE; |
3863 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3864 // Do not consider '<,'> be part of the mapping, skip leading whitespace. |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3865 // Actually accepts any mark. |
13933
bea665293ea0
patch 8.0.1837: one character cmdline abbreviation not triggered after '<,'>
Christian Brabandt <cb@256bit.org>
parents:
13831
diff
changeset
|
3866 while (VIM_ISWHITE(ccline.cmdbuff[spos]) && spos < ccline.cmdlen) |
bea665293ea0
patch 8.0.1837: one character cmdline abbreviation not triggered after '<,'>
Christian Brabandt <cb@256bit.org>
parents:
13831
diff
changeset
|
3867 spos++; |
bea665293ea0
patch 8.0.1837: one character cmdline abbreviation not triggered after '<,'>
Christian Brabandt <cb@256bit.org>
parents:
13831
diff
changeset
|
3868 if (ccline.cmdlen - spos > 5 |
bea665293ea0
patch 8.0.1837: one character cmdline abbreviation not triggered after '<,'>
Christian Brabandt <cb@256bit.org>
parents:
13831
diff
changeset
|
3869 && ccline.cmdbuff[spos] == '\'' |
bea665293ea0
patch 8.0.1837: one character cmdline abbreviation not triggered after '<,'>
Christian Brabandt <cb@256bit.org>
parents:
13831
diff
changeset
|
3870 && ccline.cmdbuff[spos + 2] == ',' |
bea665293ea0
patch 8.0.1837: one character cmdline abbreviation not triggered after '<,'>
Christian Brabandt <cb@256bit.org>
parents:
13831
diff
changeset
|
3871 && ccline.cmdbuff[spos + 3] == '\'') |
bea665293ea0
patch 8.0.1837: one character cmdline abbreviation not triggered after '<,'>
Christian Brabandt <cb@256bit.org>
parents:
13831
diff
changeset
|
3872 spos += 5; |
bea665293ea0
patch 8.0.1837: one character cmdline abbreviation not triggered after '<,'>
Christian Brabandt <cb@256bit.org>
parents:
13831
diff
changeset
|
3873 else |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3874 // check abbreviation from the beginning of the commandline |
13933
bea665293ea0
patch 8.0.1837: one character cmdline abbreviation not triggered after '<,'>
Christian Brabandt <cb@256bit.org>
parents:
13831
diff
changeset
|
3875 spos = 0; |
bea665293ea0
patch 8.0.1837: one character cmdline abbreviation not triggered after '<,'>
Christian Brabandt <cb@256bit.org>
parents:
13831
diff
changeset
|
3876 |
bea665293ea0
patch 8.0.1837: one character cmdline abbreviation not triggered after '<,'>
Christian Brabandt <cb@256bit.org>
parents:
13831
diff
changeset
|
3877 return check_abbr(c, ccline.cmdbuff, ccline.cmdpos, spos); |
7 | 3878 } |
3879 | |
3880 /* | |
1586 | 3881 * Escape special characters in "fname" for when used as a file name argument |
3882 * after a Vim command, or, when "shell" is non-zero, a shell command. | |
3883 * Returns the result in allocated memory. | |
3884 */ | |
3885 char_u * | |
18139
59bc3cd42cf5
patch 8.1.2064: MS-Windows: compiler warnings for unused arguments
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
3886 vim_strsave_fnameescape(char_u *fname, int shell UNUSED) |
1586 | 3887 { |
1685 | 3888 char_u *p; |
1586 | 3889 #ifdef BACKSLASH_IN_FILENAME |
3890 char_u buf[20]; | |
3891 int j = 0; | |
3892 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3893 // Don't escape '[', '{' and '!' if they are in 'isfname'. |
1586 | 3894 for (p = PATH_ESC_CHARS; *p != NUL; ++p) |
5481 | 3895 if ((*p != '[' && *p != '{' && *p != '!') || !vim_isfilec(*p)) |
1586 | 3896 buf[j++] = *p; |
3897 buf[j] = NUL; | |
1700 | 3898 p = vim_strsave_escaped(fname, buf); |
1586 | 3899 #else |
1685 | 3900 p = vim_strsave_escaped(fname, shell ? SHELL_ESC_CHARS : PATH_ESC_CHARS); |
3901 if (shell && csh_like_shell() && p != NULL) | |
3902 { | |
3903 char_u *s; | |
3904 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3905 // For csh and similar shells need to put two backslashes before '!'. |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3906 // One is taken by Vim, one by the shell. |
1685 | 3907 s = vim_strsave_escaped(p, (char_u *)"!"); |
3908 vim_free(p); | |
3909 p = s; | |
3910 } | |
1700 | 3911 #endif |
3912 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3913 // '>' and '+' are special at the start of some commands, e.g. ":edit" and |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3914 // ":write". "cd -" has a special meaning. |
2445
04dae202d316
Fixes for coverity warnings.
Bram Moolenaar <bram@vim.org>
parents:
2433
diff
changeset
|
3915 if (p != NULL && (*p == '>' || *p == '+' || (*p == '-' && p[1] == NUL))) |
1700 | 3916 escape_fname(&p); |
3917 | |
1685 | 3918 return p; |
1586 | 3919 } |
3920 | |
3921 /* | |
435 | 3922 * Put a backslash before the file name in "pp", which is in allocated memory. |
3923 */ | |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
3924 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3925 escape_fname(char_u **pp) |
435 | 3926 { |
3927 char_u *p; | |
3928 | |
16764
ef00b6bc186b
patch 8.1.1384: using "int" for alloc() often results in compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
16706
diff
changeset
|
3929 p = alloc(STRLEN(*pp) + 2); |
435 | 3930 if (p != NULL) |
3931 { | |
3932 p[0] = '\\'; | |
3933 STRCPY(p + 1, *pp); | |
3934 vim_free(*pp); | |
3935 *pp = p; | |
3936 } | |
3937 } | |
3938 | |
3939 /* | |
7 | 3940 * For each file name in files[num_files]: |
3941 * If 'orig_pat' starts with "~/", replace the home directory with "~". | |
3942 */ | |
3943 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3944 tilde_replace( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3945 char_u *orig_pat, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3946 int num_files, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3947 char_u **files) |
7 | 3948 { |
3949 int i; | |
3950 char_u *p; | |
3951 | |
3952 if (orig_pat[0] == '~' && vim_ispathsep(orig_pat[1])) | |
3953 { | |
3954 for (i = 0; i < num_files; ++i) | |
3955 { | |
3956 p = home_replace_save(NULL, files[i]); | |
3957 if (p != NULL) | |
3958 { | |
3959 vim_free(files[i]); | |
3960 files[i] = p; | |
3961 } | |
3962 } | |
3963 } | |
3964 } | |
3965 | |
3966 /* | |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
3967 * Get a pointer to the current command line info. |
7 | 3968 */ |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
3969 cmdline_info_T * |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
3970 get_cmdline_info(void) |
7 | 3971 { |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
3972 return &ccline; |
7 | 3973 } |
3974 | |
8647
59866aabe737
commit https://github.com/vim/vim/commit/064154c3fedd6a46ca2f61463d7e5567bd22d9f1
Christian Brabandt <cb@256bit.org>
parents:
8645
diff
changeset
|
3975 #if defined(FEAT_EVAL) || defined(FEAT_CMDWIN) || defined(PROTO) |
8645
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
3976 /* |
14854
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
3977 * Get pointer to the command line info to use. save_ccline() may clear |
8645
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
3978 * ccline and put the previous value in prev_ccline. |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
3979 */ |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
3980 static cmdline_info_T * |
8645
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
3981 get_ccline_ptr(void) |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
3982 { |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
3983 if ((State & CMDLINE) == 0) |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
3984 return NULL; |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
3985 if (ccline.cmdbuff != NULL) |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
3986 return &ccline; |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
3987 if (prev_ccline_used && prev_ccline.cmdbuff != NULL) |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
3988 return &prev_ccline; |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
3989 return NULL; |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
3990 } |
8647
59866aabe737
commit https://github.com/vim/vim/commit/064154c3fedd6a46ca2f61463d7e5567bd22d9f1
Christian Brabandt <cb@256bit.org>
parents:
8645
diff
changeset
|
3991 #endif |
59866aabe737
commit https://github.com/vim/vim/commit/064154c3fedd6a46ca2f61463d7e5567bd22d9f1
Christian Brabandt <cb@256bit.org>
parents:
8645
diff
changeset
|
3992 |
59866aabe737
commit https://github.com/vim/vim/commit/064154c3fedd6a46ca2f61463d7e5567bd22d9f1
Christian Brabandt <cb@256bit.org>
parents:
8645
diff
changeset
|
3993 #if defined(FEAT_EVAL) || defined(PROTO) |
8645
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
3994 /* |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
3995 * Get the current command line in allocated memory. |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
3996 * Only works when the command line is being edited. |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
3997 * Returns NULL when something is wrong. |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
3998 */ |
17970
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
3999 static char_u * |
8645
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4000 get_cmdline_str(void) |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4001 { |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
4002 cmdline_info_T *p; |
14848
45d8aa272dbe
patch 8.1.0436: can get the text of inputsecret() with getcmdline()
Christian Brabandt <cb@256bit.org>
parents:
14842
diff
changeset
|
4003 |
45d8aa272dbe
patch 8.1.0436: can get the text of inputsecret() with getcmdline()
Christian Brabandt <cb@256bit.org>
parents:
14842
diff
changeset
|
4004 if (cmdline_star > 0) |
45d8aa272dbe
patch 8.1.0436: can get the text of inputsecret() with getcmdline()
Christian Brabandt <cb@256bit.org>
parents:
14842
diff
changeset
|
4005 return NULL; |
45d8aa272dbe
patch 8.1.0436: can get the text of inputsecret() with getcmdline()
Christian Brabandt <cb@256bit.org>
parents:
14842
diff
changeset
|
4006 p = get_ccline_ptr(); |
8645
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4007 if (p == NULL) |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4008 return NULL; |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4009 return vim_strnsave(p->cmdbuff, p->cmdlen); |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4010 } |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4011 |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4012 /* |
17970
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4013 * "getcmdline()" function |
8645
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4014 */ |
17970
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4015 void |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4016 f_getcmdline(typval_T *argvars UNUSED, typval_T *rettv) |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4017 { |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4018 rettv->v_type = VAR_STRING; |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4019 rettv->vval.v_string = get_cmdline_str(); |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4020 } |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4021 |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4022 /* |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4023 * "getcmdpos()" function |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4024 */ |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4025 void |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4026 f_getcmdpos(typval_T *argvars UNUSED, typval_T *rettv) |
8645
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4027 { |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
4028 cmdline_info_T *p = get_ccline_ptr(); |
8645
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4029 |
17970
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4030 rettv->vval.v_number = 0; |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4031 if (p != NULL) |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4032 rettv->vval.v_number = p->cmdpos + 1; |
8645
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4033 } |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4034 |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4035 /* |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4036 * Set the command line byte position to "pos". Zero is the first position. |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4037 * Only works when the command line is being edited. |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4038 * Returns 1 when failed, 0 when OK. |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4039 */ |
17970
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4040 static int |
8645
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4041 set_cmdline_pos( |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4042 int pos) |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4043 { |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
4044 cmdline_info_T *p = get_ccline_ptr(); |
8645
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4045 |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4046 if (p == NULL) |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4047 return 1; |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4048 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4049 // The position is not set directly but after CTRL-\ e or CTRL-R = has |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4050 // changed the command line. |
8645
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4051 if (pos < 0) |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4052 new_cmdpos = 0; |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4053 else |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4054 new_cmdpos = pos; |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4055 return 0; |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4056 } |
17970
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4057 |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4058 /* |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4059 * "setcmdpos()" function |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4060 */ |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4061 void |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4062 f_setcmdpos(typval_T *argvars, typval_T *rettv) |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4063 { |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4064 int pos = (int)tv_get_number(&argvars[0]) - 1; |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4065 |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4066 if (pos >= 0) |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4067 rettv->vval.v_number = set_cmdline_pos(pos); |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4068 } |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4069 |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4070 /* |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4071 * "getcmdtype()" function |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4072 */ |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4073 void |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4074 f_getcmdtype(typval_T *argvars UNUSED, typval_T *rettv) |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4075 { |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4076 rettv->v_type = VAR_STRING; |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4077 rettv->vval.v_string = alloc(2); |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4078 if (rettv->vval.v_string != NULL) |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4079 { |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4080 rettv->vval.v_string[0] = get_cmdline_type(); |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4081 rettv->vval.v_string[1] = NUL; |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4082 } |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4083 } |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4084 |
8645
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4085 #endif |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4086 |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4087 #if defined(FEAT_EVAL) || defined(FEAT_CMDWIN) || defined(PROTO) |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4088 /* |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4089 * Get the current command-line type. |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4090 * Returns ':' or '/' or '?' or '@' or '>' or '-' |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4091 * Only works when the command line is being edited. |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4092 * Returns NUL when something is wrong. |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4093 */ |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4094 int |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4095 get_cmdline_type(void) |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4096 { |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
4097 cmdline_info_T *p = get_ccline_ptr(); |
8645
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4098 |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4099 if (p == NULL) |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4100 return NUL; |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4101 if (p->cmdfirstc == NUL) |
8647
59866aabe737
commit https://github.com/vim/vim/commit/064154c3fedd6a46ca2f61463d7e5567bd22d9f1
Christian Brabandt <cb@256bit.org>
parents:
8645
diff
changeset
|
4102 return |
59866aabe737
commit https://github.com/vim/vim/commit/064154c3fedd6a46ca2f61463d7e5567bd22d9f1
Christian Brabandt <cb@256bit.org>
parents:
8645
diff
changeset
|
4103 # ifdef FEAT_EVAL |
59866aabe737
commit https://github.com/vim/vim/commit/064154c3fedd6a46ca2f61463d7e5567bd22d9f1
Christian Brabandt <cb@256bit.org>
parents:
8645
diff
changeset
|
4104 (p->input_fn) ? '@' : |
59866aabe737
commit https://github.com/vim/vim/commit/064154c3fedd6a46ca2f61463d7e5567bd22d9f1
Christian Brabandt <cb@256bit.org>
parents:
8645
diff
changeset
|
4105 # endif |
59866aabe737
commit https://github.com/vim/vim/commit/064154c3fedd6a46ca2f61463d7e5567bd22d9f1
Christian Brabandt <cb@256bit.org>
parents:
8645
diff
changeset
|
4106 '-'; |
8645
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4107 return p->cmdfirstc; |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4108 } |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4109 #endif |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4110 |
17652
9efb4dda9720
patch 8.1.1823: command line history code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17588
diff
changeset
|
4111 /* |
9efb4dda9720
patch 8.1.1823: command line history code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17588
diff
changeset
|
4112 * Return the first character of the current command line. |
9efb4dda9720
patch 8.1.1823: command line history code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17588
diff
changeset
|
4113 */ |
9efb4dda9720
patch 8.1.1823: command line history code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17588
diff
changeset
|
4114 int |
9efb4dda9720
patch 8.1.1823: command line history code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17588
diff
changeset
|
4115 get_cmdline_firstc(void) |
9efb4dda9720
patch 8.1.1823: command line history code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17588
diff
changeset
|
4116 { |
9efb4dda9720
patch 8.1.1823: command line history code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17588
diff
changeset
|
4117 return ccline.cmdfirstc; |
9efb4dda9720
patch 8.1.1823: command line history code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17588
diff
changeset
|
4118 } |
9efb4dda9720
patch 8.1.1823: command line history code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17588
diff
changeset
|
4119 |
7 | 4120 /* |
4121 * Get indices "num1,num2" that specify a range within a list (not a range of | |
4122 * text lines in a buffer!) from a string. Used for ":history" and ":clist". | |
4123 * Returns OK if parsed successfully, otherwise FAIL. | |
4124 */ | |
4125 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4126 get_list_range(char_u **str, int *num1, int *num2) |
7 | 4127 { |
4128 int len; | |
4129 int first = FALSE; | |
9389
32e34e574716
commit https://github.com/vim/vim/commit/22fcfad29276bd5f317faf516637dcd491b96a12
Christian Brabandt <cb@256bit.org>
parents:
9301
diff
changeset
|
4130 varnumber_T num; |
7 | 4131 |
4132 *str = skipwhite(*str); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4133 if (**str == '-' || vim_isdigit(**str)) // parse "from" part of range |
7 | 4134 { |
16706
77bcb5055fec
patch 8.1.1355: obvious mistakes are accepted as valid expressions
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
4135 vim_str2nr(*str, NULL, &len, 0, &num, NULL, 0, FALSE); |
7 | 4136 *str += len; |
4137 *num1 = (int)num; | |
4138 first = TRUE; | |
4139 } | |
4140 *str = skipwhite(*str); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4141 if (**str == ',') // parse "to" part of range |
7 | 4142 { |
4143 *str = skipwhite(*str + 1); | |
16706
77bcb5055fec
patch 8.1.1355: obvious mistakes are accepted as valid expressions
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
4144 vim_str2nr(*str, NULL, &len, 0, &num, NULL, 0, FALSE); |
7 | 4145 if (len > 0) |
4146 { | |
4147 *num2 = (int)num; | |
4148 *str = skipwhite(*str + len); | |
4149 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4150 else if (!first) // no number given at all |
7 | 4151 return FAIL; |
4152 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4153 else if (first) // only one number given |
7 | 4154 *num2 = *num1; |
4155 return OK; | |
4156 } | |
4157 | |
4158 #if defined(FEAT_CMDWIN) || defined(PROTO) | |
4159 /* | |
18679
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
4160 * Check value of 'cedit' and set cedit_key. |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
4161 * Returns NULL if value is OK, error message otherwise. |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
4162 */ |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
4163 char * |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
4164 check_cedit(void) |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
4165 { |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
4166 int n; |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
4167 |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
4168 if (*p_cedit == NUL) |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
4169 cedit_key = -1; |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
4170 else |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
4171 { |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
4172 n = string_to_key(p_cedit, FALSE); |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
4173 if (vim_isprintc(n)) |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
4174 return e_invarg; |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
4175 cedit_key = n; |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
4176 } |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
4177 return NULL; |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
4178 } |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
4179 |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
4180 /* |
7 | 4181 * Open a window on the current command line and history. Allow editing in |
4182 * the window. Returns when the window is closed. | |
4183 * Returns: | |
4184 * CR if the command is to be executed | |
4185 * Ctrl_C if it is to be abandoned | |
4186 * K_IGNORE if editing continues | |
4187 */ | |
4188 static int | |
11321
f57dce6b934b
patch 8.0.0546: swap file exists briefly when opening the command window
Christian Brabandt <cb@256bit.org>
parents:
11285
diff
changeset
|
4189 open_cmdwin(void) |
7 | 4190 { |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
4191 bufref_T old_curbuf; |
7 | 4192 win_T *old_curwin = curwin; |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
4193 bufref_T bufref; |
7 | 4194 win_T *wp; |
4195 int i; | |
4196 linenr_T lnum; | |
4197 int histtype; | |
4198 garray_T winsizes; | |
4199 int save_restart_edit = restart_edit; | |
4200 int save_State = State; | |
4201 int save_exmode = exmode_active; | |
510 | 4202 #ifdef FEAT_RIGHTLEFT |
4203 int save_cmdmsg_rl = cmdmsg_rl; | |
4204 #endif | |
6145 | 4205 #ifdef FEAT_FOLDING |
4206 int save_KeyTyped; | |
4207 #endif | |
7 | 4208 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4209 // Can't do this recursively. Can't do it when typing a password. |
7 | 4210 if (cmdwin_type != 0 |
4211 # if defined(FEAT_CRYPT) || defined(FEAT_EVAL) | |
4212 || cmdline_star > 0 | |
4213 # endif | |
4214 ) | |
4215 { | |
4216 beep_flush(); | |
4217 return K_IGNORE; | |
4218 } | |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
4219 set_bufref(&old_curbuf, curbuf); |
7 | 4220 |
18043
5a0d5f8e1778
patch 8.1.2017: cannot execute commands after closing the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
17970
diff
changeset
|
4221 // Save current window sizes. |
7 | 4222 win_size_save(&winsizes); |
4223 | |
15569
43fa814a7977
patch 8.1.0792: bad display if opening cmdline window from Insert completion
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
4224 // When using completion in Insert mode with <C-R>=<C-F> one can open the |
43fa814a7977
patch 8.1.0792: bad display if opening cmdline window from Insert completion
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
4225 // command line window, but we don't want the popup menu then. |
43fa814a7977
patch 8.1.0792: bad display if opening cmdline window from Insert completion
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
4226 pum_undisplay(); |
43fa814a7977
patch 8.1.0792: bad display if opening cmdline window from Insert completion
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
4227 |
18043
5a0d5f8e1778
patch 8.1.2017: cannot execute commands after closing the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
17970
diff
changeset
|
4228 // don't use a new tab page |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22260
diff
changeset
|
4229 cmdmod.cmod_tab = 0; |
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22260
diff
changeset
|
4230 cmdmod.cmod_flags |= CMOD_NOSWAPFILE; |
683 | 4231 |
18043
5a0d5f8e1778
patch 8.1.2017: cannot execute commands after closing the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
17970
diff
changeset
|
4232 // Create a window for the command-line buffer. |
7 | 4233 if (win_split((int)p_cwh, WSP_BOT) == FAIL) |
4234 { | |
4235 beep_flush(); | |
19685
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19475
diff
changeset
|
4236 ga_clear(&winsizes); |
7 | 4237 return K_IGNORE; |
4238 } | |
20717
abebcc20af26
patch 8.2.0911: crash when opening a buffer for the cmdline window fails
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
4239 // Don't let quitting the More prompt make this fail. |
abebcc20af26
patch 8.2.0911: crash when opening a buffer for the cmdline window fails
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
4240 got_int = FALSE; |
7 | 4241 |
23744
fc031340f8f9
patch 8.2.2413: crash when using :all while using a cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
23505
diff
changeset
|
4242 // Set "cmdwin_type" before any autocommands may mess things up. |
fc031340f8f9
patch 8.2.2413: crash when using :all while using a cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
23505
diff
changeset
|
4243 cmdwin_type = get_cmdline_type(); |
fc031340f8f9
patch 8.2.2413: crash when using :all while using a cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
23505
diff
changeset
|
4244 |
18043
5a0d5f8e1778
patch 8.1.2017: cannot execute commands after closing the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
17970
diff
changeset
|
4245 // Create the command-line buffer empty. |
20717
abebcc20af26
patch 8.2.0911: crash when opening a buffer for the cmdline window fails
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
4246 if (do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE, NULL) == FAIL) |
abebcc20af26
patch 8.2.0911: crash when opening a buffer for the cmdline window fails
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
4247 { |
abebcc20af26
patch 8.2.0911: crash when opening a buffer for the cmdline window fails
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
4248 // Some autocommand messed it up? |
abebcc20af26
patch 8.2.0911: crash when opening a buffer for the cmdline window fails
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
4249 win_close(curwin, TRUE); |
abebcc20af26
patch 8.2.0911: crash when opening a buffer for the cmdline window fails
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
4250 ga_clear(&winsizes); |
23750
d98dcbc57f7f
patch 8.2.2416: may get stuck in command line window state
Bram Moolenaar <Bram@vim.org>
parents:
23746
diff
changeset
|
4251 cmdwin_type = 0; |
20717
abebcc20af26
patch 8.2.0911: crash when opening a buffer for the cmdline window fails
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
4252 return Ctrl_C; |
abebcc20af26
patch 8.2.0911: crash when opening a buffer for the cmdline window fails
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
4253 } |
abebcc20af26
patch 8.2.0911: crash when opening a buffer for the cmdline window fails
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
4254 |
19713
8514e8b7e661
patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents:
19685
diff
changeset
|
4255 apply_autocmds(EVENT_BUFFILEPRE, NULL, NULL, FALSE, curbuf); |
23899
421c130783c5
patch 8.2.2492: command line buffer name cannot be translated
Bram Moolenaar <Bram@vim.org>
parents:
23863
diff
changeset
|
4256 (void)setfname(curbuf, (char_u *)_("[Command Line]"), NULL, TRUE); |
19713
8514e8b7e661
patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents:
19685
diff
changeset
|
4257 apply_autocmds(EVENT_BUFFILEPOST, NULL, NULL, FALSE, curbuf); |
7 | 4258 set_option_value((char_u *)"bt", 0L, (char_u *)"nofile", OPT_LOCAL); |
4259 curbuf->b_p_ma = TRUE; | |
1865 | 4260 #ifdef FEAT_FOLDING |
4261 curwin->w_p_fen = FALSE; | |
4262 #endif | |
7 | 4263 # ifdef FEAT_RIGHTLEFT |
510 | 4264 curwin->w_p_rl = cmdmsg_rl; |
4265 cmdmsg_rl = FALSE; | |
7 | 4266 # endif |
2583 | 4267 RESET_BINDING(curwin); |
7 | 4268 |
18043
5a0d5f8e1778
patch 8.1.2017: cannot execute commands after closing the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
17970
diff
changeset
|
4269 // Don't allow switching to another buffer. |
11589
39787def24bb
patch 8.0.0677: setting 'filetype' may switch buffers
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
4270 ++curbuf_lock; |
7 | 4271 |
18043
5a0d5f8e1778
patch 8.1.2017: cannot execute commands after closing the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
17970
diff
changeset
|
4272 // Showing the prompt may have set need_wait_return, reset it. |
510 | 4273 need_wait_return = FALSE; |
4274 | |
1831 | 4275 histtype = hist_char2type(cmdwin_type); |
7 | 4276 if (histtype == HIST_CMD || histtype == HIST_DEBUG) |
4277 { | |
4278 if (p_wc == TAB) | |
4279 { | |
4280 add_map((char_u *)"<buffer> <Tab> <C-X><C-V>", INSERT); | |
4281 add_map((char_u *)"<buffer> <Tab> a<C-X><C-V>", NORMAL); | |
4282 } | |
4283 set_option_value((char_u *)"ft", 0L, (char_u *)"vim", OPT_LOCAL); | |
4284 } | |
11589
39787def24bb
patch 8.0.0677: setting 'filetype' may switch buffers
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
4285 --curbuf_lock; |
7 | 4286 |
18043
5a0d5f8e1778
patch 8.1.2017: cannot execute commands after closing the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
17970
diff
changeset
|
4287 // Reset 'textwidth' after setting 'filetype' (the Vim filetype plugin |
5a0d5f8e1778
patch 8.1.2017: cannot execute commands after closing the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
17970
diff
changeset
|
4288 // sets 'textwidth' to 78). |
10 | 4289 curbuf->b_p_tw = 0; |
4290 | |
18043
5a0d5f8e1778
patch 8.1.2017: cannot execute commands after closing the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
17970
diff
changeset
|
4291 // Fill the buffer with the history. |
7 | 4292 init_history(); |
17652
9efb4dda9720
patch 8.1.1823: command line history code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17588
diff
changeset
|
4293 if (get_hislen() > 0) |
7 | 4294 { |
17652
9efb4dda9720
patch 8.1.1823: command line history code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17588
diff
changeset
|
4295 i = *get_hisidx(histtype); |
7 | 4296 if (i >= 0) |
4297 { | |
4298 lnum = 0; | |
4299 do | |
4300 { | |
17652
9efb4dda9720
patch 8.1.1823: command line history code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17588
diff
changeset
|
4301 if (++i == get_hislen()) |
7 | 4302 i = 0; |
17652
9efb4dda9720
patch 8.1.1823: command line history code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17588
diff
changeset
|
4303 if (get_histentry(histtype)[i].hisstr != NULL) |
9efb4dda9720
patch 8.1.1823: command line history code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17588
diff
changeset
|
4304 ml_append(lnum++, get_histentry(histtype)[i].hisstr, |
7 | 4305 (colnr_T)0, FALSE); |
4306 } | |
17652
9efb4dda9720
patch 8.1.1823: command line history code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17588
diff
changeset
|
4307 while (i != *get_hisidx(histtype)); |
7 | 4308 } |
4309 } | |
4310 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4311 // Replace the empty last line with the current command-line and put the |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4312 // cursor there. |
7 | 4313 ml_replace(curbuf->b_ml.ml_line_count, ccline.cmdbuff, TRUE); |
4314 curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; | |
4315 curwin->w_cursor.col = ccline.cmdpos; | |
510 | 4316 changed_line_abv_curs(); |
4317 invalidate_botline(); | |
743 | 4318 redraw_later(SOME_VALID); |
7 | 4319 |
18227
7d90fa3e5f8d
patch 8.1.2108: cannot close the cmdline window from CmdWinEnter
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
4320 // No Ex mode here! |
7 | 4321 exmode_active = 0; |
4322 | |
4323 State = NORMAL; | |
4324 setmouse(); | |
4325 | |
18227
7d90fa3e5f8d
patch 8.1.2108: cannot close the cmdline window from CmdWinEnter
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
4326 // Reset here so it can be set by a CmdWinEnter autocommand. |
7d90fa3e5f8d
patch 8.1.2108: cannot close the cmdline window from CmdWinEnter
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
4327 cmdwin_result = 0; |
7d90fa3e5f8d
patch 8.1.2108: cannot close the cmdline window from CmdWinEnter
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
4328 |
18043
5a0d5f8e1778
patch 8.1.2017: cannot execute commands after closing the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
17970
diff
changeset
|
4329 // Trigger CmdwinEnter autocommands. |
12656
0a9dacb8826a
patch 8.0.1206: no autocmd for entering or leaving the command line
Christian Brabandt <cb@256bit.org>
parents:
12529
diff
changeset
|
4330 trigger_cmd_autocmd(cmdwin_type, EVENT_CMDWINENTER); |
18043
5a0d5f8e1778
patch 8.1.2017: cannot execute commands after closing the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
17970
diff
changeset
|
4331 if (restart_edit != 0) // autocmd with ":startinsert" |
929 | 4332 stuffcharReadbuff(K_NOP); |
7 | 4333 |
4334 i = RedrawingDisabled; | |
4335 RedrawingDisabled = 0; | |
4336 | |
4337 /* | |
4338 * Call the main loop until <CR> or CTRL-C is typed. | |
4339 */ | |
168 | 4340 main_loop(TRUE, FALSE); |
7 | 4341 |
4342 RedrawingDisabled = i; | |
4343 | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13256
diff
changeset
|
4344 # ifdef FEAT_FOLDING |
6145 | 4345 save_KeyTyped = KeyTyped; |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13256
diff
changeset
|
4346 # endif |
6145 | 4347 |
18043
5a0d5f8e1778
patch 8.1.2017: cannot execute commands after closing the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
17970
diff
changeset
|
4348 // Trigger CmdwinLeave autocommands. |
12656
0a9dacb8826a
patch 8.0.1206: no autocmd for entering or leaving the command line
Christian Brabandt <cb@256bit.org>
parents:
12529
diff
changeset
|
4349 trigger_cmd_autocmd(cmdwin_type, EVENT_CMDWINLEAVE); |
6145 | 4350 |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13256
diff
changeset
|
4351 # ifdef FEAT_FOLDING |
18043
5a0d5f8e1778
patch 8.1.2017: cannot execute commands after closing the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
17970
diff
changeset
|
4352 // Restore KeyTyped in case it is modified by autocommands |
6145 | 4353 KeyTyped = save_KeyTyped; |
7 | 4354 # endif |
4355 | |
4356 cmdwin_type = 0; | |
4357 exmode_active = save_exmode; | |
4358 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4359 // Safety check: The old window or buffer was deleted: It's a bug when |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4360 // this happens! |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
4361 if (!win_valid(old_curwin) || !bufref_valid(&old_curbuf)) |
7 | 4362 { |
4363 cmdwin_result = Ctrl_C; | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
4364 emsg(_("E199: Active window or buffer deleted")); |
7 | 4365 } |
4366 else | |
4367 { | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13256
diff
changeset
|
4368 # if defined(FEAT_EVAL) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4369 // autocmds may abort script processing |
7 | 4370 if (aborting() && cmdwin_result != K_IGNORE) |
4371 cmdwin_result = Ctrl_C; | |
4372 # endif | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4373 // Set the new command line from the cmdline buffer. |
7 | 4374 vim_free(ccline.cmdbuff); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4375 if (cmdwin_result == K_XF1 || cmdwin_result == K_XF2) // :qa[!] typed |
7 | 4376 { |
510 | 4377 char *p = (cmdwin_result == K_XF2) ? "qa" : "qa!"; |
4378 | |
4379 if (histtype == HIST_CMD) | |
4380 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4381 // Execute the command directly. |
510 | 4382 ccline.cmdbuff = vim_strsave((char_u *)p); |
4383 cmdwin_result = CAR; | |
4384 } | |
4385 else | |
4386 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4387 // First need to cancel what we were doing. |
510 | 4388 ccline.cmdbuff = NULL; |
4389 stuffcharReadbuff(':'); | |
4390 stuffReadbuff((char_u *)p); | |
4391 stuffcharReadbuff(CAR); | |
4392 } | |
7 | 4393 } |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4394 else if (cmdwin_result == K_XF2) // :qa typed |
7 | 4395 { |
4396 ccline.cmdbuff = vim_strsave((char_u *)"qa"); | |
4397 cmdwin_result = CAR; | |
4398 } | |
2839 | 4399 else if (cmdwin_result == Ctrl_C) |
4400 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4401 // :q or :close, don't execute any command |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4402 // and don't modify the cmd window. |
2839 | 4403 ccline.cmdbuff = NULL; |
4404 } | |
7 | 4405 else |
4406 ccline.cmdbuff = vim_strsave(ml_get_curline()); | |
4407 if (ccline.cmdbuff == NULL) | |
11647
aa426eb9589d
patch 8.0.0706: crash when cancelling the cmdline window in Ex mode
Christian Brabandt <cb@256bit.org>
parents:
11619
diff
changeset
|
4408 { |
aa426eb9589d
patch 8.0.0706: crash when cancelling the cmdline window in Ex mode
Christian Brabandt <cb@256bit.org>
parents:
11619
diff
changeset
|
4409 ccline.cmdbuff = vim_strsave((char_u *)""); |
aa426eb9589d
patch 8.0.0706: crash when cancelling the cmdline window in Ex mode
Christian Brabandt <cb@256bit.org>
parents:
11619
diff
changeset
|
4410 ccline.cmdlen = 0; |
aa426eb9589d
patch 8.0.0706: crash when cancelling the cmdline window in Ex mode
Christian Brabandt <cb@256bit.org>
parents:
11619
diff
changeset
|
4411 ccline.cmdbufflen = 1; |
aa426eb9589d
patch 8.0.0706: crash when cancelling the cmdline window in Ex mode
Christian Brabandt <cb@256bit.org>
parents:
11619
diff
changeset
|
4412 ccline.cmdpos = 0; |
7 | 4413 cmdwin_result = Ctrl_C; |
11647
aa426eb9589d
patch 8.0.0706: crash when cancelling the cmdline window in Ex mode
Christian Brabandt <cb@256bit.org>
parents:
11619
diff
changeset
|
4414 } |
7 | 4415 else |
4416 { | |
4417 ccline.cmdlen = (int)STRLEN(ccline.cmdbuff); | |
4418 ccline.cmdbufflen = ccline.cmdlen + 1; | |
4419 ccline.cmdpos = curwin->w_cursor.col; | |
4420 if (ccline.cmdpos > ccline.cmdlen) | |
4421 ccline.cmdpos = ccline.cmdlen; | |
4422 if (cmdwin_result == K_IGNORE) | |
4423 { | |
4424 set_cmdspos_cursor(); | |
4425 redrawcmd(); | |
4426 } | |
4427 } | |
4428 | |
6876 | 4429 # ifdef FEAT_CONCEAL |
18043
5a0d5f8e1778
patch 8.1.2017: cannot execute commands after closing the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
17970
diff
changeset
|
4430 // Avoid command-line window first character being concealed. |
6876 | 4431 curwin->w_p_cole = 0; |
4432 # endif | |
23746
7c730cf4fb82
patch 8.2.2414: using freed memory when closing the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
23744
diff
changeset
|
4433 // First go back to the original window. |
7 | 4434 wp = curwin; |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
4435 set_bufref(&bufref, curbuf); |
7 | 4436 win_goto(old_curwin); |
23746
7c730cf4fb82
patch 8.2.2414: using freed memory when closing the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
23744
diff
changeset
|
4437 |
7c730cf4fb82
patch 8.2.2414: using freed memory when closing the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
23744
diff
changeset
|
4438 // win_goto() may trigger an autocommand that already closes the |
7c730cf4fb82
patch 8.2.2414: using freed memory when closing the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
23744
diff
changeset
|
4439 // cmdline window. |
23863
a91f3147d06e
patch 8.2.2473: crash when leaving command line window triggers autocommand
Bram Moolenaar <Bram@vim.org>
parents:
23750
diff
changeset
|
4440 if (win_valid(wp) && wp != curwin) |
23746
7c730cf4fb82
patch 8.2.2414: using freed memory when closing the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
23744
diff
changeset
|
4441 win_close(wp, TRUE); |
2099
c1f67ce5740a
updated for version 7.2.382
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4442 |
18043
5a0d5f8e1778
patch 8.1.2017: cannot execute commands after closing the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
17970
diff
changeset
|
4443 // win_close() may have already wiped the buffer when 'bh' is |
23863
a91f3147d06e
patch 8.2.2473: crash when leaving command line window triggers autocommand
Bram Moolenaar <Bram@vim.org>
parents:
23750
diff
changeset
|
4444 // set to 'wipe', autocommands may have closed other windows |
a91f3147d06e
patch 8.2.2473: crash when leaving command line window triggers autocommand
Bram Moolenaar <Bram@vim.org>
parents:
23750
diff
changeset
|
4445 if (bufref_valid(&bufref) && bufref.br_buf != curbuf) |
18886
050f5eaa9e50
patch 8.2.0004: get E685 and E931 if buffer reload is interrupted
Bram Moolenaar <Bram@vim.org>
parents:
18793
diff
changeset
|
4446 close_buffer(NULL, bufref.br_buf, DOBUF_WIPE, FALSE, FALSE); |
7 | 4447 |
18043
5a0d5f8e1778
patch 8.1.2017: cannot execute commands after closing the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
17970
diff
changeset
|
4448 // Restore window sizes. |
7 | 4449 win_size_restore(&winsizes); |
4450 } | |
4451 | |
4452 ga_clear(&winsizes); | |
4453 restart_edit = save_restart_edit; | |
510 | 4454 # ifdef FEAT_RIGHTLEFT |
4455 cmdmsg_rl = save_cmdmsg_rl; | |
4456 # endif | |
7 | 4457 |
4458 State = save_State; | |
4459 setmouse(); | |
4460 | |
4461 return cmdwin_result; | |
4462 } | |
18043
5a0d5f8e1778
patch 8.1.2017: cannot execute commands after closing the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
17970
diff
changeset
|
4463 #endif // FEAT_CMDWIN |
7 | 4464 |
4465 /* | |
4466 * Used for commands that either take a simple command string argument, or: | |
4467 * cmd << endmarker | |
4468 * {script} | |
4469 * endmarker | |
4470 * Returns a pointer to allocated memory with {script} or NULL. | |
4471 */ | |
4472 char_u * | |
20045
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
4473 script_get(exarg_T *eap UNUSED, char_u *cmd UNUSED) |
7 | 4474 { |
20045
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
4475 #ifdef FEAT_EVAL |
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
4476 list_T *l; |
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
4477 listitem_T *li; |
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
4478 char_u *s; |
7 | 4479 garray_T ga; |
4480 | |
4481 if (cmd[0] != '<' || cmd[1] != '<' || eap->getline == NULL) | |
4482 return NULL; | |
20045
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
4483 cmd += 2; |
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
4484 |
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
4485 l = heredoc_get(eap, cmd, TRUE); |
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
4486 if (l == NULL) |
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
4487 return NULL; |
7 | 4488 |
4489 ga_init2(&ga, 1, 0x400); | |
4490 | |
20045
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
4491 FOR_ALL_LIST_ITEMS(l, li) |
7 | 4492 { |
20045
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
4493 s = tv_get_string(&li->li_tv); |
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
4494 ga_concat(&ga, s); |
7 | 4495 ga_append(&ga, '\n'); |
4496 } | |
21 | 4497 ga_append(&ga, NUL); |
7 | 4498 |
20045
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
4499 list_free(l); |
7 | 4500 return (char_u *)ga.ga_data; |
20045
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
4501 #else |
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
4502 return NULL; |
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
4503 #endif |
7 | 4504 } |
17922
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4505 |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4506 #if defined(FEAT_EVAL) || defined(PROTO) |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4507 /* |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4508 * This function is used by f_input() and f_inputdialog() functions. The third |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4509 * argument to f_input() specifies the type of completion to use at the |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4510 * prompt. The third argument to f_inputdialog() specifies the value to return |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4511 * when the user cancels the prompt. |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4512 */ |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4513 void |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4514 get_user_input( |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4515 typval_T *argvars, |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4516 typval_T *rettv, |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4517 int inputdialog, |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4518 int secret) |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4519 { |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4520 char_u *prompt = tv_get_string_chk(&argvars[0]); |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4521 char_u *p = NULL; |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4522 int c; |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4523 char_u buf[NUMBUFLEN]; |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4524 int cmd_silent_save = cmd_silent; |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4525 char_u *defstr = (char_u *)""; |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4526 int xp_type = EXPAND_NOTHING; |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4527 char_u *xp_arg = NULL; |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4528 |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4529 rettv->v_type = VAR_STRING; |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4530 rettv->vval.v_string = NULL; |
20213
8d9229c4781a
patch 8.2.0662: cannot use input() in a channel callback
Bram Moolenaar <Bram@vim.org>
parents:
20164
diff
changeset
|
4531 if (input_busy) |
8d9229c4781a
patch 8.2.0662: cannot use input() in a channel callback
Bram Moolenaar <Bram@vim.org>
parents:
20164
diff
changeset
|
4532 return; // this doesn't work recursively. |
17922
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4533 |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4534 #ifdef NO_CONSOLE_INPUT |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4535 // While starting up, there is no place to enter text. When running tests |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4536 // with --not-a-term we assume feedkeys() will be used. |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4537 if (no_console_input() && !is_not_a_term()) |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4538 return; |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4539 #endif |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4540 |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4541 cmd_silent = FALSE; // Want to see the prompt. |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4542 if (prompt != NULL) |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4543 { |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4544 // Only the part of the message after the last NL is considered as |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4545 // prompt for the command line |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4546 p = vim_strrchr(prompt, '\n'); |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4547 if (p == NULL) |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4548 p = prompt; |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4549 else |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4550 { |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4551 ++p; |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4552 c = *p; |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4553 *p = NUL; |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4554 msg_start(); |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4555 msg_clr_eos(); |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4556 msg_puts_attr((char *)prompt, get_echo_attr()); |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4557 msg_didout = FALSE; |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4558 msg_starthere(); |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4559 *p = c; |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4560 } |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4561 cmdline_row = msg_row; |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4562 |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4563 if (argvars[1].v_type != VAR_UNKNOWN) |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4564 { |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4565 defstr = tv_get_string_buf_chk(&argvars[1], buf); |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4566 if (defstr != NULL) |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4567 stuffReadbuffSpec(defstr); |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4568 |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4569 if (!inputdialog && argvars[2].v_type != VAR_UNKNOWN) |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4570 { |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4571 char_u *xp_name; |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4572 int xp_namelen; |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4573 long argt; |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4574 |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4575 // input() with a third argument: completion |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4576 rettv->vval.v_string = NULL; |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4577 |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4578 xp_name = tv_get_string_buf_chk(&argvars[2], buf); |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4579 if (xp_name == NULL) |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4580 return; |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4581 |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4582 xp_namelen = (int)STRLEN(xp_name); |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4583 |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4584 if (parse_compl_arg(xp_name, xp_namelen, &xp_type, &argt, |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4585 &xp_arg) == FAIL) |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4586 return; |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4587 } |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4588 } |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4589 |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4590 if (defstr != NULL) |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4591 { |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4592 int save_ex_normal_busy = ex_normal_busy; |
20213
8d9229c4781a
patch 8.2.0662: cannot use input() in a channel callback
Bram Moolenaar <Bram@vim.org>
parents:
20164
diff
changeset
|
4593 int save_vgetc_busy = vgetc_busy; |
8d9229c4781a
patch 8.2.0662: cannot use input() in a channel callback
Bram Moolenaar <Bram@vim.org>
parents:
20164
diff
changeset
|
4594 int save_input_busy = input_busy; |
8d9229c4781a
patch 8.2.0662: cannot use input() in a channel callback
Bram Moolenaar <Bram@vim.org>
parents:
20164
diff
changeset
|
4595 |
8d9229c4781a
patch 8.2.0662: cannot use input() in a channel callback
Bram Moolenaar <Bram@vim.org>
parents:
20164
diff
changeset
|
4596 input_busy |= vgetc_busy; |
17922
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4597 ex_normal_busy = 0; |
20213
8d9229c4781a
patch 8.2.0662: cannot use input() in a channel callback
Bram Moolenaar <Bram@vim.org>
parents:
20164
diff
changeset
|
4598 vgetc_busy = 0; |
17922
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4599 rettv->vval.v_string = |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4600 getcmdline_prompt(secret ? NUL : '@', p, get_echo_attr(), |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4601 xp_type, xp_arg); |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4602 ex_normal_busy = save_ex_normal_busy; |
20213
8d9229c4781a
patch 8.2.0662: cannot use input() in a channel callback
Bram Moolenaar <Bram@vim.org>
parents:
20164
diff
changeset
|
4603 vgetc_busy = save_vgetc_busy; |
8d9229c4781a
patch 8.2.0662: cannot use input() in a channel callback
Bram Moolenaar <Bram@vim.org>
parents:
20164
diff
changeset
|
4604 input_busy = save_input_busy; |
17922
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4605 } |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4606 if (inputdialog && rettv->vval.v_string == NULL |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4607 && argvars[1].v_type != VAR_UNKNOWN |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4608 && argvars[2].v_type != VAR_UNKNOWN) |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4609 rettv->vval.v_string = vim_strsave(tv_get_string_buf( |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4610 &argvars[2], buf)); |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4611 |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4612 vim_free(xp_arg); |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4613 |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4614 // since the user typed this, no need to wait for return |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4615 need_wait_return = FALSE; |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4616 msg_didout = FALSE; |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4617 } |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4618 cmd_silent = cmd_silent_save; |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4619 } |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4620 #endif |