Mercurial > vim
annotate src/ex_getln.c @ 31584:cfc60c536a2f v9.0.1124
patch 9.0.1124: virtual text at a column position is truncated
Commit: https://github.com/vim/vim/commit/1aeb3eb092a384e63a407096102fd5a954aabeb8
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jan 1 14:04:51 2023 +0000
patch 9.0.1124: virtual text at a column position is truncated
Problem: Virtual text at a column position is truncated at the window edge.
(Yegappan Lakshmanan)
Solution: Do not truncated virtual text that is placed at a column.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 01 Jan 2023 15:15:03 +0100 |
parents | 7d40c8c10a12 |
children | f1d5ad2b978e |
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); |
30645
101f08b49ed3
patch 9.0.0657: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
30329
diff
changeset
|
55 static int open_cmdwin(void); |
23505
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
56 #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
|
57 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
|
58 #endif |
7 | 59 |
29865
4291eb97e479
patch 9.0.0271: using INIT() in non-header files
Bram Moolenaar <Bram@vim.org>
parents:
29800
diff
changeset
|
60 static int cedit_key = -1; // key value of 'cedit' option |
12656
0a9dacb8826a
patch 8.0.1206: no autocmd for entering or leaving the command line
Christian Brabandt <cb@256bit.org>
parents:
12529
diff
changeset
|
61 |
0a9dacb8826a
patch 8.0.1206: no autocmd for entering or leaving the command line
Christian Brabandt <cb@256bit.org>
parents:
12529
diff
changeset
|
62 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
|
63 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
|
64 { |
0a9dacb8826a
patch 8.0.1206: no autocmd for entering or leaving the command line
Christian Brabandt <cb@256bit.org>
parents:
12529
diff
changeset
|
65 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
|
66 |
0a9dacb8826a
patch 8.0.1206: no autocmd for entering or leaving the command line
Christian Brabandt <cb@256bit.org>
parents:
12529
diff
changeset
|
67 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
|
68 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
|
69 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
|
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 |
7 | 72 /* |
12664
42cd1f315e8b
patch 8.0.1210: CTRL-G and CTRL-T are ignored with typeahead
Christian Brabandt <cb@256bit.org>
parents:
12656
diff
changeset
|
73 * 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
|
74 */ |
42cd1f315e8b
patch 8.0.1210: CTRL-G and CTRL-T are ignored with typeahead
Christian Brabandt <cb@256bit.org>
parents:
12656
diff
changeset
|
75 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
|
76 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
|
77 { |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13142
diff
changeset
|
78 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
|
79 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
|
80 compute_cmdrow(); |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
81 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
|
82 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
|
83 } |
42cd1f315e8b
patch 8.0.1210: CTRL-G and CTRL-T are ignored with typeahead
Christian Brabandt <cb@256bit.org>
parents:
12656
diff
changeset
|
84 |
13047
669c4f75a69e
patch 8.0.1399: warnings and errors when building tiny version
Christian Brabandt <cb@256bit.org>
parents:
13041
diff
changeset
|
85 #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
|
86 /* |
13035
89e191a2a8a7
patch 8.0.1393: too much highlighting with 'hlsearch' and 'incsearch' set
Christian Brabandt <cb@256bit.org>
parents:
12960
diff
changeset
|
87 * 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
|
88 * 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
|
89 */ |
89e191a2a8a7
patch 8.0.1393: too much highlighting with 'hlsearch' and 'incsearch' set
Christian Brabandt <cb@256bit.org>
parents:
12960
diff
changeset
|
90 static int |
23505
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
91 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
|
92 { |
23505
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
93 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
|
94 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
|
95 |
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
96 if (n > 0) |
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
97 (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
|
98 else |
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
99 return TRUE; |
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
100 |
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
101 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
|
102 } |
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
103 |
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
104 static int |
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
105 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
|
106 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
107 // 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
|
108 while (len >= 2 && p[len - 2] == '\\' |
28809
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
109 && vim_strchr((char_u *)"mMvVcCZ", p[len - 1]) != NULL) |
23505
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
110 len -= 2; |
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
111 |
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
112 // 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
|
113 // 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
|
114 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
|
115 && ((p[len - 2] == '\\' |
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
116 && 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
|
117 || (p[len - 2] != '\\' |
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
118 && 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
|
119 } |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
120 |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
121 // 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
|
122 typedef struct { |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
123 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
|
124 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
|
125 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
|
126 # ifdef FEAT_DIFF |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
127 int vs_topfill; |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
128 # endif |
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_botline; |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
130 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
|
131 } viewstate_T; |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
132 |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
133 static void |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
134 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
|
135 { |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
136 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
|
137 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
|
138 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
|
139 # ifdef FEAT_DIFF |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
140 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
|
141 # endif |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
142 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
|
143 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
|
144 } |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
145 |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
146 static void |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
147 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
|
148 { |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
149 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
|
150 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
|
151 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
|
152 # ifdef FEAT_DIFF |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
153 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
|
154 # endif |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
155 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
|
156 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
|
157 } |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
158 |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
159 // 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
|
160 typedef struct { |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
161 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
|
162 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
|
163 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
|
164 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
|
165 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
|
166 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
|
167 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
|
168 int did_incsearch; |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
169 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
|
170 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
|
171 } incsearch_state_T; |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
172 |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
173 static void |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
174 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
|
175 { |
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
|
176 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
|
177 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
|
178 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
|
179 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
|
180 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
|
181 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
|
182 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
|
183 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
|
184 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
|
185 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
|
186 } |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
187 |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
188 /* |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
189 * 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
|
190 * 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
|
191 */ |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
192 static void |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
193 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
|
194 { |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
195 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
|
196 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
|
197 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
|
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 = 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
|
200 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
|
201 } |
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 |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
204 /* |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
205 * 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
|
206 * 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
|
207 * 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
|
208 */ |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
209 static int |
22260
d7c1e3efa88e
patch 8.2.1679: Vim9: ":*" is not recognized as a range
Bram Moolenaar <Bram@vim.org>
parents:
22169
diff
changeset
|
210 do_incsearch_highlighting( |
d7c1e3efa88e
patch 8.2.1679: Vim9: ":*" is not recognized as a range
Bram Moolenaar <Bram@vim.org>
parents:
22169
diff
changeset
|
211 int firstc, |
d7c1e3efa88e
patch 8.2.1679: Vim9: ":*" is not recognized as a range
Bram Moolenaar <Bram@vim.org>
parents:
22169
diff
changeset
|
212 int *search_delim, |
d7c1e3efa88e
patch 8.2.1679: Vim9: ":*" is not recognized as a range
Bram Moolenaar <Bram@vim.org>
parents:
22169
diff
changeset
|
213 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
|
214 int *skiplen, |
d7c1e3efa88e
patch 8.2.1679: Vim9: ":*" is not recognized as a range
Bram Moolenaar <Bram@vim.org>
parents:
22169
diff
changeset
|
215 int *patlen) |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
216 { |
14565
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
217 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
|
218 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
|
219 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
|
220 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
|
221 int delim; |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
222 char_u *end; |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
223 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
|
224 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
|
225 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
|
226 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
|
227 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
|
228 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
|
229 |
14515
3648e74dd523
patch 8.1.0271: 'incsearch' doesn't work for :s, :g or :v
Christian Brabandt <cb@256bit.org>
parents:
14503
diff
changeset
|
230 *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
|
231 *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
|
232 |
14565
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
233 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
|
234 return FALSE; |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
235 |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
236 // 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
|
237 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
|
238 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
|
239 |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
240 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
|
241 { |
5512aa74cb62
patch 8.2.0295: highlighting for :s wrong when using different separator
Bram Moolenaar <Bram@vim.org>
parents:
18886
diff
changeset
|
242 *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
|
243 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
|
244 } |
14565
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
245 if (firstc != ':') |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
246 return FALSE; |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
247 |
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
|
248 ++emsg_off; |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
249 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
|
250 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
|
251 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
|
252 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
|
253 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
|
254 |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22260
diff
changeset
|
255 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
|
256 |
22260
d7c1e3efa88e
patch 8.2.1679: Vim9: ":*" is not recognized as a range
Bram Moolenaar <Bram@vim.org>
parents:
22169
diff
changeset
|
257 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
|
258 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
|
259 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
|
260 |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
261 // 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
|
262 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
|
263 ; |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
264 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
|
265 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
|
266 |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
267 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
|
268 || 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
|
269 || 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
|
270 || 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
|
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 (*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
|
273 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
|
274 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
|
275 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
|
276 } |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
277 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
|
278 { |
20164
2dd1ac2c48f4
patch 8.2.0637: incsearch highlighting does not work for ":sort!"
Bram Moolenaar <Bram@vim.org>
parents:
20118
diff
changeset
|
279 // 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
|
280 if (*p == '!') |
2dd1ac2c48f4
patch 8.2.0637: incsearch highlighting does not work for ":sort!"
Bram Moolenaar <Bram@vim.org>
parents:
20118
diff
changeset
|
281 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
|
282 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
|
283 ++p; |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
284 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
|
285 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
|
286 } |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
287 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
|
288 || 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
|
289 || 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
|
290 || 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
|
291 || 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
|
292 { |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
293 // skip over "!" |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
294 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
|
295 { |
14565
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
296 p++; |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
297 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
|
298 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
|
299 } |
14565
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
300 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
|
301 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
|
302 } |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
303 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
|
304 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
|
305 |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
306 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
|
307 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
|
308 *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
|
309 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
|
310 |
14613
3f9b73cc8adb
patch 8.1.0320: too much 'incsearch' highlight for pat matching everything
Christian Brabandt <cb@256bit.org>
parents:
14565
diff
changeset
|
311 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
|
312 |
3f9b73cc8adb
patch 8.1.0320: too much 'incsearch' highlight for pat matching everything
Christian Brabandt <cb@256bit.org>
parents:
14565
diff
changeset
|
313 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
|
314 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
|
315 |
3f9b73cc8adb
patch 8.1.0320: too much 'incsearch' highlight for pat matching everything
Christian Brabandt <cb@256bit.org>
parents:
14565
diff
changeset
|
316 // 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
|
317 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
|
318 { |
3f9b73cc8adb
patch 8.1.0320: too much 'incsearch' highlight for pat matching everything
Christian Brabandt <cb@256bit.org>
parents:
14565
diff
changeset
|
319 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
|
320 int empty; |
3f9b73cc8adb
patch 8.1.0320: too much 'incsearch' highlight for pat matching everything
Christian Brabandt <cb@256bit.org>
parents:
14565
diff
changeset
|
321 |
3f9b73cc8adb
patch 8.1.0320: too much 'incsearch' highlight for pat matching everything
Christian Brabandt <cb@256bit.org>
parents:
14565
diff
changeset
|
322 *end = NUL; |
23505
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23272
diff
changeset
|
323 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
|
324 *end = c; |
3f9b73cc8adb
patch 8.1.0320: too much 'incsearch' highlight for pat matching everything
Christian Brabandt <cb@256bit.org>
parents:
14565
diff
changeset
|
325 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
|
326 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
|
327 } |
3f9b73cc8adb
patch 8.1.0320: too much 'incsearch' highlight for pat matching everything
Christian Brabandt <cb@256bit.org>
parents:
14565
diff
changeset
|
328 |
14565
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
329 // 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
|
330 *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
|
331 *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
|
332 |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
333 // 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
|
334 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
|
335 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
|
336 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
|
337 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
|
338 { |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
339 // 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
|
340 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
|
341 { |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
342 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
|
343 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
|
344 } |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
345 else |
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.line1; |
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.line2; |
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 } |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
351 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
|
352 { |
5e038972cafa
patch 8.1.0296: command parsing for 'incsearch' is a bit ugly
Christian Brabandt <cb@256bit.org>
parents:
14563
diff
changeset
|
353 // :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
|
354 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
|
355 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
|
356 } |
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 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
|
359 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
|
360 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
|
361 --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
|
362 return retval; |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
363 } |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
364 |
14528
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
365 static void |
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
366 finish_incsearch_highlighting( |
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
367 int gotesc, |
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
368 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
|
369 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
|
370 { |
31565
7d40c8c10a12
patch 9.0.1115: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31414
diff
changeset
|
371 if (!is_state->did_incsearch) |
7d40c8c10a12
patch 9.0.1115: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31414
diff
changeset
|
372 return; |
7d40c8c10a12
patch 9.0.1115: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31414
diff
changeset
|
373 |
7d40c8c10a12
patch 9.0.1115: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31414
diff
changeset
|
374 is_state->did_incsearch = FALSE; |
7d40c8c10a12
patch 9.0.1115: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31414
diff
changeset
|
375 if (gotesc) |
7d40c8c10a12
patch 9.0.1115: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31414
diff
changeset
|
376 curwin->w_cursor = is_state->save_cursor; |
7d40c8c10a12
patch 9.0.1115: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31414
diff
changeset
|
377 else |
14528
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
378 { |
31565
7d40c8c10a12
patch 9.0.1115: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31414
diff
changeset
|
379 if (!EQUAL_POS(is_state->save_cursor, is_state->search_start)) |
14528
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
380 { |
31565
7d40c8c10a12
patch 9.0.1115: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31414
diff
changeset
|
381 // put the '" mark at the original position |
7d40c8c10a12
patch 9.0.1115: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31414
diff
changeset
|
382 curwin->w_cursor = is_state->save_cursor; |
7d40c8c10a12
patch 9.0.1115: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31414
diff
changeset
|
383 setpcmark(); |
14528
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
384 } |
31565
7d40c8c10a12
patch 9.0.1115: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31414
diff
changeset
|
385 curwin->w_cursor = is_state->search_start; |
14528
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
386 } |
31565
7d40c8c10a12
patch 9.0.1115: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31414
diff
changeset
|
387 restore_viewstate(&is_state->old_viewstate); |
7d40c8c10a12
patch 9.0.1115: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31414
diff
changeset
|
388 highlight_match = FALSE; |
7d40c8c10a12
patch 9.0.1115: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31414
diff
changeset
|
389 |
7d40c8c10a12
patch 9.0.1115: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31414
diff
changeset
|
390 // by default search all lines |
7d40c8c10a12
patch 9.0.1115: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31414
diff
changeset
|
391 search_first_line = 0; |
7d40c8c10a12
patch 9.0.1115: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31414
diff
changeset
|
392 search_last_line = MAXLNUM; |
7d40c8c10a12
patch 9.0.1115: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31414
diff
changeset
|
393 |
7d40c8c10a12
patch 9.0.1115: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31414
diff
changeset
|
394 magic_overruled = is_state->magic_overruled_save; |
7d40c8c10a12
patch 9.0.1115: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31414
diff
changeset
|
395 |
7d40c8c10a12
patch 9.0.1115: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31414
diff
changeset
|
396 validate_cursor(); // needed for TAB |
7d40c8c10a12
patch 9.0.1115: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31414
diff
changeset
|
397 status_redraw_all(); |
7d40c8c10a12
patch 9.0.1115: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31414
diff
changeset
|
398 redraw_all_later(UPD_SOME_VALID); |
7d40c8c10a12
patch 9.0.1115: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31414
diff
changeset
|
399 if (call_update_screen) |
7d40c8c10a12
patch 9.0.1115: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31414
diff
changeset
|
400 update_screen(UPD_SOME_VALID); |
14528
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
401 } |
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
402 |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
403 /* |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
404 * 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
|
405 */ |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
406 static void |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
407 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
|
408 int firstc, |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
409 long count, |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
410 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
|
411 { |
14515
3648e74dd523
patch 8.1.0271: 'incsearch' doesn't work for :s, :g or :v
Christian Brabandt <cb@256bit.org>
parents:
14503
diff
changeset
|
412 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
|
413 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
|
414 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
|
415 #ifdef FEAT_RELTIME |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
416 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
|
417 #endif |
14528
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
418 int next_char; |
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
419 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
|
420 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
|
421 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
|
422 |
14677
7771a1ff8b99
patch 8.1.0351: 'incsearch' for :/foo/s//<Esc> changes last search pattern
Christian Brabandt <cb@256bit.org>
parents:
14652
diff
changeset
|
423 // 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
|
424 // 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
|
425 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
|
426 |
22061
d6120c97f57c
patch 8.2.1580: wildmenu does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
21883
diff
changeset
|
427 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
|
428 &skiplen, &patlen)) |
14528
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
429 { |
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 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
|
431 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
|
432 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
|
433 // 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
|
434 redrawcmd(); |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
435 return; |
14528
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
436 } |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
437 |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
438 // 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
|
439 if (char_avail()) |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
440 { |
14677
7771a1ff8b99
patch 8.1.0351: 'incsearch' for :/foo/s//<Esc> changes last search pattern
Christian Brabandt <cb@256bit.org>
parents:
14652
diff
changeset
|
441 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
|
442 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
|
443 return; |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
444 } |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
445 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
|
446 |
14515
3648e74dd523
patch 8.1.0271: 'incsearch' doesn't work for :s, :g or :v
Christian Brabandt <cb@256bit.org>
parents:
14503
diff
changeset
|
447 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
|
448 // 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
|
449 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
|
450 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
|
451 { |
676db1b7fc35
patch 8.1.0499: :2vimgrep causes an ml_get error
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
452 // 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
|
453 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
|
454 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
|
455 } |
14515
3648e74dd523
patch 8.1.0271: 'incsearch' doesn't work for :s, :g or :v
Christian Brabandt <cb@256bit.org>
parents:
14503
diff
changeset
|
456 else |
3648e74dd523
patch 8.1.0271: 'incsearch' doesn't work for :s, :g or :v
Christian Brabandt <cb@256bit.org>
parents:
14503
diff
changeset
|
457 { |
3648e74dd523
patch 8.1.0271: 'incsearch' doesn't work for :s, :g or :v
Christian Brabandt <cb@256bit.org>
parents:
14503
diff
changeset
|
458 // 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
|
459 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
|
460 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
|
461 } |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
462 |
14528
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
463 // 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
|
464 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
|
465 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
|
466 && 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
|
467 |
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
468 // 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
|
469 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
|
470 { |
14687
2982a54aa304
patch 8.1.0356: using :s with 'incsearch' prevents CTRL-R CTRL-W
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
471 found = 0; |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
472 set_no_hlsearch(TRUE); // turn off previous highlight |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
473 redraw_all_later(UPD_SOME_VALID); |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
474 } |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
475 else |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
476 { |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
477 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
|
478 |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
479 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
|
480 out_flush(); |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
481 ++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
|
482 if (!p_hls) |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
483 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
|
484 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
|
485 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
|
486 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
|
487 #ifdef FEAT_RELTIME |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
488 CLEAR_FIELD(sia); |
29071
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
29044
diff
changeset
|
489 // Set the time limit to half a second. |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
29044
diff
changeset
|
490 sia.sa_tm = 500; |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
491 #endif |
19475
5512aa74cb62
patch 8.2.0295: highlighting for :s wrong when using different separator
Bram Moolenaar <Bram@vim.org>
parents:
18886
diff
changeset
|
492 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
|
493 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
|
494 #ifdef FEAT_RELTIME |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
495 &sia |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
496 #else |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
497 NULL |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
498 #endif |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
499 ); |
14528
58ca11610819
patch 8.1.0277: 'incsearch' highlighting wrong in a few cases
Christian Brabandt <cb@256bit.org>
parents:
14524
diff
changeset
|
500 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
|
501 --emsg_off; |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
502 |
14515
3648e74dd523
patch 8.1.0271: 'incsearch' doesn't work for :s, :g or :v
Christian Brabandt <cb@256bit.org>
parents:
14503
diff
changeset
|
503 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
|
504 || 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
|
505 { |
14515
3648e74dd523
patch 8.1.0271: 'incsearch' doesn't work for :s, :g or :v
Christian Brabandt <cb@256bit.org>
parents:
14503
diff
changeset
|
506 // 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
|
507 found = 0; |
14542
116a01c73fd8
patch 8.1.0284: 'cursorline' highlighting wrong with 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
508 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
|
509 } |
14515
3648e74dd523
patch 8.1.0271: 'incsearch' doesn't work for :s, :g or :v
Christian Brabandt <cb@256bit.org>
parents:
14503
diff
changeset
|
510 |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
511 // 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
|
512 if (got_int) |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
513 { |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
514 (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
|
515 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
|
516 found = 0; |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
517 } |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
518 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
|
519 // 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
|
520 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
|
521 } |
14687
2982a54aa304
patch 8.1.0356: using :s with 'incsearch' prevents CTRL-R CTRL-W
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
522 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
|
523 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
|
524 else |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
525 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
|
526 |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
527 // 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
|
528 // 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
|
529 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
|
530 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
|
531 update_topline(); |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
532 |
14687
2982a54aa304
patch 8.1.0356: using :s with 'incsearch' prevents CTRL-R CTRL-W
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
533 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
|
534 { |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
535 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
|
536 |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
537 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
|
538 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
|
539 validate_cursor(); |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
540 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
|
541 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
|
542 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
|
543 } |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
544 else |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
545 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
|
546 |
14615
c6b41d47bac1
patch 8.1.0321: 'incsearch' regression: / highlights everything
Christian Brabandt <cb@256bit.org>
parents:
14613
diff
changeset
|
547 // 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
|
548 // Avoids a flash when typing "foo\|". |
c6b41d47bac1
patch 8.1.0321: 'incsearch' regression: / highlights everything
Christian Brabandt <cb@256bit.org>
parents:
14613
diff
changeset
|
549 if (!use_last_pat) |
c6b41d47bac1
patch 8.1.0321: 'incsearch' regression: / highlights everything
Christian Brabandt <cb@256bit.org>
parents:
14613
diff
changeset
|
550 { |
c6b41d47bac1
patch 8.1.0321: 'incsearch' regression: / highlights everything
Christian Brabandt <cb@256bit.org>
parents:
14613
diff
changeset
|
551 next_char = ccline.cmdbuff[skiplen + patlen]; |
c6b41d47bac1
patch 8.1.0321: 'incsearch' regression: / highlights everything
Christian Brabandt <cb@256bit.org>
parents:
14613
diff
changeset
|
552 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
|
553 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
|
554 && !no_hlsearch) |
14774
5e5f2d824189
patch 8.1.0399: 'hlsearch' highlight remains in other window
Christian Brabandt <cb@256bit.org>
parents:
14760
diff
changeset
|
555 { |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
556 redraw_all_later(UPD_SOME_VALID); |
14615
c6b41d47bac1
patch 8.1.0321: 'incsearch' regression: / highlights everything
Christian Brabandt <cb@256bit.org>
parents:
14613
diff
changeset
|
557 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
|
558 } |
14615
c6b41d47bac1
patch 8.1.0321: 'incsearch' regression: / highlights everything
Christian Brabandt <cb@256bit.org>
parents:
14613
diff
changeset
|
559 ccline.cmdbuff[skiplen + patlen] = next_char; |
c6b41d47bac1
patch 8.1.0321: 'incsearch' regression: / highlights everything
Christian Brabandt <cb@256bit.org>
parents:
14613
diff
changeset
|
560 } |
c6b41d47bac1
patch 8.1.0321: 'incsearch' regression: / highlights everything
Christian Brabandt <cb@256bit.org>
parents:
14613
diff
changeset
|
561 |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
562 validate_cursor(); |
31115
b7834109fefe
patch 9.0.0892: may redraw when not needed
Bram Moolenaar <Bram@vim.org>
parents:
31103
diff
changeset
|
563 |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
564 // 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
|
565 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
|
566 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
|
567 |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
568 update_screen(UPD_SOME_VALID); |
18457
71199e360948
patch 8.1.2222: accessing invalid memory
Bram Moolenaar <Bram@vim.org>
parents:
18358
diff
changeset
|
569 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
|
570 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
|
571 |
14687
2982a54aa304
patch 8.1.0356: using :s with 'incsearch' prevents CTRL-R CTRL-W
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
572 // 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
|
573 // 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
|
574 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
|
575 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
|
576 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
|
577 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
|
578 |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
579 msg_starthere(); |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
580 redrawcmdline(); |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
581 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
|
582 } |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
583 |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
584 /* |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
585 * 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
|
586 * or previous match. |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
587 * 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
|
588 */ |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
589 static int |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
590 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
|
591 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
|
592 long count, |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
593 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
|
594 int c) |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
595 { |
14515
3648e74dd523
patch 8.1.0271: 'incsearch' doesn't work for :s, :g or :v
Christian Brabandt <cb@256bit.org>
parents:
14503
diff
changeset
|
596 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
|
597 pos_T t; |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
598 char_u *pat; |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
599 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
|
600 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
|
601 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
|
602 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
|
603 |
14677
7771a1ff8b99
patch 8.1.0351: 'incsearch' for :/foo/s//<Esc> changes last search pattern
Christian Brabandt <cb@256bit.org>
parents:
14652
diff
changeset
|
604 // 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
|
605 // 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
|
606 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
|
607 |
25874
054623fc54c5
patch 8.2.3471: crash when using CTRL-T after an empty search pattern
Bram Moolenaar <Bram@vim.org>
parents:
25790
diff
changeset
|
608 if (!do_incsearch_highlighting(firstc, &search_delim, is_state, |
054623fc54c5
patch 8.2.3471: crash when using CTRL-T after an empty search pattern
Bram Moolenaar <Bram@vim.org>
parents:
25790
diff
changeset
|
609 &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
|
610 { |
7771a1ff8b99
patch 8.1.0351: 'incsearch' for :/foo/s//<Esc> changes last search pattern
Christian Brabandt <cb@256bit.org>
parents:
14652
diff
changeset
|
611 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
|
612 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
|
613 } |
14515
3648e74dd523
patch 8.1.0271: 'incsearch' doesn't work for :s, :g or :v
Christian Brabandt <cb@256bit.org>
parents:
14503
diff
changeset
|
614 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
|
615 { |
7771a1ff8b99
patch 8.1.0351: 'incsearch' for :/foo/s//<Esc> changes last search pattern
Christian Brabandt <cb@256bit.org>
parents:
14652
diff
changeset
|
616 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
|
617 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
|
618 } |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
619 |
19475
5512aa74cb62
patch 8.2.0295: highlighting for :s wrong when using different separator
Bram Moolenaar <Bram@vim.org>
parents:
18886
diff
changeset
|
620 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
|
621 { |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
622 pat = last_search_pattern(); |
25874
054623fc54c5
patch 8.2.3471: crash when using CTRL-T after an empty search pattern
Bram Moolenaar <Bram@vim.org>
parents:
25790
diff
changeset
|
623 if (pat == NULL) |
054623fc54c5
patch 8.2.3471: crash when using CTRL-T after an empty search pattern
Bram Moolenaar <Bram@vim.org>
parents:
25790
diff
changeset
|
624 { |
054623fc54c5
patch 8.2.3471: crash when using CTRL-T after an empty search pattern
Bram Moolenaar <Bram@vim.org>
parents:
25790
diff
changeset
|
625 restore_last_search_pattern(); |
054623fc54c5
patch 8.2.3471: crash when using CTRL-T after an empty search pattern
Bram Moolenaar <Bram@vim.org>
parents:
25790
diff
changeset
|
626 return FAIL; |
054623fc54c5
patch 8.2.3471: crash when using CTRL-T after an empty search pattern
Bram Moolenaar <Bram@vim.org>
parents:
25790
diff
changeset
|
627 } |
14520
20866abc790b
patch 8.1.0273: invalid memory access when using 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
14515
diff
changeset
|
628 skiplen = 0; |
14544
2b2d7ae42fb8
patch 8.1.0285: compiler warning for conversion
Christian Brabandt <cb@256bit.org>
parents:
14542
diff
changeset
|
629 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
|
630 } |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
631 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
|
632 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
|
633 |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
634 cursor_off(); |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
635 out_flush(); |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
636 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
|
637 { |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
638 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
|
639 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
|
640 // 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
|
641 // the next column. |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
642 (void)decl(&t); |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
643 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
|
644 } |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
645 else |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
646 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
|
647 if (!p_hls) |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
648 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
|
649 ++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
|
650 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
|
651 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
|
652 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
|
653 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
|
654 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
|
655 --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
|
656 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
|
657 if (i) |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
658 { |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
659 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
|
660 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
|
661 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
|
662 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
|
663 { |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
664 // 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
|
665 // 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
|
666 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
|
667 (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
|
668 } |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
669 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
|
670 { |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
671 // 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
|
672 // 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
|
673 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
|
674 (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
|
675 } |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
676 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
|
677 { |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
678 // wrap around |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
679 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
|
680 if (firstc == '?') |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
681 (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
|
682 else |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
683 (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
|
684 } |
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 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
|
687 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
|
688 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
|
689 update_topline(); |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
690 validate_cursor(); |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
691 highlight_match = TRUE; |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
692 save_viewstate(&is_state->old_viewstate); |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
693 update_screen(UPD_NOT_VALID); |
18457
71199e360948
patch 8.1.2222: accessing invalid memory
Bram Moolenaar <Bram@vim.org>
parents:
18358
diff
changeset
|
694 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
|
695 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
|
696 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
|
697 } |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
698 else |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
699 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
|
700 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
|
701 return FAIL; |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
702 } |
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 * 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
|
706 * 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
|
707 * 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
|
708 */ |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
709 static int |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
710 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
|
711 { |
19475
5512aa74cb62
patch 8.2.0295: highlighting for :s wrong when using different separator
Bram Moolenaar <Bram@vim.org>
parents:
18886
diff
changeset
|
712 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
|
713 |
14677
7771a1ff8b99
patch 8.1.0351: 'incsearch' for :/foo/s//<Esc> changes last search pattern
Christian Brabandt <cb@256bit.org>
parents:
14652
diff
changeset
|
714 // 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
|
715 // 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
|
716 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
|
717 |
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
|
718 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
|
719 &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
|
720 { |
7771a1ff8b99
patch 8.1.0351: 'incsearch' for :/foo/s//<Esc> changes last search pattern
Christian Brabandt <cb@256bit.org>
parents:
14652
diff
changeset
|
721 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
|
722 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
|
723 } |
15083
70aa5caa9f0d
patch 8.1.0552: saved last search pattern may not be restored
Bram Moolenaar <Bram@vim.org>
parents:
15064
diff
changeset
|
724 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
|
725 |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
726 // 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
|
727 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
|
728 { |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
729 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
|
730 *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
|
731 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
|
732 { |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
733 // 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
|
734 // 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
|
735 // 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
|
736 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
|
737 *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
|
738 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
|
739 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
|
740 { |
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
|
741 // 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
|
742 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
|
743 *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 } |
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 // 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
|
746 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
|
747 { |
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 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
|
749 |
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 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
|
751 { |
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
|
752 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
|
753 *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
|
754 stuffcharReadbuff(*c); |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
15083
diff
changeset
|
755 } |
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
|
756 *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
|
757 } |
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
|
758 return FAIL; |
14503
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
759 } |
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 return OK; |
4825955cb706
patch 8.1.0265: the getcmdline() function is way too big
Christian Brabandt <cb@256bit.org>
parents:
14439
diff
changeset
|
762 } |
13794
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
763 #endif |
530a6b894ae2
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
764 |
17155
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
765 #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
|
766 /* |
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
767 * 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
|
768 * 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
|
769 */ |
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
770 static int |
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
771 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
|
772 { |
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
773 int j; |
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
774 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
|
775 int u8c; |
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
776 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
|
777 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
|
778 |
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
779 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
|
780 return FALSE; |
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
781 |
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
782 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
|
783 { |
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
784 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
|
785 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
|
786 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
|
787 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
|
788 return TRUE; |
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
789 } |
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
790 return FALSE; |
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
791 } |
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
792 #endif |
da2bb80cd838
patch 8.1.1577: command line redrawn for +arabic without Arabic characters
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
793 |
14858
49b3bdf774ad
patch 8.1.0441: build failure without command line history
Christian Brabandt <cb@256bit.org>
parents:
14854
diff
changeset
|
794 void |
49b3bdf774ad
patch 8.1.0441: build failure without command line history
Christian Brabandt <cb@256bit.org>
parents:
14854
diff
changeset
|
795 cmdline_init(void) |
49b3bdf774ad
patch 8.1.0441: build failure without command line history
Christian Brabandt <cb@256bit.org>
parents:
14854
diff
changeset
|
796 { |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
797 CLEAR_FIELD(ccline); |
14858
49b3bdf774ad
patch 8.1.0441: build failure without command line history
Christian Brabandt <cb@256bit.org>
parents:
14854
diff
changeset
|
798 } |
49b3bdf774ad
patch 8.1.0441: build failure without command line history
Christian Brabandt <cb@256bit.org>
parents:
14854
diff
changeset
|
799 |
13035
89e191a2a8a7
patch 8.0.1393: too much highlighting with 'hlsearch' and 'incsearch' set
Christian Brabandt <cb@256bit.org>
parents:
12960
diff
changeset
|
800 /* |
31410
f09c92cf3786
patch 9.0.1038: function name does not match what it is used for
Bram Moolenaar <Bram@vim.org>
parents:
31293
diff
changeset
|
801 * Handle CTRL-\ pressed in Command-line mode: |
f09c92cf3786
patch 9.0.1038: function name does not match what it is used for
Bram Moolenaar <Bram@vim.org>
parents:
31293
diff
changeset
|
802 * - CTRL-\ CTRL-N goes to Normal mode |
f09c92cf3786
patch 9.0.1038: function name does not match what it is used for
Bram Moolenaar <Bram@vim.org>
parents:
31293
diff
changeset
|
803 * - CTRL-\ CTRL-G goes to Insert mode when 'insertmode' is set |
f09c92cf3786
patch 9.0.1038: function name does not match what it is used for
Bram Moolenaar <Bram@vim.org>
parents:
31293
diff
changeset
|
804 * - CTRL-\ e prompts for an expression. |
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
|
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 |
31410
f09c92cf3786
patch 9.0.1038: function name does not match what it is used for
Bram Moolenaar <Bram@vim.org>
parents:
31293
diff
changeset
|
807 cmdline_handle_ctrl_bsl(int c, int *gotesc) |
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
|
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. |
31410
f09c92cf3786
patch 9.0.1038: function name does not match what it is used for
Bram Moolenaar <Bram@vim.org>
parents:
31293
diff
changeset
|
836 * This will call getcmdline() recursively in get_expr_register(). |
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
|
837 */ |
53ed9f8a843f
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 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
|
839 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
|
840 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
|
841 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
|
842 |
53ed9f8a843f
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 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
|
844 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
|
845 { |
31410
f09c92cf3786
patch 9.0.1038: function name does not match what it is used for
Bram Moolenaar <Bram@vim.org>
parents:
31293
diff
changeset
|
846 // Evaluate the expression. Set "textlock" to avoid nasty things |
f09c92cf3786
patch 9.0.1038: function name does not match what it is used for
Bram Moolenaar <Bram@vim.org>
parents:
31293
diff
changeset
|
847 // like going to another buffer. |
29014
45c182c4f7e9
patch 8.2.5029: "textlock" is always zero
Bram Moolenaar <Bram@vim.org>
parents:
28905
diff
changeset
|
848 ++textlock; |
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
|
849 p = get_expr_line(); |
29014
45c182c4f7e9
patch 8.2.5029: "textlock" is always zero
Bram Moolenaar <Bram@vim.org>
parents:
28905
diff
changeset
|
850 --textlock; |
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
|
851 |
53ed9f8a843f
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 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
|
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 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
|
855 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
|
856 { |
53ed9f8a843f
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 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
|
858 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
|
859 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
|
860 |
53ed9f8a843f
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 // 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
|
862 // 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
|
863 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
|
864 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
|
865 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
|
866 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
|
867 |
53ed9f8a843f
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 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
|
869 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
|
870 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
|
871 } |
53ed9f8a843f
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 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
|
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 } |
53ed9f8a843f
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 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
|
876 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
|
877 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
|
878 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
|
879 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
|
880 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
|
881 } |
53ed9f8a843f
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 #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
|
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 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
|
885 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
|
886 *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
|
887 // 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
|
888 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
|
889 } |
53ed9f8a843f
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 |
53ed9f8a843f
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 * 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
|
893 * - 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
|
894 * - 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
|
895 * 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
|
896 * 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
|
897 */ |
53ed9f8a843f
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 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
|
899 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
|
900 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
|
901 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
|
902 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
|
903 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
|
904 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
|
905 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
|
906 { |
53ed9f8a843f
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 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
|
908 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
|
909 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
|
910 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
|
911 |
53ed9f8a843f
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 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
|
913 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
|
914 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
|
915 { |
53ed9f8a843f
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 '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
|
917 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
|
918 && !*did_wild_list |
27597
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27372
diff
changeset
|
919 && ((wim_flags[wim_index] & WIM_LIST) |
29881
0cc9a3001717
patch 9.0.0279: the tiny version has the popup menu but not 'wildmenu'
Bram Moolenaar <Bram@vim.org>
parents:
29865
diff
changeset
|
920 || (p_wmnu && (wim_flags[wim_index] & WIM_FULL) != 0))) |
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
|
921 { |
27597
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27372
diff
changeset
|
922 (void)showmatches(xp, |
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27372
diff
changeset
|
923 p_wmnu && ((wim_flags[wim_index] & WIM_LIST) == 0)); |
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
|
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 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
|
952 *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
|
953 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
|
954 } |
53ed9f8a843f
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 |
53ed9f8a843f
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 // 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
|
957 // "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
|
958 // 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
|
959 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
|
960 { |
53ed9f8a843f
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 // 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
|
962 // "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
|
963 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
|
964 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
|
965 if ((wim_flags[wim_index] & WIM_LIST) |
29881
0cc9a3001717
patch 9.0.0279: the tiny version has the popup menu but not 'wildmenu'
Bram Moolenaar <Bram@vim.org>
parents:
29865
diff
changeset
|
966 || (p_wmnu && (wim_flags[wim_index] & WIM_FULL) != 0)) |
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
|
967 { |
53ed9f8a843f
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 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
|
969 { |
53ed9f8a843f
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 int p_wmnu_save = p_wmnu; |
29881
0cc9a3001717
patch 9.0.0279: the tiny version has the popup menu but not 'wildmenu'
Bram Moolenaar <Bram@vim.org>
parents:
29865
diff
changeset
|
971 |
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
|
972 p_wmnu = 0; |
29881
0cc9a3001717
patch 9.0.0279: the tiny version has the popup menu but not 'wildmenu'
Bram Moolenaar <Bram@vim.org>
parents:
29865
diff
changeset
|
973 |
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
|
974 // 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
|
975 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
|
976 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
|
977 } |
53ed9f8a843f
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 (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
|
979 && ((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
|
980 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
|
981 *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
|
982 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
|
983 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
|
984 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
|
985 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
|
986 } |
53ed9f8a843f
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 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
|
988 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
|
989 } |
53ed9f8a843f
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 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
|
991 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
|
992 } |
53ed9f8a843f
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_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
|
994 ++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
|
995 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
|
996 *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
|
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 *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
|
999 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
|
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 |
53ed9f8a843f
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 /* |
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
|
1003 * 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
|
1004 * 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
|
1005 * 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
|
1006 * 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
|
1007 * 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
|
1008 */ |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1009 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
|
1010 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
|
1011 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
|
1012 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
|
1013 #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
|
1014 , 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
|
1015 #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
|
1016 ) |
e6fb7f627448
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 { |
e6fb7f627448
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 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
|
1019 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
|
1020 |
e6fb7f627448
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 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
|
1022 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
|
1023 |
e6fb7f627448
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 /* |
e6fb7f627448
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 * 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
|
1026 * 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
|
1027 */ |
e6fb7f627448
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 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
|
1029 ++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
|
1030 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
|
1031 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
|
1032 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
|
1033 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
|
1034 { |
e6fb7f627448
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 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
|
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 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
|
1038 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
|
1039 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
|
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 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
|
1042 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
|
1043 { |
e6fb7f627448
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 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
|
1045 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
|
1046 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
|
1047 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
|
1048 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
|
1049 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
|
1050 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
|
1051 } |
e6fb7f627448
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 } |
e6fb7f627448
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 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
|
1054 { |
e6fb7f627448
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 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
|
1056 --p; |
28749
4a9fdf708575
patch 8.2.4899: with latin1 encoding CTRL-W might go before the cmdline
Bram Moolenaar <Bram@vim.org>
parents:
28560
diff
changeset
|
1057 if (p > ccline.cmdbuff) |
4a9fdf708575
patch 8.2.4899: with latin1 encoding CTRL-W might go before the cmdline
Bram Moolenaar <Bram@vim.org>
parents:
28560
diff
changeset
|
1058 { |
4a9fdf708575
patch 8.2.4899: with latin1 encoding CTRL-W might go before the cmdline
Bram Moolenaar <Bram@vim.org>
parents:
28560
diff
changeset
|
1059 i = vim_iswordc(p[-1]); |
4a9fdf708575
patch 8.2.4899: with latin1 encoding CTRL-W might go before the cmdline
Bram Moolenaar <Bram@vim.org>
parents:
28560
diff
changeset
|
1060 while (p > ccline.cmdbuff && !vim_isspace(p[-1]) |
4a9fdf708575
patch 8.2.4899: with latin1 encoding CTRL-W might go before the cmdline
Bram Moolenaar <Bram@vim.org>
parents:
28560
diff
changeset
|
1061 && vim_iswordc(p[-1]) == i) |
4a9fdf708575
patch 8.2.4899: with latin1 encoding CTRL-W might go before the cmdline
Bram Moolenaar <Bram@vim.org>
parents:
28560
diff
changeset
|
1062 --p; |
4a9fdf708575
patch 8.2.4899: with latin1 encoding CTRL-W might go before the cmdline
Bram Moolenaar <Bram@vim.org>
parents:
28560
diff
changeset
|
1063 } |
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
|
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 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
|
1066 --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
|
1067 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
|
1068 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
|
1069 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
|
1070 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
|
1071 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
|
1072 |
e6fb7f627448
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 // 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
|
1074 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
|
1075 #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
|
1076 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
|
1077 { |
e6fb7f627448
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 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
|
1079 // 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
|
1080 // 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
|
1081 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
|
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 #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
|
1084 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
|
1085 } |
e6fb7f627448
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 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
|
1087 && 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
|
1088 { |
e6fb7f627448
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 // 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
|
1090 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
|
1091 #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
|
1092 || 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
|
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 ) |
e6fb7f627448
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 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
|
1096 |
e6fb7f627448
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 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
|
1098 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
|
1099 { |
e6fb7f627448
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 #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
|
1101 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
|
1102 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
|
1103 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
|
1104 #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
|
1105 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
|
1106 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
|
1107 } |
e6fb7f627448
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 #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
|
1109 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
|
1110 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
|
1111 #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
|
1112 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
|
1113 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
|
1114 } |
e6fb7f627448
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 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
|
1116 } |
e6fb7f627448
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 /* |
e6fb7f627448
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 * 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
|
1120 * 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
|
1121 */ |
e6fb7f627448
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 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
|
1123 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
|
1124 { |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28771
diff
changeset
|
1125 if (map_to_exists_mode((char_u *)"", MODE_LANGMAP, FALSE)) |
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
|
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 // ":lmap" mappings exists, toggle use of mappings. |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28771
diff
changeset
|
1128 State ^= MODE_LANGMAP; |
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
|
1129 #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
|
1130 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
|
1131 #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
|
1132 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
|
1133 { |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28771
diff
changeset
|
1134 if (State & MODE_LANGMAP) |
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
|
1135 *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
|
1136 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
|
1137 *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
|
1138 } |
e6fb7f627448
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 } |
e6fb7f627448
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 #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
|
1141 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
|
1142 { |
e6fb7f627448
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 // 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
|
1144 // '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
|
1145 // 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
|
1146 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
|
1147 ? *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
|
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 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
|
1150 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
|
1151 *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
|
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 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
|
1154 { |
e6fb7f627448
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 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
|
1156 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
|
1157 *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
|
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 } |
e6fb7f627448
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 #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
|
1161 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
|
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 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
|
1164 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
|
1165 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
|
1166 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
|
1167 } |
e6fb7f627448
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 #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
|
1169 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
|
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 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
|
1172 // 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
|
1173 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
|
1174 #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
|
1175 } |
e6fb7f627448
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 |
e6fb7f627448
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 * 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
|
1179 * 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
|
1180 */ |
e6fb7f627448
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 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
|
1182 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
|
1183 { |
e6fb7f627448
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 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
|
1185 int c; |
29261
2f2c3448a337
patch 8.2.5149: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
29259
diff
changeset
|
1186 #ifdef FEAT_EVAL |
29259
a5846b82119b
patch 8.2.5148: invalid memory access when using expression on command line
Bram Moolenaar <Bram@vim.org>
parents:
29173
diff
changeset
|
1187 int save_new_cmdpos = new_cmdpos; |
29261
2f2c3448a337
patch 8.2.5149: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
29259
diff
changeset
|
1188 #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
|
1189 |
e6fb7f627448
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 #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
|
1191 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
|
1192 #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
|
1193 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
|
1194 ++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
|
1195 ++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
|
1196 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
|
1197 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
|
1198 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
|
1199 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
|
1200 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
|
1201 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
|
1202 --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
|
1203 --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
|
1204 #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
|
1205 /* |
e6fb7f627448
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 * 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
|
1207 */ |
e6fb7f627448
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 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
|
1209 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
|
1210 { |
e6fb7f627448
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 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
|
1212 || 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
|
1213 { |
e6fb7f627448
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 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
|
1215 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
|
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 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
|
1218 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
|
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 #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
|
1221 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
|
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 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
|
1224 |
e6fb7f627448
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 #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
|
1226 // 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
|
1227 // 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
|
1228 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
|
1229 { |
e6fb7f627448
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 *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
|
1231 // 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
|
1232 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
|
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 #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
|
1235 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
|
1236 #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
|
1237 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
|
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 // 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
|
1240 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
|
1241 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
|
1242 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
|
1243 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
|
1244 } |
e6fb7f627448
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 #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
|
1246 } |
29261
2f2c3448a337
patch 8.2.5149: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
29259
diff
changeset
|
1247 #ifdef FEAT_EVAL |
29259
a5846b82119b
patch 8.2.5148: invalid memory access when using expression on command line
Bram Moolenaar <Bram@vim.org>
parents:
29173
diff
changeset
|
1248 new_cmdpos = save_new_cmdpos; |
29261
2f2c3448a337
patch 8.2.5149: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
29259
diff
changeset
|
1249 #endif |
29259
a5846b82119b
patch 8.2.5148: invalid memory access when using expression on command line
Bram Moolenaar <Bram@vim.org>
parents:
29173
diff
changeset
|
1250 |
24663
ce7a80bd0fd5
patch 8.2.2870: CmdlineChange event triggered twice for CTRL-R
Bram Moolenaar <Bram@vim.org>
parents:
24628
diff
changeset
|
1251 // 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
|
1252 redrawcmd(); |
24663
ce7a80bd0fd5
patch 8.2.2870: CmdlineChange event triggered twice for CTRL-R
Bram Moolenaar <Bram@vim.org>
parents:
24628
diff
changeset
|
1253 |
ce7a80bd0fd5
patch 8.2.2870: CmdlineChange event triggered twice for CTRL-R
Bram Moolenaar <Bram@vim.org>
parents:
24628
diff
changeset
|
1254 // 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
|
1255 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
|
1256 } |
e6fb7f627448
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 |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1258 /* |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
1259 * 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
|
1260 */ |
e6fb7f627448
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 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
|
1262 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
|
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 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
|
1265 *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
|
1266 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
|
1267 *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
|
1268 # 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
|
1269 // 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
|
1270 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
|
1271 # 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
|
1272 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
|
1273 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
|
1274 # 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
|
1275 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
|
1276 { |
e6fb7f627448
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 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
|
1278 |
e6fb7f627448
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 /* |
e6fb7f627448
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 * 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
|
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 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
|
1283 &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
|
1284 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
|
1285 && (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
|
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 // 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
|
1288 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
|
1289 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
|
1290 } |
e6fb7f627448
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 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
|
1292 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
|
1293 } |
e6fb7f627448
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 # 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
|
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 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
|
1297 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
|
1298 ++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
|
1299 { |
e6fb7f627448
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 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
|
1301 |
e6fb7f627448
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 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
|
1303 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
|
1304 && 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
|
1305 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
|
1306 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
|
1307 { |
e6fb7f627448
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 // 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
|
1309 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
|
1310 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
|
1311 + 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
|
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 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
|
1314 } |
e6fb7f627448
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 } |
e6fb7f627448
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 |
e6fb7f627448
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 * 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
|
1319 * 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
|
1320 * 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
|
1321 * 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
|
1322 * 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
|
1323 * 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
|
1324 */ |
e6fb7f627448
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 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
|
1326 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
|
1327 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
|
1328 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
|
1329 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
|
1330 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
|
1331 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
|
1332 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
|
1333 { |
e6fb7f627448
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 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
|
1335 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
|
1336 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
|
1337 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
|
1338 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
|
1339 |
e6fb7f627448
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 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
|
1341 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
|
1342 |
e6fb7f627448
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 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
|
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 // 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
|
1346 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
|
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 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
|
1349 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
|
1350 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
|
1351 } |
e6fb7f627448
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 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
|
1354 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
|
1355 { |
e6fb7f627448
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 // 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
|
1357 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
|
1358 || 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
|
1359 { |
e6fb7f627448
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 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
|
1361 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
|
1362 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
|
1363 != 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
|
1364 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
|
1365 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
|
1366 --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
|
1367 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
|
1368 { |
e6fb7f627448
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 = 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
|
1370 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
|
1371 } |
e6fb7f627448
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 } |
e6fb7f627448
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 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
|
1374 { |
e6fb7f627448
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 // 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
|
1376 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
|
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 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
|
1379 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
|
1380 } |
e6fb7f627448
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 |
e6fb7f627448
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 // 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
|
1383 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
|
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 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
|
1386 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
|
1387 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
|
1388 ++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
|
1389 } |
e6fb7f627448
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 < 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
|
1391 == 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
|
1392 { |
e6fb7f627448
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 = 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
|
1394 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
|
1395 } |
e6fb7f627448
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 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
|
1397 || 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
|
1398 || 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
|
1399 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
|
1400 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
|
1401 } |
e6fb7f627448
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 |
e6fb7f627448
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 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
|
1404 { |
e6fb7f627448
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 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
|
1406 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
|
1407 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
|
1408 |
e6fb7f627448
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 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
|
1410 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
|
1411 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
|
1412 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
|
1413 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
|
1414 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
|
1415 |
e6fb7f627448
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 (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
|
1417 && 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
|
1418 && (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
|
1419 { |
e6fb7f627448
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 // 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
|
1421 // 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
|
1422 // 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
|
1423 // 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
|
1424 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
|
1425 { |
e6fb7f627448
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 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
|
1427 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
|
1428 { |
e6fb7f627448
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 // 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
|
1430 // 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
|
1431 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
|
1432 && (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
|
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 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
|
1435 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
|
1436 } |
e6fb7f627448
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 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
|
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 // 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
|
1440 // 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
|
1441 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
|
1442 && (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
|
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 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
|
1445 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
|
1446 ++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
|
1447 } |
e6fb7f627448
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 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
|
1449 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
|
1450 } |
e6fb7f627448
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 { |
e6fb7f627448
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 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
|
1456 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
|
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 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
|
1459 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
|
1460 } |
e6fb7f627448
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 } |
e6fb7f627448
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 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
|
1464 } |
e6fb7f627448
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 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
|
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 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
|
1468 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
|
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 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
|
1471 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
|
1472 } |
e6fb7f627448
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 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
|
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 |
e6fb7f627448
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 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
|
1477 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
|
1478 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
|
1479 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
|
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 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
|
1482 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
|
1483 |
e6fb7f627448
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 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 *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
|
1486 *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
|
1487 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
|
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 |
e6fb7f627448
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 /* |
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
|
1491 * 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
|
1492 */ |
53ed9f8a843f
patch 8.2.1634: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22145
diff
changeset
|
1493 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
|
1494 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
|
1495 { |
53ed9f8a843f
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 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
|
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 /* |
53ed9f8a843f
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 * 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
|
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.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
|
1502 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
|
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 // alloc initial ccline.cmdbuff |
27372
81d391f7c189
patch 8.2.4214: illegal memory access with large 'tabstop' in Ex mode
Bram Moolenaar <Bram@vim.org>
parents:
27140
diff
changeset
|
1505 alloc_cmdbuff(indent + 50); |
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
|
1506 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
|
1507 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
|
1508 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
|
1509 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
|
1510 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
|
1511 |
53ed9f8a843f
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 // 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
|
1513 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
|
1514 { |
53ed9f8a843f
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 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
|
1516 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
|
1517 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
|
1518 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
|
1519 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
|
1520 } |
53ed9f8a843f
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 |
53ed9f8a843f
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 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
|
1523 } |
53ed9f8a843f
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 |
53ed9f8a843f
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 /* |
7 | 1526 * getcmdline() - accept a command line starting with firstc. |
1527 * | |
1528 * firstc == ':' get ":" command line. | |
1529 * firstc == '/' or '?' get search pattern | |
1530 * firstc == '=' get expression | |
1531 * firstc == '@' get text for input() function | |
1532 * firstc == '>' get text for debug mode | |
1533 * firstc == NUL get text for :insert command | |
1534 * firstc == -1 like NUL, and break on CTRL-C | |
1535 * | |
1536 * The line is collected in ccline.cmdbuff, which is reallocated to fit the | |
1537 * command line. | |
1538 * | |
1539 * Careful: getcmdline() can be called recursively! | |
1540 * | |
1541 * Return pointer to allocated string if there is a commandline, NULL | |
1542 * otherwise. | |
1543 */ | |
1544 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
1545 getcmdline( |
26804
34f1b7d6974a
patch 8.2.3930: getcmdline() argument has a misleading type
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
1546 int firstc, |
34f1b7d6974a
patch 8.2.3930: getcmdline() argument has a misleading type
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
1547 long count, // only used for incremental search |
34f1b7d6974a
patch 8.2.3930: getcmdline() argument has a misleading type
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
1548 int indent, // indent for inside conditionals |
34f1b7d6974a
patch 8.2.3930: getcmdline() argument has a misleading type
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
1549 getline_opt_T 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
|
1550 { |
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
1551 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
|
1552 } |
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
1553 |
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
1554 static char_u * |
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
1555 getcmdline_int( |
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
1556 int firstc, |
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
1557 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
|
1558 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
|
1559 int clear_ccline) // clear ccline first |
7 | 1560 { |
28905
f3f45218f923
patch 8.2.4975: recursive command line loop may cause a crash
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
1561 static int depth = 0; // call depth |
7 | 1562 int c; |
1563 int i; | |
1564 int j; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1565 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
|
1566 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
|
1567 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
|
1568 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
|
1569 int histype; // history type to be used |
7 | 1570 #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
|
1571 incsearch_state_T is_state; |
7 | 1572 #endif |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1573 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
|
1574 int wim_index = 0; // index in wim_flags[] |
7 | 1575 int res; |
1576 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
|
1577 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
|
1578 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
|
1579 // 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
|
1580 // preceded with a mouse down event |
7 | 1581 int ignore_drag_release = TRUE; |
1582 #ifdef FEAT_EVAL | |
1583 int break_ctrl_c = FALSE; | |
1584 #endif | |
1585 expand_T xpc; | |
1586 long *b_im_ptr = NULL; | |
30308
6b541aaaf39e
patch 9.0.0490: using freed memory with cmdwin and BufEnter autocmd
Bram Moolenaar <Bram@vim.org>
parents:
30267
diff
changeset
|
1587 buf_T *b_im_ptr_buf = NULL; // buffer where b_im_ptr is valid |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
1588 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
|
1589 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
|
1590 int cmdline_type; |
28121
4765d97b4d8b
patch 8.2.4585: cannot use keypad page-up/down for completion menu
Bram Moolenaar <Bram@vim.org>
parents:
28109
diff
changeset
|
1591 int wild_type; |
7 | 1592 |
28905
f3f45218f923
patch 8.2.4975: recursive command line loop may cause a crash
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
1593 // one recursion level deeper |
f3f45218f923
patch 8.2.4975: recursive command line loop may cause a crash
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
1594 ++depth; |
f3f45218f923
patch 8.2.4975: recursive command line loop may cause a crash
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
1595 |
14854
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
1596 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
|
1597 { |
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
1598 // 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
|
1599 // 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
|
1600 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
|
1601 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
|
1602 } |
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
|
1603 if (clear_ccline) |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
1604 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
|
1605 |
7 | 1606 #ifdef FEAT_EVAL |
1607 if (firstc == -1) | |
1608 { | |
1609 firstc = NUL; | |
1610 break_ctrl_c = TRUE; | |
1611 } | |
1612 #endif | |
1613 #ifdef FEAT_RIGHTLEFT | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1614 // start without Hebrew mapping for a command line |
7 | 1615 if (firstc == ':' || firstc == '=' || firstc == '>') |
1616 cmd_hkmap = 0; | |
1617 #endif | |
1618 | |
1619 #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
|
1620 init_incsearch_state(&is_state); |
7 | 1621 #endif |
1622 | |
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
|
1623 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
|
1624 goto theend; // out of memory |
164 | 1625 |
28905
f3f45218f923
patch 8.2.4975: recursive command line loop may cause a crash
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
1626 if (depth == 50) |
f3f45218f923
patch 8.2.4975: recursive command line loop may cause a crash
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
1627 { |
f3f45218f923
patch 8.2.4975: recursive command line loop may cause a crash
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
1628 // Somehow got into a loop recursively calling getcmdline(), bail out. |
f3f45218f923
patch 8.2.4975: recursive command line loop may cause a crash
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
1629 emsg(_(e_command_too_recursive)); |
f3f45218f923
patch 8.2.4975: recursive command line loop may cause a crash
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
1630 goto theend; |
f3f45218f923
patch 8.2.4975: recursive command line loop may cause a crash
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
1631 } |
f3f45218f923
patch 8.2.4975: recursive command line loop may cause a crash
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
1632 |
7 | 1633 ExpandInit(&xpc); |
1718 | 1634 ccline.xpc = &xpc; |
7 | 1635 |
1636 #ifdef FEAT_RIGHTLEFT | |
1637 if (curwin->w_p_rl && *curwin->w_p_rlc == 's' | |
1638 && (firstc == '/' || firstc == '?')) | |
1639 cmdmsg_rl = TRUE; | |
1640 else | |
1641 cmdmsg_rl = FALSE; | |
1642 #endif | |
1643 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1644 redir_off = TRUE; // don't redirect the typed command |
7 | 1645 if (!cmd_silent) |
1646 { | |
1647 i = msg_scrolled; | |
29960
4fcf816aa806
patch 9.0.0318: clearing screen causes flicker
Bram Moolenaar <Bram@vim.org>
parents:
29956
diff
changeset
|
1648 msg_scrolled = 0; // avoid wait_return() message |
7 | 1649 gotocmdline(TRUE); |
1650 msg_scrolled += i; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1651 redrawcmdprompt(); // draw prompt or indent |
7 | 1652 set_cmdspos(); |
1653 } | |
1654 xpc.xp_context = EXPAND_NOTHING; | |
1655 xpc.xp_backslash = XP_BS_NONE; | |
632 | 1656 #ifndef BACKSLASH_IN_FILENAME |
1657 xpc.xp_shell = FALSE; | |
1658 #endif | |
7 | 1659 |
531 | 1660 #if defined(FEAT_EVAL) |
1661 if (ccline.input_fn) | |
1662 { | |
1663 xpc.xp_context = ccline.xp_context; | |
1664 xpc.xp_pattern = ccline.cmdbuff; | |
1665 xpc.xp_arg = ccline.xp_arg; | |
1666 } | |
1667 #endif | |
1668 | |
7 | 1669 /* |
1670 * Avoid scrolling when called by a recursive do_cmdline(), e.g. when | |
1671 * doing ":@0" when register 0 doesn't contain a CR. | |
1672 */ | |
1673 msg_scroll = FALSE; | |
1674 | |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28771
diff
changeset
|
1675 State = MODE_CMDLINE; |
7 | 1676 |
1677 if (firstc == '/' || firstc == '?' || firstc == '@') | |
1678 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1679 // Use ":lmap" mappings for search pattern and input(). |
7 | 1680 if (curbuf->b_p_imsearch == B_IMODE_USE_INSERT) |
1681 b_im_ptr = &curbuf->b_p_iminsert; | |
1682 else | |
1683 b_im_ptr = &curbuf->b_p_imsearch; | |
30308
6b541aaaf39e
patch 9.0.0490: using freed memory with cmdwin and BufEnter autocmd
Bram Moolenaar <Bram@vim.org>
parents:
30267
diff
changeset
|
1684 b_im_ptr_buf = curbuf; |
7 | 1685 if (*b_im_ptr == B_IMODE_LMAP) |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28771
diff
changeset
|
1686 State |= MODE_LANGMAP; |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13256
diff
changeset
|
1687 #ifdef HAVE_INPUT_METHOD |
7 | 1688 im_set_active(*b_im_ptr == B_IMODE_IM); |
1689 #endif | |
1690 } | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13256
diff
changeset
|
1691 #ifdef HAVE_INPUT_METHOD |
7 | 1692 else if (p_imcmdline) |
1693 im_set_active(TRUE); | |
1694 #endif | |
1695 | |
1696 setmouse(); | |
1697 #ifdef CURSOR_SHAPE | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1698 ui_cursor_shape(); // may show different cursor shape |
7 | 1699 #endif |
1700 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1701 // 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
|
1702 // terminal mode set to cooked. Need to set raw mode here then. |
571 | 1703 settmode(TMODE_RAW); |
1704 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1705 // 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
|
1706 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
|
1707 trigger_cmd_autocmd(cmdline_type, EVENT_CMDLINEENTER); |
25790
16a7d1154be8
patch 8.2.3430: no generic way to trigger an autocommand on mode change
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
1708 #ifdef FEAT_EVAL |
16a7d1154be8
patch 8.2.3430: no generic way to trigger an autocommand on mode change
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
1709 if (!debug_mode) |
28397
d1702731786c
patch 8.2.4723: the ModeChanged autocmd event is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28121
diff
changeset
|
1710 may_trigger_modechanged(); |
25790
16a7d1154be8
patch 8.2.3430: no generic way to trigger an autocommand on mode change
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
1711 #endif |
12656
0a9dacb8826a
patch 8.0.1206: no autocmd for entering or leaving the command line
Christian Brabandt <cb@256bit.org>
parents:
12529
diff
changeset
|
1712 |
7 | 1713 init_history(); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1714 hiscnt = get_hislen(); // set hiscnt to impossible history value |
7 | 1715 histype = hist_char2type(firstc); |
1716 | |
1717 #ifdef FEAT_DIGRAPHS | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1718 do_digraph(-1); // init digraph typeahead |
7 | 1719 #endif |
1720 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1721 // 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
|
1722 // and execute commands. Display may be messed up a bit. |
5993 | 1723 if (did_emsg) |
1724 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
|
1725 |
24297
6b7ab048eaae
patch 8.2.2689: tiny build fails
Bram Moolenaar <Bram@vim.org>
parents:
24291
diff
changeset
|
1726 #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
|
1727 // 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
|
1728 // 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
|
1729 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
|
1730 { |
24394
5858745d393a
patch 8.2.2737: status line not updated when local 'statusline' option set
Bram Moolenaar <Bram@vim.org>
parents:
24297
diff
changeset
|
1731 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
|
1732 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
|
1733 |
5858745d393a
patch 8.2.2737: status line not updated when local 'statusline' option set
Bram Moolenaar <Bram@vim.org>
parents:
24297
diff
changeset
|
1734 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
|
1735 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
|
1736 { |
5858745d393a
patch 8.2.2737: status line not updated when local 'statusline' option set
Bram Moolenaar <Bram@vim.org>
parents:
24297
diff
changeset
|
1737 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
|
1738 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
|
1739 } |
29489
7c639dff32dd
patch 9.0.0086: tabline is not redrawn when entering command line
Bram Moolenaar <Bram@vim.org>
parents:
29483
diff
changeset
|
1740 |
7c639dff32dd
patch 9.0.0086: tabline is not redrawn when entering command line
Bram Moolenaar <Bram@vim.org>
parents:
29483
diff
changeset
|
1741 if (*p_tal != NUL) |
7c639dff32dd
patch 9.0.0086: tabline is not redrawn when entering command line
Bram Moolenaar <Bram@vim.org>
parents:
29483
diff
changeset
|
1742 { |
7c639dff32dd
patch 9.0.0086: tabline is not redrawn when entering command line
Bram Moolenaar <Bram@vim.org>
parents:
29483
diff
changeset
|
1743 redraw_tabline = TRUE; |
7c639dff32dd
patch 9.0.0086: tabline is not redrawn when entering command line
Bram Moolenaar <Bram@vim.org>
parents:
29483
diff
changeset
|
1744 found_one = TRUE; |
7c639dff32dd
patch 9.0.0086: tabline is not redrawn when entering command line
Bram Moolenaar <Bram@vim.org>
parents:
29483
diff
changeset
|
1745 } |
7c639dff32dd
patch 9.0.0086: tabline is not redrawn when entering command line
Bram Moolenaar <Bram@vim.org>
parents:
29483
diff
changeset
|
1746 |
24394
5858745d393a
patch 8.2.2737: status line not updated when local 'statusline' option set
Bram Moolenaar <Bram@vim.org>
parents:
24297
diff
changeset
|
1747 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
|
1748 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
|
1749 } |
24297
6b7ab048eaae
patch 8.2.2689: tiny build fails
Bram Moolenaar <Bram@vim.org>
parents:
24291
diff
changeset
|
1750 #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
|
1751 |
5993 | 1752 did_emsg = FALSE; |
1753 got_int = FALSE; | |
1754 | |
7 | 1755 /* |
1756 * Collect the command string, handling editing keys. | |
1757 */ | |
1758 for (;;) | |
1759 { | |
24628
447426630e44
patch 8.2.2853: window is not updated after using <Cmd> mapping
Bram Moolenaar <Bram@vim.org>
parents:
24624
diff
changeset
|
1760 int trigger_cmdlinechanged = TRUE; |
28109
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27887
diff
changeset
|
1761 int end_wildmenu; |
24628
447426630e44
patch 8.2.2853: window is not updated after using <Cmd> mapping
Bram Moolenaar <Bram@vim.org>
parents:
24624
diff
changeset
|
1762 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1763 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
|
1764 // Repeated, because a ":redir" inside |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1765 // completion may switch it on. |
7 | 1766 #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
|
1767 dont_scroll = FALSE; // allow scrolling here |
7 | 1768 #endif |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1769 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
|
1770 |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1771 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
|
1772 // 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
|
1773 // 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
|
1774 |
18098
a2870e6f5b45
patch 8.1.2044: no easy way to process postponed work
Bram Moolenaar <Bram@vim.org>
parents:
18043
diff
changeset
|
1775 // 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
|
1776 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
|
1777 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1778 // 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
|
1779 // anything, such as stop completion. |
1472 | 1780 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
|
1781 { |
5a7db84713dc
patch 8.2.1983: ml_get error when using <Cmd> to open a terminal
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1782 cursorcmd(); // set the cursor on the right spot |
1472 | 1783 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
|
1784 } while (c == K_IGNORE || c == K_NOP); |
1472 | 1785 |
27140
a9eeb18e749c
patch 8.2.4099: Vim9: cannot use Vim9 syntax in mapping
Bram Moolenaar <Bram@vim.org>
parents:
27032
diff
changeset
|
1786 if (c == K_COMMAND || c == K_SCRIPT_COMMAND) |
24624
c6aaf1742634
patch 8.2.2851: using <Cmd> mapping on the command line triggers CmdlineChanged
Bram Moolenaar <Bram@vim.org>
parents:
24394
diff
changeset
|
1787 { |
31414
ca083d0199c6
patch 9.0.1040: test for <Cmd> mapping with CmdlineChanged fails
Bram Moolenaar <Bram@vim.org>
parents:
31412
diff
changeset
|
1788 int clen = ccline.cmdlen; |
31412
742b7bf2fefc
patch 9.0.1039: using a <Cmd> mapping CmdlineChanged may be triggered twice
Bram Moolenaar <Bram@vim.org>
parents:
31410
diff
changeset
|
1789 int cc_count = aucmd_cmdline_changed_count; |
24624
c6aaf1742634
patch 8.2.2851: using <Cmd> mapping on the command line triggers CmdlineChanged
Bram Moolenaar <Bram@vim.org>
parents:
24394
diff
changeset
|
1790 |
27140
a9eeb18e749c
patch 8.2.4099: Vim9: cannot use Vim9 syntax in mapping
Bram Moolenaar <Bram@vim.org>
parents:
27032
diff
changeset
|
1791 if (do_cmdkey_command(c, DOCMD_NOWAIT) == OK) |
24624
c6aaf1742634
patch 8.2.2851: using <Cmd> mapping on the command line triggers CmdlineChanged
Bram Moolenaar <Bram@vim.org>
parents:
24394
diff
changeset
|
1792 { |
31414
ca083d0199c6
patch 9.0.1040: test for <Cmd> mapping with CmdlineChanged fails
Bram Moolenaar <Bram@vim.org>
parents:
31412
diff
changeset
|
1793 // Do not trigger CmdlineChanged below if: |
ca083d0199c6
patch 9.0.1040: test for <Cmd> mapping with CmdlineChanged fails
Bram Moolenaar <Bram@vim.org>
parents:
31412
diff
changeset
|
1794 // - the length of the command line didn't change |
ca083d0199c6
patch 9.0.1040: test for <Cmd> mapping with CmdlineChanged fails
Bram Moolenaar <Bram@vim.org>
parents:
31412
diff
changeset
|
1795 // - the <Cmd> mapping already triggered the event |
ca083d0199c6
patch 9.0.1040: test for <Cmd> mapping with CmdlineChanged fails
Bram Moolenaar <Bram@vim.org>
parents:
31412
diff
changeset
|
1796 if (clen == ccline.cmdlen |
ca083d0199c6
patch 9.0.1040: test for <Cmd> mapping with CmdlineChanged fails
Bram Moolenaar <Bram@vim.org>
parents:
31412
diff
changeset
|
1797 || cc_count != aucmd_cmdline_changed_count) |
24628
447426630e44
patch 8.2.2853: window is not updated after using <Cmd> mapping
Bram Moolenaar <Bram@vim.org>
parents:
24624
diff
changeset
|
1798 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
|
1799 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
|
1800 } |
c6aaf1742634
patch 8.2.2851: using <Cmd> mapping on the command line triggers CmdlineChanged
Bram Moolenaar <Bram@vim.org>
parents:
24394
diff
changeset
|
1801 } |
22862
6d50182e7e24
patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
1802 |
7 | 1803 if (KeyTyped) |
1804 { | |
1805 some_key_typed = TRUE; | |
1806 #ifdef FEAT_RIGHTLEFT | |
1807 if (cmd_hkmap) | |
1808 c = hkmap(c); | |
1809 if (cmdmsg_rl && !KeyStuffed) | |
1810 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1811 // 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
|
1812 // 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
|
1813 // mapping. |
7 | 1814 switch (c) |
1815 { | |
1816 case K_RIGHT: c = K_LEFT; break; | |
1817 case K_S_RIGHT: c = K_S_LEFT; break; | |
1818 case K_C_RIGHT: c = K_C_LEFT; break; | |
1819 case K_LEFT: c = K_RIGHT; break; | |
1820 case K_S_LEFT: c = K_S_RIGHT; break; | |
1821 case K_C_LEFT: c = K_C_RIGHT; break; | |
1822 } | |
1823 } | |
1824 #endif | |
1825 } | |
1826 | |
1827 /* | |
1828 * Ignore got_int when CTRL-C was typed here. | |
1829 * Don't ignore it in :global, we really need to break then, e.g., for | |
1830 * ":g/pat/normal /pat" (without the <CR>). | |
1831 * Don't ignore it for the input() function. | |
1832 */ | |
1833 if ((c == Ctrl_C | |
1834 #ifdef UNIX | |
1835 || c == intr_char | |
1836 #endif | |
1837 ) | |
1838 #if defined(FEAT_EVAL) || defined(FEAT_CRYPT) | |
1839 && firstc != '@' | |
1840 #endif | |
1841 #ifdef FEAT_EVAL | |
29481
34bb46847ba0
patch 9.0.0082: cannot interrupt global command from command line
Bram Moolenaar <Bram@vim.org>
parents:
29419
diff
changeset
|
1842 // do clear got_int in Ex mode to avoid infinite Ctrl-C loop |
34bb46847ba0
patch 9.0.0082: cannot interrupt global command from command line
Bram Moolenaar <Bram@vim.org>
parents:
29419
diff
changeset
|
1843 && (!break_ctrl_c || exmode_active) |
7 | 1844 #endif |
1845 && !global_busy) | |
1846 got_int = FALSE; | |
1847 | |
17652
9efb4dda9720
patch 8.1.1823: command line history code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17588
diff
changeset
|
1848 // 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
|
1849 // list |
7 | 1850 if (lookfor != NULL |
180 | 1851 && c != K_S_DOWN && c != K_S_UP |
230 | 1852 && c != K_DOWN && c != K_UP |
7 | 1853 && c != K_PAGEDOWN && c != K_PAGEUP |
1854 && c != K_KPAGEDOWN && c != K_KPAGEUP | |
230 | 1855 && c != K_LEFT && c != K_RIGHT |
7 | 1856 && (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
|
1857 VIM_CLEAR(lookfor); |
7 | 1858 |
1859 /* | |
1718 | 1860 * When there are matching completions to select <S-Tab> works like |
1861 * CTRL-P (unless 'wc' is <S-Tab>). | |
7 | 1862 */ |
1718 | 1863 if (c != p_wc && c == K_S_TAB && xpc.xp_numfiles > 0) |
7 | 1864 c = Ctrl_P; |
1865 | |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27626
diff
changeset
|
1866 if (p_wmnu) |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27626
diff
changeset
|
1867 c = wildmenu_translate_key(&ccline, c, &xpc, did_wild_list); |
27597
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27372
diff
changeset
|
1868 |
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27372
diff
changeset
|
1869 if (cmdline_pum_active()) |
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27372
diff
changeset
|
1870 { |
27626
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27603
diff
changeset
|
1871 // Ctrl-Y: Accept the current selection and close the popup menu. |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27603
diff
changeset
|
1872 // Ctrl-E: cancel the cmdline popup menu and return the original |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27603
diff
changeset
|
1873 // text. |
27597
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27372
diff
changeset
|
1874 if (c == Ctrl_E || c == Ctrl_Y) |
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27372
diff
changeset
|
1875 { |
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27372
diff
changeset
|
1876 wild_type = (c == Ctrl_E) ? WILD_CANCEL : WILD_APPLY; |
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27372
diff
changeset
|
1877 if (nextwild(&xpc, wild_type, WILD_NO_BEEP, |
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27372
diff
changeset
|
1878 firstc != '@') == FAIL) |
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27372
diff
changeset
|
1879 break; |
27626
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27603
diff
changeset
|
1880 c = Ctrl_E; |
27597
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27372
diff
changeset
|
1881 } |
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27372
diff
changeset
|
1882 } |
7 | 1883 |
28109
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27887
diff
changeset
|
1884 // The wildmenu is cleared if the pressed key is not used for |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27887
diff
changeset
|
1885 // navigating the wild menu (i.e. the key is not 'wildchar' or |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27887
diff
changeset
|
1886 // 'wildcharm' or Ctrl-N or Ctrl-P or Ctrl-A or Ctrl-L). |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27887
diff
changeset
|
1887 // If the popup menu is displayed, then PageDown and PageUp keys are |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27887
diff
changeset
|
1888 // also used to navigate the menu. |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27887
diff
changeset
|
1889 end_wildmenu = (!(c == p_wc && KeyTyped) && c != p_wcm |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27887
diff
changeset
|
1890 && c != Ctrl_N && c != Ctrl_P && c != Ctrl_A && c != Ctrl_L); |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27887
diff
changeset
|
1891 end_wildmenu = end_wildmenu && (!cmdline_pum_active() || |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27887
diff
changeset
|
1892 (c != K_PAGEDOWN && c != K_PAGEUP |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27887
diff
changeset
|
1893 && c != K_KPAGEDOWN && c != K_KPAGEUP)); |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27887
diff
changeset
|
1894 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1895 // free expanded names when finished walking through matches |
28109
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27887
diff
changeset
|
1896 if (end_wildmenu) |
7 | 1897 { |
27603
98139cef237a
patch 8.2.4328: command line complete matches cleard when typing character
Bram Moolenaar <Bram@vim.org>
parents:
27597
diff
changeset
|
1898 if (cmdline_pum_active()) |
98139cef237a
patch 8.2.4328: command line complete matches cleard when typing character
Bram Moolenaar <Bram@vim.org>
parents:
27597
diff
changeset
|
1899 cmdline_pum_remove(); |
27626
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27603
diff
changeset
|
1900 if (xpc.xp_numfiles != -1) |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27603
diff
changeset
|
1901 (void)ExpandOne(&xpc, NULL, NULL, 0, WILD_FREE); |
7 | 1902 did_wild_list = FALSE; |
230 | 1903 if (!p_wmnu || (c != K_UP && c != K_DOWN)) |
7 | 1904 xpc.xp_context = EXPAND_NOTHING; |
1905 wim_index = 0; | |
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
|
1906 wildmenu_cleanup(&ccline); |
7 | 1907 } |
1908 | |
27744
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27626
diff
changeset
|
1909 if (p_wmnu) |
515ce8e07bf2
patch 8.2.4398: some command completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents:
27626
diff
changeset
|
1910 c = wildmenu_process_key(&ccline, c, &xpc); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1911 |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1912 // 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
|
1913 // mode when 'insertmode' is set, CTRL-\ e prompts for an expression. |
7 | 1914 if (c == Ctrl_BSL) |
1915 { | |
31410
f09c92cf3786
patch 9.0.1038: function name does not match what it is used for
Bram Moolenaar <Bram@vim.org>
parents:
31293
diff
changeset
|
1916 res = cmdline_handle_ctrl_bsl(c, &gotesc); |
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
|
1917 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
|
1918 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
|
1919 else if (res == CMDLINE_NOT_CHANGED) |
2636 | 1920 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
|
1921 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
|
1922 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
|
1923 c = Ctrl_BSL; // backslash key not processed by |
31410
f09c92cf3786
patch 9.0.1038: function name does not match what it is used for
Bram Moolenaar <Bram@vim.org>
parents:
31293
diff
changeset
|
1924 // cmdline_handle_ctrl_bsl() |
7 | 1925 } |
1926 | |
1927 if (c == cedit_key || c == K_CMDWIN) | |
1928 { | |
18793
7a1606ceec7d
patch 8.1.2385: opening cmdline window with feedkeys() does not work
Bram Moolenaar <Bram@vim.org>
parents:
18779
diff
changeset
|
1929 // 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
|
1930 if ((c == K_CMDWIN || ex_normal_busy == 0) && got_int == FALSE) |
6211 | 1931 { |
1932 /* | |
1933 * Open a window to edit the command line (and history). | |
1934 */ | |
11321
f57dce6b934b
patch 8.0.0546: swap file exists briefly when opening the command window
Christian Brabandt <cb@256bit.org>
parents:
11285
diff
changeset
|
1935 c = open_cmdwin(); |
6211 | 1936 some_key_typed = TRUE; |
1937 } | |
7 | 1938 } |
30645
101f08b49ed3
patch 9.0.0657: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
30329
diff
changeset
|
1939 #ifdef FEAT_DIGRAPHS |
7 | 1940 else |
1941 c = do_digraph(c); | |
1942 #endif | |
1943 | |
1944 if (c == '\n' || c == '\r' || c == K_KENTER || (c == ESC | |
1945 && (!KeyTyped || vim_strchr(p_cpo, CPO_ESC) != NULL))) | |
1946 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1947 // In Ex mode a backslash escapes a newline. |
168 | 1948 if (exmode_active |
1949 && c != ESC | |
1318 | 1950 && ccline.cmdpos == ccline.cmdlen |
168 | 1951 && ccline.cmdpos > 0 |
1952 && ccline.cmdbuff[ccline.cmdpos - 1] == '\\') | |
1953 { | |
1954 if (c == K_KENTER) | |
1955 c = '\n'; | |
1956 } | |
1957 else | |
7 | 1958 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1959 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
|
1960 // truncate the cmdline now. |
168 | 1961 if (ccheck_abbr(c + ABBR_OFF)) |
1962 goto cmdline_changed; | |
1963 if (!cmd_silent) | |
1964 { | |
1965 windgoto(msg_row, 0); | |
1966 out_flush(); | |
1967 } | |
1968 break; | |
7 | 1969 } |
1970 } | |
1971 | |
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
|
1972 // Completion for 'wildchar' or 'wildcharm' key. |
7 | 1973 if ((c == p_wc && !gotesc && KeyTyped) || c == p_wcm) |
1974 { | |
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
|
1975 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
|
1976 &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
|
1977 if (res == CMDLINE_CHANGED) |
7 | 1978 goto cmdline_changed; |
1979 } | |
1980 | |
1981 gotesc = FALSE; | |
1982 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
1983 // <S-Tab> goes to last match, in a clumsy way |
7 | 1984 if (c == K_S_TAB && KeyTyped) |
1985 { | |
27597
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27372
diff
changeset
|
1986 if (nextwild(&xpc, WILD_EXPAND_KEEP, 0, firstc != '@') == OK) |
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27372
diff
changeset
|
1987 { |
29798
e038b8dd7cd9
patch 9.0.0238: Shift-Tab shows matches on cmdline when 'wildmenu' is off
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
1988 if (xpc.xp_numfiles > 1 |
e038b8dd7cd9
patch 9.0.0238: Shift-Tab shows matches on cmdline when 'wildmenu' is off
Bram Moolenaar <Bram@vim.org>
parents:
29732
diff
changeset
|
1989 && ((!did_wild_list && (wim_flags[wim_index] & WIM_LIST)) |
29881
0cc9a3001717
patch 9.0.0279: the tiny version has the popup menu but not 'wildmenu'
Bram Moolenaar <Bram@vim.org>
parents:
29865
diff
changeset
|
1990 || p_wmnu)) |
27626
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27603
diff
changeset
|
1991 { |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27603
diff
changeset
|
1992 // Trigger the popup menu when wildoptions=pum |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27603
diff
changeset
|
1993 showmatches(&xpc, p_wmnu |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27603
diff
changeset
|
1994 && ((wim_flags[wim_index] & WIM_LIST) == 0)); |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27603
diff
changeset
|
1995 } |
27597
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27372
diff
changeset
|
1996 if (nextwild(&xpc, WILD_PREV, 0, firstc != '@') == OK |
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27372
diff
changeset
|
1997 && nextwild(&xpc, WILD_PREV, 0, firstc != '@') == OK) |
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27372
diff
changeset
|
1998 goto cmdline_changed; |
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27372
diff
changeset
|
1999 } |
7 | 2000 } |
2001 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2002 if (c == NUL || c == K_ZERO) // NUL is stored as NL |
7 | 2003 c = NL; |
2004 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2005 do_abbr = TRUE; // default: check for abbreviation |
7 | 2006 |
2007 /* | |
2008 * Big switch for a typed command line character. | |
2009 */ | |
2010 switch (c) | |
2011 { | |
2012 case K_BS: | |
2013 case Ctrl_H: | |
2014 case K_DEL: | |
2015 case K_KDEL: | |
2016 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
|
2017 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
|
2018 #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
|
2019 , &is_state |
7 | 2020 #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
|
2021 ); |
e6fb7f627448
patch 8.2.1622: loop to handle keys for the command line is too long
Bram Moolenaar <Bram@vim.org>
parents:
22075
diff
changeset
|
2022 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
|
2023 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
|
2024 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
|
2025 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
|
2026 goto cmdline_changed; |
7 | 2027 |
2028 case K_INS: | |
2029 case K_KINS: | |
2030 ccline.overstrike = !ccline.overstrike; | |
2031 #ifdef CURSOR_SHAPE | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2032 ui_cursor_shape(); // may show different cursor shape |
7 | 2033 #endif |
2034 goto cmdline_not_changed; | |
2035 | |
2036 case Ctrl_HAT: | |
30308
6b541aaaf39e
patch 9.0.0490: using freed memory with cmdwin and BufEnter autocmd
Bram Moolenaar <Bram@vim.org>
parents:
30267
diff
changeset
|
2037 cmdline_toggle_langmap( |
6b541aaaf39e
patch 9.0.0490: using freed memory with cmdwin and BufEnter autocmd
Bram Moolenaar <Bram@vim.org>
parents:
30267
diff
changeset
|
2038 buf_valid(b_im_ptr_buf) ? b_im_ptr : NULL); |
7 | 2039 goto cmdline_not_changed; |
2040 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2041 // case '@': only in very old vi |
7 | 2042 case Ctrl_U: |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2043 // delete all characters left of the cursor |
7 | 2044 j = ccline.cmdpos; |
2045 ccline.cmdlen -= j; | |
2046 i = ccline.cmdpos = 0; | |
2047 while (i < ccline.cmdlen) | |
2048 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
|
2049 // Truncate at the end, required for multi-byte chars. |
7 | 2050 ccline.cmdbuff[ccline.cmdlen] = NUL; |
9971
98b39d2eb895
commit https://github.com/vim/vim/commit/4d6f32cbfbaf324ac4a25c0206a5db0e9f7a48f7
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
2051 #ifdef FEAT_SEARCH_EXTRA |
98b39d2eb895
commit https://github.com/vim/vim/commit/4d6f32cbfbaf324ac4a25c0206a5db0e9f7a48f7
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
2052 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
|
2053 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
|
2054 #endif |
7 | 2055 redrawcmd(); |
2056 goto cmdline_changed; | |
2057 | |
2058 #ifdef FEAT_CLIPBOARD | |
2059 case Ctrl_Y: | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2060 // Copy the modeless selection, if there is one. |
7 | 2061 if (clip_star.state != SELECT_CLEARED) |
2062 { | |
2063 if (clip_star.state == SELECT_DONE) | |
2064 clip_copy_modeless_selection(TRUE); | |
2065 goto cmdline_not_changed; | |
2066 } | |
2067 break; | |
2068 #endif | |
2069 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2070 case ESC: // get here if p_wc != ESC or when ESC typed twice |
7 | 2071 case Ctrl_C: |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2072 // 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
|
2073 // ":normal" runs out of characters. |
161 | 2074 if (exmode_active |
7850
10f17a228661
commit https://github.com/vim/vim/commit/e2c3810c2ae290bbc2cba18eb47cc2d44e4b9797
Christian Brabandt <cb@256bit.org>
parents:
7819
diff
changeset
|
2075 && (ex_normal_busy == 0 || typebuf.tb_len > 0)) |
7 | 2076 goto cmdline_not_changed; |
2077 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2078 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
|
2079 // putting it in history |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2080 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
|
2081 |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2082 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
|
2083 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
|
2084 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
|
2085 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
|
2086 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
|
2087 goto returncmd; |
7 | 2088 goto cmdline_changed; |
2089 | |
2090 case Ctrl_D: | |
2091 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
|
2092 break; // Use ^D as normal char instead |
7 | 2093 |
2094 redrawcmd(); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2095 continue; // don't do incremental search now |
7 | 2096 |
2097 case K_RIGHT: | |
2098 case K_S_RIGHT: | |
2099 case K_C_RIGHT: | |
2100 do | |
2101 { | |
2102 if (ccline.cmdpos >= ccline.cmdlen) | |
2103 break; | |
2104 i = cmdline_charsize(ccline.cmdpos); | |
2105 if (KeyTyped && ccline.cmdspos + i >= Columns * Rows) | |
2106 break; | |
2107 ccline.cmdspos += i; | |
2108 if (has_mbyte) | |
474 | 2109 ccline.cmdpos += (*mb_ptr2len)(ccline.cmdbuff |
7 | 2110 + ccline.cmdpos); |
2111 else | |
2112 ++ccline.cmdpos; | |
2113 } | |
180 | 2114 while ((c == K_S_RIGHT || c == K_C_RIGHT |
2115 || (mod_mask & (MOD_MASK_SHIFT|MOD_MASK_CTRL))) | |
7 | 2116 && ccline.cmdbuff[ccline.cmdpos] != ' '); |
2117 if (has_mbyte) | |
2118 set_cmdspos_cursor(); | |
2119 goto cmdline_not_changed; | |
2120 | |
2121 case K_LEFT: | |
2122 case K_S_LEFT: | |
2123 case K_C_LEFT: | |
1456 | 2124 if (ccline.cmdpos == 0) |
2125 goto cmdline_not_changed; | |
7 | 2126 do |
2127 { | |
2128 --ccline.cmdpos; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2129 if (has_mbyte) // move to first byte of char |
7 | 2130 ccline.cmdpos -= (*mb_head_off)(ccline.cmdbuff, |
2131 ccline.cmdbuff + ccline.cmdpos); | |
2132 ccline.cmdspos -= cmdline_charsize(ccline.cmdpos); | |
2133 } | |
1456 | 2134 while (ccline.cmdpos > 0 |
2135 && (c == K_S_LEFT || c == K_C_LEFT | |
180 | 2136 || (mod_mask & (MOD_MASK_SHIFT|MOD_MASK_CTRL))) |
7 | 2137 && ccline.cmdbuff[ccline.cmdpos - 1] != ' '); |
2138 if (has_mbyte) | |
2139 set_cmdspos_cursor(); | |
2140 goto cmdline_not_changed; | |
2141 | |
2142 case K_IGNORE: | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2143 // Ignore mouse event or open_cmdwin() result. |
1472 | 2144 goto cmdline_not_changed; |
7 | 2145 |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
2146 #ifdef FEAT_GUI_MSWIN |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2147 // 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
|
2148 // was cancelled. |
625 | 2149 case K_F4: |
2150 if (mod_mask == MOD_MASK_ALT) | |
2151 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2152 redrawcmd(); // somehow the cmdline is cleared |
625 | 2153 goto cmdline_not_changed; |
2154 } | |
2155 break; | |
2156 #endif | |
2157 | |
7 | 2158 case K_MIDDLEDRAG: |
2159 case K_MIDDLERELEASE: | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2160 goto cmdline_not_changed; // Ignore mouse |
7 | 2161 |
2162 case K_MIDDLEMOUSE: | |
2163 # ifdef FEAT_GUI | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2164 // When GUI is active, also paste when 'mouse' is empty |
7 | 2165 if (!gui.in_use) |
2166 # endif | |
2167 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
|
2168 goto cmdline_not_changed; // Ignore mouse |
692 | 2169 # ifdef FEAT_CLIPBOARD |
7 | 2170 if (clip_star.available) |
1015 | 2171 cmdline_paste('*', TRUE, TRUE); |
7 | 2172 else |
692 | 2173 # endif |
1015 | 2174 cmdline_paste(0, TRUE, TRUE); |
7 | 2175 redrawcmd(); |
2176 goto cmdline_changed; | |
2177 | |
692 | 2178 # ifdef FEAT_DND |
7 | 2179 case K_DROP: |
1015 | 2180 cmdline_paste('~', TRUE, FALSE); |
7 | 2181 redrawcmd(); |
2182 goto cmdline_changed; | |
692 | 2183 # endif |
7 | 2184 |
2185 case K_LEFTDRAG: | |
2186 case K_LEFTRELEASE: | |
2187 case K_RIGHTDRAG: | |
2188 case K_RIGHTRELEASE: | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2189 // 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
|
2190 // seen before. |
7 | 2191 if (ignore_drag_release) |
2192 goto cmdline_not_changed; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2193 // FALLTHROUGH |
7 | 2194 case K_LEFTMOUSE: |
2195 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
|
2196 cmdline_left_right_mouse(c, &ignore_drag_release); |
7 | 2197 goto cmdline_not_changed; |
2198 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2199 // Mouse scroll wheel: ignored here |
7 | 2200 case K_MOUSEDOWN: |
2201 case K_MOUSEUP: | |
2409
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
2202 case K_MOUSELEFT: |
0ca06a92adfb
Add support for horizontal scroll wheel. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
2203 case K_MOUSERIGHT: |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2204 // Alternate buttons ignored here |
7 | 2205 case K_X1MOUSE: |
2206 case K_X1DRAG: | |
2207 case K_X1RELEASE: | |
2208 case K_X2MOUSE: | |
2209 case K_X2DRAG: | |
2210 case K_X2RELEASE: | |
12865
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12855
diff
changeset
|
2211 case K_MOUSEMOVE: |
7 | 2212 goto cmdline_not_changed; |
2213 | |
2214 #ifdef FEAT_GUI | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2215 case K_LEFTMOUSE_NM: // mousefocus click, ignored |
7 | 2216 case K_LEFTRELEASE_NM: |
2217 goto cmdline_not_changed; | |
2218 | |
2219 case K_VER_SCROLLBAR: | |
540 | 2220 if (msg_scrolled == 0) |
7 | 2221 { |
2222 gui_do_scroll(); | |
2223 redrawcmd(); | |
2224 } | |
2225 goto cmdline_not_changed; | |
2226 | |
2227 case K_HOR_SCROLLBAR: | |
540 | 2228 if (msg_scrolled == 0) |
7 | 2229 { |
31103
33ca088dbd3e
patch 9.0.0886: horizontal mouse scroll only works in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
30645
diff
changeset
|
2230 do_mousescroll_horiz(scrollbar_value); |
7 | 2231 redrawcmd(); |
2232 } | |
2233 goto cmdline_not_changed; | |
2234 #endif | |
692 | 2235 #ifdef FEAT_GUI_TABLINE |
2236 case K_TABLINE: | |
2237 case K_TABMENU: | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2238 // 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
|
2239 // is still selected. |
692 | 2240 if (gui_use_tabline()) |
2241 gui_mch_set_curtab(tabpage_index(curtab)); | |
2242 goto cmdline_not_changed; | |
2243 #endif | |
2244 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2245 case K_SELECT: // end of Select mode mapping - ignore |
7 | 2246 goto cmdline_not_changed; |
2247 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2248 case Ctrl_B: // begin of command line |
7 | 2249 case K_HOME: |
2250 case K_KHOME: | |
2251 case K_S_HOME: | |
2252 case K_C_HOME: | |
2253 ccline.cmdpos = 0; | |
2254 set_cmdspos(); | |
2255 goto cmdline_not_changed; | |
2256 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2257 case Ctrl_E: // end of command line |
7 | 2258 case K_END: |
2259 case K_KEND: | |
2260 case K_S_END: | |
2261 case K_C_END: | |
2262 ccline.cmdpos = ccline.cmdlen; | |
2263 set_cmdspos_cursor(); | |
2264 goto cmdline_not_changed; | |
2265 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2266 case Ctrl_A: // all matches |
27597
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27372
diff
changeset
|
2267 if (cmdline_pum_active()) |
27626
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27603
diff
changeset
|
2268 // As Ctrl-A completes all the matches, close the popup |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27603
diff
changeset
|
2269 // menu (if present) |
27597
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
27372
diff
changeset
|
2270 cmdline_pum_cleanup(&ccline); |
29881
0cc9a3001717
patch 9.0.0279: the tiny version has the popup menu but not 'wildmenu'
Bram Moolenaar <Bram@vim.org>
parents:
29865
diff
changeset
|
2271 |
27626
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27603
diff
changeset
|
2272 if (nextwild(&xpc, WILD_ALL, 0, firstc != '@') == FAIL) |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27603
diff
changeset
|
2273 break; |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27603
diff
changeset
|
2274 xpc.xp_context = EXPAND_NOTHING; |
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27603
diff
changeset
|
2275 did_wild_list = FALSE; |
7 | 2276 goto cmdline_changed; |
2277 | |
772 | 2278 case Ctrl_L: |
2279 #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
|
2280 if (may_add_char_to_search(firstc, &c, &is_state) == OK) |
772 | 2281 goto cmdline_not_changed; |
2282 #endif | |
2283 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2284 // completion: longest common part |
3961 | 2285 if (nextwild(&xpc, WILD_LONGEST, 0, firstc != '@') == FAIL) |
7 | 2286 break; |
2287 goto cmdline_changed; | |
2288 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2289 case Ctrl_N: // next match |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2290 case Ctrl_P: // previous match |
9976
e448370630b2
commit https://github.com/vim/vim/commit/7df0f6313a46b80d760c9a80241922544333351c
Christian Brabandt <cb@256bit.org>
parents:
9971
diff
changeset
|
2291 if (xpc.xp_numfiles > 0) |
7 | 2292 { |
28121
4765d97b4d8b
patch 8.2.4585: cannot use keypad page-up/down for completion menu
Bram Moolenaar <Bram@vim.org>
parents:
28109
diff
changeset
|
2293 wild_type = (c == Ctrl_P) ? WILD_PREV : WILD_NEXT; |
4765d97b4d8b
patch 8.2.4585: cannot use keypad page-up/down for completion menu
Bram Moolenaar <Bram@vim.org>
parents:
28109
diff
changeset
|
2294 if (nextwild(&xpc, wild_type, 0, firstc != '@') == FAIL) |
7 | 2295 break; |
9990
6a1793d9c895
commit https://github.com/vim/vim/commit/1195669f9e434fa9ab8b57ee9470bf951e4990b8
Christian Brabandt <cb@256bit.org>
parents:
9976
diff
changeset
|
2296 goto cmdline_not_changed; |
7 | 2297 } |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2298 // FALLTHROUGH |
7 | 2299 case K_UP: |
2300 case K_DOWN: | |
2301 case K_S_UP: | |
2302 case K_S_DOWN: | |
2303 case K_PAGEUP: | |
2304 case K_KPAGEUP: | |
2305 case K_PAGEDOWN: | |
2306 case K_KPAGEDOWN: | |
28109
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27887
diff
changeset
|
2307 if (cmdline_pum_active() |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27887
diff
changeset
|
2308 && (c == K_PAGEUP || c == K_PAGEDOWN || |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27887
diff
changeset
|
2309 c == K_KPAGEUP || c == K_KPAGEDOWN)) |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27887
diff
changeset
|
2310 { |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27887
diff
changeset
|
2311 // If the popup menu is displayed, then PageUp and PageDown |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27887
diff
changeset
|
2312 // are used to scroll the menu. |
28121
4765d97b4d8b
patch 8.2.4585: cannot use keypad page-up/down for completion menu
Bram Moolenaar <Bram@vim.org>
parents:
28109
diff
changeset
|
2313 wild_type = WILD_PAGEUP; |
4765d97b4d8b
patch 8.2.4585: cannot use keypad page-up/down for completion menu
Bram Moolenaar <Bram@vim.org>
parents:
28109
diff
changeset
|
2314 if (c == K_PAGEDOWN || c == K_KPAGEDOWN) |
4765d97b4d8b
patch 8.2.4585: cannot use keypad page-up/down for completion menu
Bram Moolenaar <Bram@vim.org>
parents:
28109
diff
changeset
|
2315 wild_type = WILD_PAGEDOWN; |
4765d97b4d8b
patch 8.2.4585: cannot use keypad page-up/down for completion menu
Bram Moolenaar <Bram@vim.org>
parents:
28109
diff
changeset
|
2316 if (nextwild(&xpc, wild_type, 0, firstc != '@') == FAIL) |
28109
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27887
diff
changeset
|
2317 break; |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27887
diff
changeset
|
2318 goto cmdline_not_changed; |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27887
diff
changeset
|
2319 } |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27887
diff
changeset
|
2320 else |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27887
diff
changeset
|
2321 { |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27887
diff
changeset
|
2322 res = cmdline_browse_history(c, firstc, &lookfor, histype, |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27887
diff
changeset
|
2323 &hiscnt, &xpc); |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27887
diff
changeset
|
2324 if (res == CMDLINE_CHANGED) |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27887
diff
changeset
|
2325 goto cmdline_changed; |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27887
diff
changeset
|
2326 else if (res == GOTO_NORMAL_MODE) |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27887
diff
changeset
|
2327 goto returncmd; |
06535d568f74
patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27887
diff
changeset
|
2328 } |
9990
6a1793d9c895
commit https://github.com/vim/vim/commit/1195669f9e434fa9ab8b57ee9470bf951e4990b8
Christian Brabandt <cb@256bit.org>
parents:
9976
diff
changeset
|
2329 goto cmdline_not_changed; |
6a1793d9c895
commit https://github.com/vim/vim/commit/1195669f9e434fa9ab8b57ee9470bf951e4990b8
Christian Brabandt <cb@256bit.org>
parents:
9976
diff
changeset
|
2330 |
10094
61dc69646af6
commit https://github.com/vim/vim/commit/349e7d94e6bbb253bb87adad9039f095128ab543
Christian Brabandt <cb@256bit.org>
parents:
10082
diff
changeset
|
2331 #ifdef FEAT_SEARCH_EXTRA |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2332 case Ctrl_G: // next match |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2333 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
|
2334 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
|
2335 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
|
2336 goto cmdline_not_changed; |
61dc69646af6
commit https://github.com/vim/vim/commit/349e7d94e6bbb253bb87adad9039f095128ab543
Christian Brabandt <cb@256bit.org>
parents:
10082
diff
changeset
|
2337 break; |
7 | 2338 #endif |
2339 | |
2340 case Ctrl_V: | |
2341 case Ctrl_Q: | |
2342 { | |
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
|
2343 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
|
2344 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
|
2345 |
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
|
2346 // 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
|
2347 // 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
|
2348 // 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
|
2349 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
|
2350 |
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
|
2351 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
|
2352 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
|
2353 // 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
|
2354 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
|
2355 { |
14d2a210fab1
patch 8.1.2350: other text for CTRL-V in Insert mode with modifyOtherKeys
Bram Moolenaar <Bram@vim.org>
parents:
18709
diff
changeset
|
2356 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
|
2357 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
|
2358 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
|
2359 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
|
2360 } |
7 | 2361 } |
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
|
2362 |
7 | 2363 break; |
2364 | |
2365 #ifdef FEAT_DIGRAPHS | |
2366 case Ctrl_K: | |
2367 ignore_drag_release = TRUE; | |
2368 putcmdline('?', TRUE); | |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18251
diff
changeset
|
2369 # 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
|
2370 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
|
2371 # endif |
7 | 2372 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
|
2373 extra_char = NUL; |
7 | 2374 if (c != NUL) |
2375 break; | |
2376 | |
2377 redrawcmd(); | |
2378 goto cmdline_not_changed; | |
18354
9f51d0cef8da
patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents:
18251
diff
changeset
|
2379 #endif // FEAT_DIGRAPHS |
7 | 2380 |
2381 #ifdef FEAT_RIGHTLEFT | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2382 case Ctrl__: // CTRL-_: switch language mode |
7 | 2383 if (!p_ari) |
2384 break; | |
15850
a6ca8cf07a98
patch 8.1.0932: Farsi support is outdated and unused
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
2385 cmd_hkmap = !cmd_hkmap; |
7 | 2386 goto cmdline_not_changed; |
2387 #endif | |
2388 | |
10676
b8c04c007d39
patch 8.0.0228: pasting in xterm on the command line has PasteStart
Christian Brabandt <cb@256bit.org>
parents:
10565
diff
changeset
|
2389 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
|
2390 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
|
2391 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
|
2392 |
7 | 2393 default: |
2394 #ifdef UNIX | |
2395 if (c == intr_char) | |
2396 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2397 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
|
2398 // putting it in history |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2399 goto returncmd; // back to Normal mode |
7 | 2400 } |
2401 #endif | |
2402 /* | |
2403 * Normal character with no special meaning. Just set mod_mask | |
2404 * to 0x0 so that typing Shift-Space in the GUI doesn't enter | |
2405 * the string <S-Space>. This should only happen after ^V. | |
2406 */ | |
2407 if (!IS_SPECIAL(c)) | |
2408 mod_mask = 0x0; | |
2409 break; | |
2410 } | |
2411 /* | |
2412 * End of switch on command line character. | |
2413 * We come here if we have a normal character. | |
2414 */ | |
2415 | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15575
diff
changeset
|
2416 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
|
2417 && (ccheck_abbr( |
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15575
diff
changeset
|
2418 // 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
|
2419 // what check_abbr() expects. |
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15575
diff
changeset
|
2420 (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
|
2421 || c == Ctrl_RSB)) |
7 | 2422 goto cmdline_changed; |
2423 | |
2424 /* | |
2425 * put the character in the command line | |
2426 */ | |
2427 if (IS_SPECIAL(c) || mod_mask != 0) | |
2428 put_on_cmdline(get_special_key_name(c, mod_mask), -1, TRUE); | |
2429 else | |
2430 { | |
2431 if (has_mbyte) | |
2432 { | |
2433 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
|
2434 IObuff[j] = NUL; // exclude composing chars |
7 | 2435 put_on_cmdline(IObuff, j, TRUE); |
2436 } | |
2437 else | |
2438 { | |
2439 IObuff[0] = c; | |
2440 put_on_cmdline(IObuff, 1, TRUE); | |
2441 } | |
2442 } | |
2443 goto cmdline_changed; | |
2444 | |
2445 /* | |
2446 * This part implements incremental searches for "/" and "?" | |
2447 * Jump to cmdline_not_changed when a character has been read but the command | |
2448 * line did not change. Then we only search and redraw if something changed in | |
2449 * the past. | |
2450 * Jump to cmdline_changed when the command line did change. | |
2451 * (Sorry for the goto's, I know it is ugly). | |
2452 */ | |
2453 cmdline_not_changed: | |
2454 #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
|
2455 if (!is_state.incsearch_postponed) |
7 | 2456 continue; |
2457 #endif | |
2458 | |
2459 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
|
2460 #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
|
2461 // 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
|
2462 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
|
2463 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
|
2464 #endif |
24628
447426630e44
patch 8.2.2853: window is not updated after using <Cmd> mapping
Bram Moolenaar <Bram@vim.org>
parents:
24624
diff
changeset
|
2465 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
|
2466 // 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
|
2467 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
|
2468 |
7 | 2469 #ifdef FEAT_SEARCH_EXTRA |
25376
485ae4421331
patch 8.2.3225: incsearch highlighting is attempted halfway a mapping
Bram Moolenaar <Bram@vim.org>
parents:
25064
diff
changeset
|
2470 if (xpc.xp_context == EXPAND_NOTHING && (KeyTyped || vpeekc() == NUL)) |
22061
d6120c97f57c
patch 8.2.1580: wildmenu does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
21883
diff
changeset
|
2471 may_do_incsearch_highlighting(firstc, count, &is_state); |
7 | 2472 #endif |
2473 | |
2474 #ifdef FEAT_RIGHTLEFT | |
2475 if (cmdmsg_rl | |
2476 # 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
|
2477 || (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
|
2478 && cmdline_has_arabic(0, ccline.cmdlen)) |
7 | 2479 # endif |
2480 ) | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2481 // 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
|
2482 // 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
|
2483 // 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
|
2484 // to avoid useless intermediate redraws. |
3374 | 2485 if (vpeekc() == NUL) |
2486 redrawcmd(); | |
7 | 2487 #endif |
2488 } | |
2489 | |
2490 returncmd: | |
2491 | |
2492 #ifdef FEAT_RIGHTLEFT | |
2493 cmdmsg_rl = FALSE; | |
2494 #endif | |
2495 | |
2496 ExpandCleanup(&xpc); | |
1718 | 2497 ccline.xpc = NULL; |
7 | 2498 |
2499 #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
|
2500 finish_incsearch_highlighting(gotesc, &is_state, FALSE); |
7 | 2501 #endif |
2502 | |
2503 if (ccline.cmdbuff != NULL) | |
2504 { | |
2505 /* | |
2506 * Put line in history buffer (":" and "=" only when it was typed). | |
2507 */ | |
2508 if (ccline.cmdlen && firstc != NUL | |
2509 && (some_key_typed || histype == HIST_SEARCH)) | |
2510 { | |
2511 add_to_history(histype, ccline.cmdbuff, TRUE, | |
2512 histype == HIST_SEARCH ? firstc : NUL); | |
2513 if (firstc == ':') | |
2514 { | |
2515 vim_free(new_last_cmdline); | |
2516 new_last_cmdline = vim_strsave(ccline.cmdbuff); | |
2517 } | |
2518 } | |
2519 | |
12664
42cd1f315e8b
patch 8.0.1210: CTRL-G and CTRL-T are ignored with typeahead
Christian Brabandt <cb@256bit.org>
parents:
12656
diff
changeset
|
2520 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
|
2521 abandon_cmdline(); |
7 | 2522 } |
2523 | |
2524 /* | |
2525 * If the screen was shifted up, redraw the whole screen (later). | |
2526 * If the line is too long, clear it, so ruler and shown command do | |
2527 * not get printed in the middle of it. | |
2528 */ | |
2529 msg_check(); | |
2530 msg_scroll = save_msg_scroll; | |
2531 redir_off = FALSE; | |
2532 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2533 // When the command line was typed, no need for a wait-return prompt. |
7 | 2534 if (some_key_typed) |
2535 need_wait_return = FALSE; | |
2536 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2537 // 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
|
2538 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
|
2539 |
7 | 2540 State = save_State; |
25790
16a7d1154be8
patch 8.2.3430: no generic way to trigger an autocommand on mode change
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
2541 |
16a7d1154be8
patch 8.2.3430: no generic way to trigger an autocommand on mode change
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
2542 #ifdef FEAT_EVAL |
16a7d1154be8
patch 8.2.3430: no generic way to trigger an autocommand on mode change
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
2543 if (!debug_mode) |
28397
d1702731786c
patch 8.2.4723: the ModeChanged autocmd event is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
28121
diff
changeset
|
2544 may_trigger_modechanged(); |
25790
16a7d1154be8
patch 8.2.3430: no generic way to trigger an autocommand on mode change
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
2545 #endif |
16a7d1154be8
patch 8.2.3430: no generic way to trigger an autocommand on mode change
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
2546 |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13256
diff
changeset
|
2547 #ifdef HAVE_INPUT_METHOD |
30308
6b541aaaf39e
patch 9.0.0490: using freed memory with cmdwin and BufEnter autocmd
Bram Moolenaar <Bram@vim.org>
parents:
30267
diff
changeset
|
2548 if (b_im_ptr != NULL && buf_valid(b_im_ptr_buf) |
6b541aaaf39e
patch 9.0.0490: using freed memory with cmdwin and BufEnter autocmd
Bram Moolenaar <Bram@vim.org>
parents:
30267
diff
changeset
|
2549 && *b_im_ptr != B_IMODE_LMAP) |
7 | 2550 im_save_status(b_im_ptr); |
2551 im_set_active(FALSE); | |
2552 #endif | |
2553 setmouse(); | |
2554 #ifdef CURSOR_SHAPE | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2555 ui_cursor_shape(); // may show different cursor shape |
7 | 2556 #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
|
2557 sb_text_end_cmdline(); |
7 | 2558 |
14854
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
2559 theend: |
95 | 2560 { |
2561 char_u *p = ccline.cmdbuff; | |
2562 | |
28905
f3f45218f923
patch 8.2.4975: recursive command line loop may cause a crash
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
2563 --depth; |
14854
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
2564 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
|
2565 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
|
2566 else |
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
2567 ccline.cmdbuff = NULL; |
95 | 2568 return p; |
2569 } | |
7 | 2570 } |
2571 | |
2572 #if (defined(FEAT_CRYPT) || defined(FEAT_EVAL)) || defined(PROTO) | |
2573 /* | |
2574 * Get a command line with a prompt. | |
2575 * This is prepared to be called recursively from getcmdline() (e.g. by | |
2576 * f_input() when evaluating an expression from CTRL-R =). | |
2577 * Returns the command line in allocated memory, or NULL. | |
2578 */ | |
2579 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2580 getcmdline_prompt( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2581 int firstc, |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2582 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
|
2583 int attr, // attributes for prompt |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2584 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
|
2585 char_u *xp_arg) // user-defined expansion argument |
7 | 2586 { |
2587 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
|
2588 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
|
2589 int did_save_ccline = FALSE; |
7 | 2590 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
|
2591 int msg_silent_save = msg_silent; |
7 | 2592 |
14854
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
2593 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
|
2594 { |
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
2595 // 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
|
2596 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
|
2597 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
|
2598 } |
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
2599 |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
2600 CLEAR_FIELD(ccline); |
7 | 2601 ccline.cmdprompt = prompt; |
2602 ccline.cmdattr = attr; | |
531 | 2603 # ifdef FEAT_EVAL |
2604 ccline.xp_context = xp_context; | |
2605 ccline.xp_arg = xp_arg; | |
2606 ccline.input_fn = (firstc == '@'); | |
2607 # endif | |
8694
f2e81ae5ab48
commit https://github.com/vim/vim/commit/6135d0d803084f6c2dd8672df1bef4c6e58f9e19
Christian Brabandt <cb@256bit.org>
parents:
8647
diff
changeset
|
2608 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
|
2609 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
|
2610 |
3b72808fbb0d
patch 8.1.0439: recursive use of getcmdline() still not protected
Christian Brabandt <cb@256bit.org>
parents:
14848
diff
changeset
|
2611 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
|
2612 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
|
2613 |
8694
f2e81ae5ab48
commit https://github.com/vim/vim/commit/6135d0d803084f6c2dd8672df1bef4c6e58f9e19
Christian Brabandt <cb@256bit.org>
parents:
8647
diff
changeset
|
2614 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
|
2615 // 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
|
2616 // 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
|
2617 // 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
|
2618 // so we need its modified msg_col left intact. |
3020 | 2619 if (ccline.cmdbuff != NULL) |
2620 msg_col = msg_col_save; | |
7 | 2621 |
2622 return s; | |
2623 } | |
2624 #endif | |
2625 | |
632 | 2626 /* |
18679
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2627 * 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
|
2628 */ |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2629 int |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2630 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
|
2631 { |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2632 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
|
2633 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
|
2634 int i; |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2635 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
|
2636 |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2637 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
|
2638 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
|
2639 |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2640 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
|
2641 { |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2642 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
|
2643 ; |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2644 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
|
2645 return FAIL; |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2646 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
|
2647 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
|
2648 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
|
2649 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
|
2650 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
|
2651 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
|
2652 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
|
2653 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
|
2654 else |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2655 return FAIL; |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2656 p += i; |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2657 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
|
2658 break; |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2659 if (*p == ',') |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2660 { |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2661 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
|
2662 return FAIL; |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2663 ++idx; |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2664 } |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2665 } |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2666 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2667 // 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
|
2668 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
|
2669 { |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2670 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
|
2671 ++idx; |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2672 } |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2673 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2674 // 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
|
2675 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
|
2676 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
|
2677 return OK; |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2678 } |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2679 |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
2680 /* |
634 | 2681 * 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
|
2682 * another window or buffer. TRUE when editing the command line, evaluating |
634 | 2683 * 'balloonexpr', etc. |
632 | 2684 */ |
2685 int | |
29014
45c182c4f7e9
patch 8.2.5029: "textlock" is always zero
Bram Moolenaar <Bram@vim.org>
parents:
28905
diff
changeset
|
2686 text_locked(void) |
632 | 2687 { |
2688 if (cmdwin_type != 0) | |
2689 return TRUE; | |
29014
45c182c4f7e9
patch 8.2.5029: "textlock" is always zero
Bram Moolenaar <Bram@vim.org>
parents:
28905
diff
changeset
|
2690 return textlock != 0; |
632 | 2691 } |
2692 | |
2693 /* | |
2694 * Give an error message for a command that isn't allowed while the cmdline | |
2695 * window is open or editing the cmdline in another way. | |
2696 */ | |
2697 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2698 text_locked_msg(void) |
632 | 2699 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
2700 emsg(_(get_text_locked_msg())); |
10082
7fc6103c6651
commit https://github.com/vim/vim/commit/5a49789a9b1f6447aeafbbbdd5b235dd10c471d5
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2701 } |
7fc6103c6651
commit https://github.com/vim/vim/commit/5a49789a9b1f6447aeafbbbdd5b235dd10c471d5
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2702 |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
2703 char * |
10082
7fc6103c6651
commit https://github.com/vim/vim/commit/5a49789a9b1f6447aeafbbbdd5b235dd10c471d5
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2704 get_text_locked_msg(void) |
7fc6103c6651
commit https://github.com/vim/vim/commit/5a49789a9b1f6447aeafbbbdd5b235dd10c471d5
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2705 { |
632 | 2706 if (cmdwin_type != 0) |
25064
8f2262c72178
patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
24663
diff
changeset
|
2707 return e_invalid_in_cmdline_window; |
29014
45c182c4f7e9
patch 8.2.5029: "textlock" is always zero
Bram Moolenaar <Bram@vim.org>
parents:
28905
diff
changeset
|
2708 return e_not_allowed_to_change_text_or_change_window; |
20229
06a1dd50463e
patch 8.2.0670: cannot change window when evaluating 'completefunc'
Bram Moolenaar <Bram@vim.org>
parents:
20213
diff
changeset
|
2709 } |
06a1dd50463e
patch 8.2.0670: cannot change window when evaluating 'completefunc'
Bram Moolenaar <Bram@vim.org>
parents:
20213
diff
changeset
|
2710 |
06a1dd50463e
patch 8.2.0670: cannot change window when evaluating 'completefunc'
Bram Moolenaar <Bram@vim.org>
parents:
20213
diff
changeset
|
2711 /* |
29042
e150d0e4701f
patch 8.2.5043: can open a cmdline window from a substitute expression
Bram Moolenaar <Bram@vim.org>
parents:
29014
diff
changeset
|
2712 * Check for text, window or buffer locked. |
e150d0e4701f
patch 8.2.5043: can open a cmdline window from a substitute expression
Bram Moolenaar <Bram@vim.org>
parents:
29014
diff
changeset
|
2713 * Give an error message and return TRUE if something is locked. |
e150d0e4701f
patch 8.2.5043: can open a cmdline window from a substitute expression
Bram Moolenaar <Bram@vim.org>
parents:
29014
diff
changeset
|
2714 */ |
e150d0e4701f
patch 8.2.5043: can open a cmdline window from a substitute expression
Bram Moolenaar <Bram@vim.org>
parents:
29014
diff
changeset
|
2715 int |
e150d0e4701f
patch 8.2.5043: can open a cmdline window from a substitute expression
Bram Moolenaar <Bram@vim.org>
parents:
29014
diff
changeset
|
2716 text_or_buf_locked(void) |
e150d0e4701f
patch 8.2.5043: can open a cmdline window from a substitute expression
Bram Moolenaar <Bram@vim.org>
parents:
29014
diff
changeset
|
2717 { |
e150d0e4701f
patch 8.2.5043: can open a cmdline window from a substitute expression
Bram Moolenaar <Bram@vim.org>
parents:
29014
diff
changeset
|
2718 if (text_locked()) |
e150d0e4701f
patch 8.2.5043: can open a cmdline window from a substitute expression
Bram Moolenaar <Bram@vim.org>
parents:
29014
diff
changeset
|
2719 { |
e150d0e4701f
patch 8.2.5043: can open a cmdline window from a substitute expression
Bram Moolenaar <Bram@vim.org>
parents:
29014
diff
changeset
|
2720 text_locked_msg(); |
e150d0e4701f
patch 8.2.5043: can open a cmdline window from a substitute expression
Bram Moolenaar <Bram@vim.org>
parents:
29014
diff
changeset
|
2721 return TRUE; |
e150d0e4701f
patch 8.2.5043: can open a cmdline window from a substitute expression
Bram Moolenaar <Bram@vim.org>
parents:
29014
diff
changeset
|
2722 } |
e150d0e4701f
patch 8.2.5043: can open a cmdline window from a substitute expression
Bram Moolenaar <Bram@vim.org>
parents:
29014
diff
changeset
|
2723 return curbuf_locked(); |
e150d0e4701f
patch 8.2.5043: can open a cmdline window from a substitute expression
Bram Moolenaar <Bram@vim.org>
parents:
29014
diff
changeset
|
2724 } |
e150d0e4701f
patch 8.2.5043: can open a cmdline window from a substitute expression
Bram Moolenaar <Bram@vim.org>
parents:
29014
diff
changeset
|
2725 |
e150d0e4701f
patch 8.2.5043: can open a cmdline window from a substitute expression
Bram Moolenaar <Bram@vim.org>
parents:
29014
diff
changeset
|
2726 /* |
1834 | 2727 * Check if "curbuf_lock" or "allbuf_lock" is set and return TRUE when it is |
2728 * and give an error message. | |
819 | 2729 */ |
2730 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2731 curbuf_locked(void) |
819 | 2732 { |
2733 if (curbuf_lock > 0) | |
2734 { | |
26958
d92e0d85923f
patch 8.2.4008: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26883
diff
changeset
|
2735 emsg(_(e_not_allowed_to_edit_another_buffer_now)); |
819 | 2736 return TRUE; |
2737 } | |
1834 | 2738 return allbuf_locked(); |
2739 } | |
2740 | |
2741 /* | |
2742 * Check if "allbuf_lock" is set and return TRUE when it is and give an error | |
2743 * message. | |
2744 */ | |
2745 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2746 allbuf_locked(void) |
1834 | 2747 { |
2748 if (allbuf_lock > 0) | |
2749 { | |
26962
85866e069c24
patch 8.2.4010: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26958
diff
changeset
|
2750 emsg(_(e_not_allowed_to_change_buffer_information_now)); |
1834 | 2751 return TRUE; |
2752 } | |
819 | 2753 return FALSE; |
2754 } | |
2755 | |
7 | 2756 static int |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2757 cmdline_charsize(int idx) |
7 | 2758 { |
2759 #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
|
2760 if (cmdline_star > 0) // showing '*', always 1 position |
7 | 2761 return 1; |
2762 #endif | |
2763 return ptr2cells(ccline.cmdbuff + idx); | |
2764 } | |
2765 | |
2766 /* | |
2767 * Compute the offset of the cursor on the command line for the prompt and | |
2768 * indent. | |
2769 */ | |
2770 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2771 set_cmdspos(void) |
7 | 2772 { |
531 | 2773 if (ccline.cmdfirstc != NUL) |
7 | 2774 ccline.cmdspos = 1 + ccline.cmdindent; |
2775 else | |
2776 ccline.cmdspos = 0 + ccline.cmdindent; | |
2777 } | |
2778 | |
2779 /* | |
2780 * Compute the screen position for the cursor on the command line. | |
2781 */ | |
2782 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2783 set_cmdspos_cursor(void) |
7 | 2784 { |
2785 int i, m, c; | |
2786 | |
2787 set_cmdspos(); | |
2788 if (KeyTyped) | |
534 | 2789 { |
7 | 2790 m = Columns * Rows; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2791 if (m < 0) // overflow, Columns or Rows at weird value |
534 | 2792 m = MAXCOL; |
2793 } | |
7 | 2794 else |
2795 m = MAXCOL; | |
2796 for (i = 0; i < ccline.cmdlen && i < ccline.cmdpos; ++i) | |
2797 { | |
2798 c = cmdline_charsize(i); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2799 // Count ">" for double-wide multi-byte char that doesn't fit. |
7 | 2800 if (has_mbyte) |
2801 correct_cmdspos(i, c); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2802 // 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
|
2803 // Don't move the cursor itself, so we can still append. |
7 | 2804 if ((ccline.cmdspos += c) >= m) |
2805 { | |
2806 ccline.cmdspos -= c; | |
2807 break; | |
2808 } | |
2809 if (has_mbyte) | |
474 | 2810 i += (*mb_ptr2len)(ccline.cmdbuff + i) - 1; |
7 | 2811 } |
2812 } | |
2813 | |
2814 /* | |
2815 * Check if the character at "idx", which is "cells" wide, is a multi-byte | |
2816 * character that doesn't fit, so that a ">" must be displayed. | |
2817 */ | |
2818 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2819 correct_cmdspos(int idx, int cells) |
7 | 2820 { |
474 | 2821 if ((*mb_ptr2len)(ccline.cmdbuff + idx) > 1 |
7 | 2822 && (*mb_ptr2cells)(ccline.cmdbuff + idx) > 1 |
2823 && ccline.cmdspos % Columns + cells > Columns) | |
2824 ccline.cmdspos++; | |
2825 } | |
2826 | |
2827 /* | |
2828 * Get an Ex command line for the ":" command. | |
2829 */ | |
2830 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2831 getexline( |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2832 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
|
2833 void *cookie UNUSED, |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2834 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
|
2835 getline_opt_T options) |
7 | 2836 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2837 // When executing a register, remove ':' that's in front of each line. |
7 | 2838 if (exec_from_reg && vpeekc() == ':') |
2839 (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
|
2840 return getcmdline(c, 1L, indent, options); |
7 | 2841 } |
2842 | |
2843 /* | |
2844 * Get an Ex command line for Ex mode. | |
2845 * In Ex mode we only use the OS supplied line editing features and no | |
2846 * mappings or abbreviations. | |
168 | 2847 * Returns a string in allocated memory or NULL. |
7 | 2848 */ |
2849 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2850 getexmodeline( |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2851 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
|
2852 // :s prompt |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
2853 void *cookie UNUSED, |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2854 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
|
2855 getline_opt_T options UNUSED) |
7 | 2856 { |
168 | 2857 garray_T line_ga; |
2858 char_u *pend; | |
2859 int startcol = 0; | |
1329 | 2860 int c1 = 0; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2861 int escaped = FALSE; // CTRL-V typed |
168 | 2862 int vcol = 0; |
2863 char_u *p; | |
1329 | 2864 int prev_char; |
5966 | 2865 int len; |
7 | 2866 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2867 // 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
|
2868 // confuses the system function that computes tabstops. |
7 | 2869 cursor_on(); |
2870 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2871 // always start in column 0; write a newline if necessary |
7 | 2872 compute_cmdrow(); |
168 | 2873 if ((msg_col || msg_didout) && promptc != '?') |
7 | 2874 msg_putchar('\n'); |
168 | 2875 if (promptc == ':') |
7 | 2876 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2877 // indent that is only displayed, not in the line itself |
168 | 2878 if (p_prompt) |
2879 msg_putchar(':'); | |
7 | 2880 while (indent-- > 0) |
2881 msg_putchar(' '); | |
2882 startcol = msg_col; | |
2883 } | |
2884 | |
2885 ga_init2(&line_ga, 1, 30); | |
2886 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2887 // autoindent for :insert and :append is in the line itself |
168 | 2888 if (promptc <= 0) |
164 | 2889 { |
2890 vcol = indent; | |
2891 while (indent >= 8) | |
2892 { | |
2893 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
|
2894 msg_puts(" "); |
164 | 2895 indent -= 8; |
2896 } | |
2897 while (indent-- > 0) | |
2898 { | |
2899 ga_append(&line_ga, ' '); | |
2900 msg_putchar(' '); | |
2901 } | |
2902 } | |
168 | 2903 ++no_mapping; |
2904 ++allow_keys; | |
164 | 2905 |
7 | 2906 /* |
2907 * Get the line, one character at a time. | |
2908 */ | |
2909 got_int = FALSE; | |
168 | 2910 while (!got_int) |
7 | 2911 { |
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
|
2912 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
|
2913 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
|
2914 |
31293
ff4473b3fc58
patch 9.0.0980: the keyboard state response may end up in a shell command
Bram Moolenaar <Bram@vim.org>
parents:
31115
diff
changeset
|
2915 // May request the keyboard protocol state now. |
ff4473b3fc58
patch 9.0.0980: the keyboard state response may end up in a shell command
Bram Moolenaar <Bram@vim.org>
parents:
31115
diff
changeset
|
2916 may_send_t_RK(); |
ff4473b3fc58
patch 9.0.0980: the keyboard state response may end up in a shell command
Bram Moolenaar <Bram@vim.org>
parents:
31115
diff
changeset
|
2917 |
7 | 2918 if (ga_grow(&line_ga, 40) == FAIL) |
2919 break; | |
2920 | |
10970
ab9f7bbe4439
patch 8.0.0374: invalid memory access when using :sc in Ex mode
Christian Brabandt <cb@256bit.org>
parents:
10942
diff
changeset
|
2921 /* |
ab9f7bbe4439
patch 8.0.0374: invalid memory access when using :sc in Ex mode
Christian Brabandt <cb@256bit.org>
parents:
10942
diff
changeset
|
2922 * 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
|
2923 */ |
1329 | 2924 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
|
2925 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2926 // 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
|
2927 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
|
2928 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
|
2929 else |
ab9f7bbe4439
patch 8.0.0374: invalid memory access when using :sc in Ex mode
Christian Brabandt <cb@256bit.org>
parents:
10942
diff
changeset
|
2930 c1 = vgetc(); |
7 | 2931 |
2932 /* | |
168 | 2933 * Handle line editing. |
2934 * Previously this was left to the system, putting the terminal in | |
2935 * cooked mode, but then CTRL-D and CTRL-T can't be used properly. | |
7 | 2936 */ |
168 | 2937 if (got_int) |
2938 { | |
2939 msg_putchar('\n'); | |
2940 break; | |
2941 } | |
2942 | |
10676
b8c04c007d39
patch 8.0.0228: pasting in xterm on the command line has PasteStart
Christian Brabandt <cb@256bit.org>
parents:
10565
diff
changeset
|
2943 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
|
2944 { |
b8c04c007d39
patch 8.0.0228: pasting in xterm on the command line has PasteStart
Christian Brabandt <cb@256bit.org>
parents:
10565
diff
changeset
|
2945 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
|
2946 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
|
2947 } |
b8c04c007d39
patch 8.0.0228: pasting in xterm on the command line has PasteStart
Christian Brabandt <cb@256bit.org>
parents:
10565
diff
changeset
|
2948 |
168 | 2949 if (!escaped) |
7 | 2950 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2951 // CR typed means "enter", which is NL |
168 | 2952 if (c1 == '\r') |
2953 c1 = '\n'; | |
2954 | |
2955 if (c1 == BS || c1 == K_BS | |
2956 || c1 == DEL || c1 == K_DEL || c1 == K_KDEL) | |
7 | 2957 { |
168 | 2958 if (line_ga.ga_len > 0) |
2959 { | |
5966 | 2960 if (has_mbyte) |
2961 { | |
2962 p = (char_u *)line_ga.ga_data; | |
2963 p[line_ga.ga_len] = NUL; | |
2964 len = (*mb_head_off)(p, p + line_ga.ga_len - 1) + 1; | |
2965 line_ga.ga_len -= len; | |
2966 } | |
2967 else | |
2968 --line_ga.ga_len; | |
168 | 2969 goto redraw; |
2970 } | |
2971 continue; | |
7 | 2972 } |
2973 | |
168 | 2974 if (c1 == Ctrl_U) |
7 | 2975 { |
168 | 2976 msg_col = startcol; |
2977 msg_clr_eos(); | |
2978 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
|
2979 goto redraw; |
168 | 2980 } |
2981 | |
2982 if (c1 == Ctrl_T) | |
2983 { | |
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
|
2984 sw = get_sw_value(curbuf); |
168 | 2985 p = (char_u *)line_ga.ga_data; |
2986 p[line_ga.ga_len] = NUL; | |
5995 | 2987 indent = get_indent_str(p, 8, FALSE); |
3740 | 2988 indent += sw - indent % sw; |
168 | 2989 add_indent: |
5995 | 2990 while (get_indent_str(p, 8, FALSE) < indent) |
7 | 2991 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
2992 (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
|
2993 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
|
2994 s = skipwhite(p); |
168 | 2995 mch_memmove(s + 1, s, line_ga.ga_len - (s - p) + 1); |
2996 *s = ' '; | |
2997 ++line_ga.ga_len; | |
7 | 2998 } |
168 | 2999 redraw: |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3000 // redraw the line |
168 | 3001 msg_col = startcol; |
3002 vcol = 0; | |
5966 | 3003 p = (char_u *)line_ga.ga_data; |
3004 p[line_ga.ga_len] = NUL; | |
3005 while (p < (char_u *)line_ga.ga_data + line_ga.ga_len) | |
7 | 3006 { |
168 | 3007 if (*p == TAB) |
7 | 3008 { |
168 | 3009 do |
3010 msg_putchar(' '); | |
16162
cd5c83115ec6
patch 8.1.1086: too many curly braces
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
3011 while (++vcol % 8); |
5966 | 3012 ++p; |
7 | 3013 } |
168 | 3014 else |
164 | 3015 { |
18251
c8a53c0daeed
patch 8.1.2120: some MB_ macros are more complicated than necessary
Bram Moolenaar <Bram@vim.org>
parents:
18227
diff
changeset
|
3016 len = mb_ptr2len(p); |
5966 | 3017 msg_outtrans_len(p, len); |
3018 vcol += ptr2cells(p); | |
3019 p += len; | |
7 | 3020 } |
3021 } | |
168 | 3022 msg_clr_eos(); |
1329 | 3023 windgoto(msg_row, msg_col); |
168 | 3024 continue; |
3025 } | |
3026 | |
3027 if (c1 == Ctrl_D) | |
3028 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3029 // Delete one shiftwidth. |
168 | 3030 p = (char_u *)line_ga.ga_data; |
3031 if (prev_char == '0' || prev_char == '^') | |
7 | 3032 { |
168 | 3033 if (prev_char == '^') |
3034 ex_keep_indent = TRUE; | |
3035 indent = 0; | |
3036 p[--line_ga.ga_len] = NUL; | |
7 | 3037 } |
3038 else | |
3039 { | |
168 | 3040 p[line_ga.ga_len] = NUL; |
5995 | 3041 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
|
3042 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
|
3043 { |
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
|
3044 --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
|
3045 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
|
3046 } |
168 | 3047 } |
5995 | 3048 while (get_indent_str(p, 8, FALSE) > indent) |
168 | 3049 { |
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
|
3050 s = skipwhite(p); |
168 | 3051 mch_memmove(s - 1, s, line_ga.ga_len - (s - p) + 1); |
3052 --line_ga.ga_len; | |
7 | 3053 } |
168 | 3054 goto add_indent; |
3055 } | |
3056 | |
3057 if (c1 == Ctrl_V || c1 == Ctrl_Q) | |
3058 { | |
3059 escaped = TRUE; | |
3060 continue; | |
7 | 3061 } |
168 | 3062 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3063 // Ignore special key codes: mouse movement, K_IGNORE, etc. |
168 | 3064 if (IS_SPECIAL(c1)) |
3065 continue; | |
7 | 3066 } |
168 | 3067 |
3068 if (IS_SPECIAL(c1)) | |
3069 c1 = '?'; | |
5966 | 3070 if (has_mbyte) |
3071 len = (*mb_char2bytes)(c1, | |
3072 (char_u *)line_ga.ga_data + line_ga.ga_len); | |
3073 else | |
3074 { | |
3075 len = 1; | |
3076 ((char_u *)line_ga.ga_data)[line_ga.ga_len] = c1; | |
3077 } | |
168 | 3078 if (c1 == '\n') |
3079 msg_putchar('\n'); | |
3080 else if (c1 == TAB) | |
3081 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3082 // Don't use chartabsize(), 'ts' can be different |
168 | 3083 do |
3084 msg_putchar(' '); | |
16162
cd5c83115ec6
patch 8.1.1086: too many curly braces
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
3085 while (++vcol % 8); |
168 | 3086 } |
7 | 3087 else |
3088 { | |
168 | 3089 msg_outtrans_len( |
5966 | 3090 ((char_u *)line_ga.ga_data) + line_ga.ga_len, len); |
168 | 3091 vcol += char2cells(c1); |
7 | 3092 } |
5966 | 3093 line_ga.ga_len += len; |
168 | 3094 escaped = FALSE; |
3095 | |
3096 windgoto(msg_row, msg_col); | |
164 | 3097 pend = (char_u *)(line_ga.ga_data) + line_ga.ga_len; |
168 | 3098 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3099 // 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
|
3100 // odd number of backslashes, that results in a NUL. |
2590 | 3101 if (line_ga.ga_len > 0 && pend[-1] == '\n') |
7 | 3102 { |
2590 | 3103 int bcount = 0; |
3104 | |
3105 while (line_ga.ga_len - 2 >= bcount && pend[-2 - bcount] == '\\') | |
3106 ++bcount; | |
3107 | |
3108 if (bcount > 0) | |
3109 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3110 // 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
|
3111 // "\NL", etc. |
2590 | 3112 line_ga.ga_len -= (bcount + 1) / 2; |
3113 pend -= (bcount + 1) / 2; | |
3114 pend[-1] = '\n'; | |
3115 } | |
3116 | |
3117 if ((bcount & 1) == 0) | |
3118 { | |
3119 --line_ga.ga_len; | |
3120 --pend; | |
3121 *pend = NUL; | |
3122 break; | |
3123 } | |
7 | 3124 } |
3125 } | |
3126 | |
168 | 3127 --no_mapping; |
3128 --allow_keys; | |
3129 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3130 // make following messages go to the next line |
7 | 3131 msg_didout = FALSE; |
3132 msg_col = 0; | |
3133 if (msg_row < Rows - 1) | |
3134 ++msg_row; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3135 emsg_on_display = FALSE; // don't want ui_delay() |
7 | 3136 |
3137 if (got_int) | |
3138 ga_clear(&line_ga); | |
3139 | |
3140 return (char_u *)line_ga.ga_data; | |
3141 } | |
3142 | |
502 | 3143 # if defined(MCH_CURSOR_SHAPE) || defined(FEAT_GUI) \ |
3144 || defined(FEAT_MOUSESHAPE) || defined(PROTO) | |
7 | 3145 /* |
3146 * Return TRUE if ccline.overstrike is on. | |
3147 */ | |
3148 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3149 cmdline_overstrike(void) |
7 | 3150 { |
3151 return ccline.overstrike; | |
3152 } | |
3153 | |
3154 /* | |
3155 * Return TRUE if the cursor is at the end of the cmdline. | |
3156 */ | |
3157 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3158 cmdline_at_end(void) |
7 | 3159 { |
3160 return (ccline.cmdpos >= ccline.cmdlen); | |
3161 } | |
3162 #endif | |
3163 | |
574 | 3164 #if (defined(FEAT_XIM) && (defined(FEAT_GUI_GTK))) || defined(PROTO) |
7 | 3165 /* |
3166 * Return the virtual column number at the current cursor position. | |
3167 * This is used by the IM code to obtain the start of the preedit string. | |
3168 */ | |
3169 colnr_T | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3170 cmdline_getvcol_cursor(void) |
7 | 3171 { |
3172 if (ccline.cmdbuff == NULL || ccline.cmdpos > ccline.cmdlen) | |
3173 return MAXCOL; | |
3174 | |
3175 if (has_mbyte) | |
3176 { | |
3177 colnr_T col; | |
3178 int i = 0; | |
3179 | |
3180 for (col = 0; i < ccline.cmdpos; ++col) | |
474 | 3181 i += (*mb_ptr2len)(ccline.cmdbuff + i); |
7 | 3182 |
3183 return col; | |
3184 } | |
3185 else | |
3186 return ccline.cmdpos; | |
3187 } | |
3188 #endif | |
3189 | |
3190 #if defined(FEAT_XIM) && defined(FEAT_GUI_GTK) | |
3191 /* | |
3192 * If part of the command line is an IM preedit string, redraw it with | |
3193 * IM feedback attributes. The cursor position is restored after drawing. | |
3194 */ | |
3195 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3196 redrawcmd_preedit(void) |
7 | 3197 { |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28771
diff
changeset
|
3198 if ((State & MODE_CMDLINE) |
7 | 3199 && xic != NULL |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3200 // && im_get_status() doesn't work when using SCIM |
7 | 3201 && !p_imdisable |
3202 && im_is_preediting()) | |
3203 { | |
3204 int cmdpos = 0; | |
3205 int cmdspos; | |
3206 int old_row; | |
3207 int old_col; | |
3208 colnr_T col; | |
3209 | |
3210 old_row = msg_row; | |
3211 old_col = msg_col; | |
531 | 3212 cmdspos = ((ccline.cmdfirstc != NUL) ? 1 : 0) + ccline.cmdindent; |
7 | 3213 |
3214 if (has_mbyte) | |
3215 { | |
3216 for (col = 0; col < preedit_start_col | |
3217 && cmdpos < ccline.cmdlen; ++col) | |
3218 { | |
3219 cmdspos += (*mb_ptr2cells)(ccline.cmdbuff + cmdpos); | |
474 | 3220 cmdpos += (*mb_ptr2len)(ccline.cmdbuff + cmdpos); |
7 | 3221 } |
3222 } | |
3223 else | |
3224 { | |
3225 cmdspos += preedit_start_col; | |
3226 cmdpos += preedit_start_col; | |
3227 } | |
3228 | |
3229 msg_row = cmdline_row + (cmdspos / (int)Columns); | |
3230 msg_col = cmdspos % (int)Columns; | |
3231 if (msg_row >= Rows) | |
3232 msg_row = Rows - 1; | |
3233 | |
3234 for (col = 0; cmdpos < ccline.cmdlen; ++col) | |
3235 { | |
3236 int char_len; | |
3237 int char_attr; | |
3238 | |
3239 char_attr = im_get_feedback_attr(col); | |
3240 if (char_attr < 0) | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3241 break; // end of preedit string |
7 | 3242 |
3243 if (has_mbyte) | |
474 | 3244 char_len = (*mb_ptr2len)(ccline.cmdbuff + cmdpos); |
7 | 3245 else |
3246 char_len = 1; | |
3247 | |
3248 msg_outtrans_len_attr(ccline.cmdbuff + cmdpos, char_len, char_attr); | |
3249 cmdpos += char_len; | |
3250 } | |
3251 | |
3252 msg_row = old_row; | |
3253 msg_col = old_col; | |
3254 } | |
3255 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3256 #endif // FEAT_XIM && FEAT_GUI_GTK |
7 | 3257 |
3258 /* | |
3259 * Allocate a new command line buffer. | |
3260 * Assigns the new buffer to ccline.cmdbuff and ccline.cmdbufflen. | |
3261 */ | |
3262 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3263 alloc_cmdbuff(int len) |
7 | 3264 { |
3265 /* | |
3266 * give some extra space to avoid having to allocate all the time | |
3267 */ | |
3268 if (len < 80) | |
3269 len = 100; | |
3270 else | |
3271 len += 20; | |
3272 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3273 ccline.cmdbuff = alloc(len); // caller should check for out-of-memory |
7 | 3274 ccline.cmdbufflen = len; |
3275 } | |
3276 | |
3277 /* | |
3278 * Re-allocate the command line to length len + something extra. | |
3279 * return FAIL for failure, OK otherwise | |
3280 */ | |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
3281 int |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3282 realloc_cmdbuff(int len) |
7 | 3283 { |
3284 char_u *p; | |
3285 | |
2557
029ace8dff7d
Now really fix using expressions in the command line (hopefully).
Bram Moolenaar <bram@vim.org>
parents:
2556
diff
changeset
|
3286 if (len < ccline.cmdbufflen) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3287 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
|
3288 |
7 | 3289 p = ccline.cmdbuff; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3290 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
|
3291 if (ccline.cmdbuff == NULL) // out of memory |
7 | 3292 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3293 ccline.cmdbuff = p; // keep the old one |
7 | 3294 return FAIL; |
3295 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3296 // 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
|
3297 // 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
|
3298 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
|
3299 ccline.cmdbuff[ccline.cmdlen] = NUL; |
7 | 3300 vim_free(p); |
1718 | 3301 |
3302 if (ccline.xpc != NULL | |
3303 && ccline.xpc->xp_pattern != NULL | |
3304 && ccline.xpc->xp_context != EXPAND_NOTHING | |
3305 && ccline.xpc->xp_context != EXPAND_UNSUCCESSFUL) | |
3306 { | |
1754 | 3307 int i = (int)(ccline.xpc->xp_pattern - p); |
1718 | 3308 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3309 // 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
|
3310 // to point into the newly allocated memory. |
1718 | 3311 if (i >= 0 && i <= ccline.cmdlen) |
3312 ccline.xpc->xp_pattern = ccline.cmdbuff + i; | |
3313 } | |
3314 | |
7 | 3315 return OK; |
3316 } | |
3317 | |
359 | 3318 #if defined(FEAT_ARABIC) || defined(PROTO) |
3319 static char_u *arshape_buf = NULL; | |
3320 | |
3321 # if defined(EXITFREE) || defined(PROTO) | |
3322 void | |
17266
a9556c0ba457
patch 8.1.1632: build with EXITFREE but without +arabic fails
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
3323 free_arshape_buf(void) |
359 | 3324 { |
3325 vim_free(arshape_buf); | |
3326 } | |
3327 # endif | |
3328 #endif | |
3329 | |
7 | 3330 /* |
3331 * Draw part of the cmdline at the current cursor position. But draw stars | |
3332 * when cmdline_star is TRUE. | |
3333 */ | |
3334 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3335 draw_cmdline(int start, int len) |
7 | 3336 { |
3337 #if defined(FEAT_CRYPT) || defined(FEAT_EVAL) | |
3338 int i; | |
3339 | |
3340 if (cmdline_star > 0) | |
3341 for (i = 0; i < len; ++i) | |
3342 { | |
3343 msg_putchar('*'); | |
3344 if (has_mbyte) | |
474 | 3345 i += (*mb_ptr2len)(ccline.cmdbuff + start + i) - 1; |
7 | 3346 } |
3347 else | |
3348 #endif | |
3349 #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
|
3350 if (p_arshape && !p_tbidi && cmdline_has_arabic(start, len)) |
7 | 3351 { |
3352 static int buflen = 0; | |
3353 char_u *p; | |
3354 int j; | |
3355 int newlen = 0; | |
3356 int mb_l; | |
719 | 3357 int pc, pc1 = 0; |
7 | 3358 int prev_c = 0; |
3359 int prev_c1 = 0; | |
714 | 3360 int u8c; |
3361 int u8cc[MAX_MCO]; | |
7 | 3362 int nc = 0; |
3363 | |
3364 /* | |
3365 * Do arabic shaping into a temporary buffer. This is very | |
3366 * inefficient! | |
3367 */ | |
507 | 3368 if (len * 2 + 2 > buflen) |
7 | 3369 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3370 // 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
|
3371 // alloc()/free() calls. |
359 | 3372 vim_free(arshape_buf); |
507 | 3373 buflen = len * 2 + 2; |
359 | 3374 arshape_buf = alloc(buflen); |
3375 if (arshape_buf == NULL) | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3376 return; // out of memory |
7 | 3377 } |
3378 | |
507 | 3379 if (utf_iscomposing(utf_ptr2char(ccline.cmdbuff + start))) |
3380 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3381 // Prepend a space to draw the leading composing char on. |
507 | 3382 arshape_buf[0] = ' '; |
3383 newlen = 1; | |
3384 } | |
3385 | |
7 | 3386 for (j = start; j < start + len; j += mb_l) |
3387 { | |
3388 p = ccline.cmdbuff + j; | |
714 | 3389 u8c = utfc_ptr2char_len(p, u8cc, start + len - j); |
474 | 3390 mb_l = utfc_ptr2len_len(p, start + len - j); |
7 | 3391 if (ARABIC_CHAR(u8c)) |
3392 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3393 // Do Arabic shaping. |
7 | 3394 if (cmdmsg_rl) |
3395 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3396 // displaying from right to left |
7 | 3397 pc = prev_c; |
3398 pc1 = prev_c1; | |
714 | 3399 prev_c1 = u8cc[0]; |
7 | 3400 if (j + mb_l >= start + len) |
3401 nc = NUL; | |
3402 else | |
3403 nc = utf_ptr2char(p + mb_l); | |
3404 } | |
3405 else | |
3406 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3407 // displaying from left to right |
7 | 3408 if (j + mb_l >= start + len) |
3409 pc = NUL; | |
3410 else | |
714 | 3411 { |
3412 int pcc[MAX_MCO]; | |
3413 | |
3414 pc = utfc_ptr2char_len(p + mb_l, pcc, | |
7 | 3415 start + len - j - mb_l); |
714 | 3416 pc1 = pcc[0]; |
3417 } | |
7 | 3418 nc = prev_c; |
3419 } | |
3420 prev_c = u8c; | |
3421 | |
714 | 3422 u8c = arabic_shape(u8c, NULL, &u8cc[0], pc, pc1, nc); |
7 | 3423 |
359 | 3424 newlen += (*mb_char2bytes)(u8c, arshape_buf + newlen); |
714 | 3425 if (u8cc[0] != 0) |
7 | 3426 { |
714 | 3427 newlen += (*mb_char2bytes)(u8cc[0], arshape_buf + newlen); |
3428 if (u8cc[1] != 0) | |
3429 newlen += (*mb_char2bytes)(u8cc[1], | |
359 | 3430 arshape_buf + newlen); |
7 | 3431 } |
3432 } | |
3433 else | |
3434 { | |
3435 prev_c = u8c; | |
359 | 3436 mch_memmove(arshape_buf + newlen, p, mb_l); |
7 | 3437 newlen += mb_l; |
3438 } | |
3439 } | |
3440 | |
359 | 3441 msg_outtrans_len(arshape_buf, newlen); |
7 | 3442 } |
3443 else | |
3444 #endif | |
3445 msg_outtrans_len(ccline.cmdbuff + start, len); | |
3446 } | |
3447 | |
3448 /* | |
3449 * Put a character on the command line. Shifts the following text to the | |
3450 * right when "shift" is TRUE. Used for CTRL-V, CTRL-K, etc. | |
3451 * "c" must be printable (fit in one display cell)! | |
3452 */ | |
3453 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3454 putcmdline(int c, int shift) |
7 | 3455 { |
3456 if (cmd_silent) | |
3457 return; | |
3458 msg_no_more = TRUE; | |
3459 msg_putchar(c); | |
3460 if (shift) | |
3461 draw_cmdline(ccline.cmdpos, ccline.cmdlen - ccline.cmdpos); | |
3462 msg_no_more = FALSE; | |
3463 cursorcmd(); | |
11674
d093e4167733
patch 8.0.0720: unfinished mapping not displayed when running timer
Christian Brabandt <cb@256bit.org>
parents:
11664
diff
changeset
|
3464 extra_char = c; |
d093e4167733
patch 8.0.0720: unfinished mapping not displayed when running timer
Christian Brabandt <cb@256bit.org>
parents:
11664
diff
changeset
|
3465 extra_char_shift = shift; |
7 | 3466 } |
3467 | |
3468 /* | |
3469 * Undo a putcmdline(c, FALSE). | |
3470 */ | |
3471 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3472 unputcmdline(void) |
7 | 3473 { |
3474 if (cmd_silent) | |
3475 return; | |
3476 msg_no_more = TRUE; | |
3477 if (ccline.cmdlen == ccline.cmdpos) | |
3478 msg_putchar(' '); | |
3558 | 3479 else if (has_mbyte) |
3480 draw_cmdline(ccline.cmdpos, | |
3481 (*mb_ptr2len)(ccline.cmdbuff + ccline.cmdpos)); | |
7 | 3482 else |
3483 draw_cmdline(ccline.cmdpos, 1); | |
3484 msg_no_more = FALSE; | |
3485 cursorcmd(); | |
11674
d093e4167733
patch 8.0.0720: unfinished mapping not displayed when running timer
Christian Brabandt <cb@256bit.org>
parents:
11664
diff
changeset
|
3486 extra_char = NUL; |
7 | 3487 } |
3488 | |
3489 /* | |
3490 * Put the given string, of the given length, onto the command line. | |
3491 * If len is -1, then STRLEN() is used to calculate the length. | |
3492 * If 'redraw' is TRUE then the new part of the command line, and the remaining | |
3493 * part will be redrawn, otherwise it will not. If this function is called | |
3494 * twice in a row, then 'redraw' should be FALSE and redrawcmd() should be | |
3495 * called afterwards. | |
3496 */ | |
3497 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3498 put_on_cmdline(char_u *str, int len, int redraw) |
7 | 3499 { |
3500 int retval; | |
3501 int i; | |
3502 int m; | |
3503 int c; | |
3504 | |
3505 if (len < 0) | |
3506 len = (int)STRLEN(str); | |
3507 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3508 // Check if ccline.cmdbuff needs to be longer |
7 | 3509 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
|
3510 retval = realloc_cmdbuff(ccline.cmdlen + len + 1); |
7 | 3511 else |
3512 retval = OK; | |
3513 if (retval == OK) | |
3514 { | |
3515 if (!ccline.overstrike) | |
3516 { | |
3517 mch_memmove(ccline.cmdbuff + ccline.cmdpos + len, | |
3518 ccline.cmdbuff + ccline.cmdpos, | |
3519 (size_t)(ccline.cmdlen - ccline.cmdpos)); | |
3520 ccline.cmdlen += len; | |
3521 } | |
3522 else | |
3523 { | |
3524 if (has_mbyte) | |
3525 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3526 // Count nr of characters in the new string. |
7 | 3527 m = 0; |
474 | 3528 for (i = 0; i < len; i += (*mb_ptr2len)(str + i)) |
7 | 3529 ++m; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3530 // 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
|
3531 // characters. |
7 | 3532 for (i = ccline.cmdpos; i < ccline.cmdlen && m > 0; |
474 | 3533 i += (*mb_ptr2len)(ccline.cmdbuff + i)) |
7 | 3534 --m; |
3535 if (i < ccline.cmdlen) | |
3536 { | |
3537 mch_memmove(ccline.cmdbuff + ccline.cmdpos + len, | |
3538 ccline.cmdbuff + i, (size_t)(ccline.cmdlen - i)); | |
3539 ccline.cmdlen += ccline.cmdpos + len - i; | |
3540 } | |
3541 else | |
3542 ccline.cmdlen = ccline.cmdpos + len; | |
3543 } | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15575
diff
changeset
|
3544 else if (ccline.cmdpos + len > ccline.cmdlen) |
7 | 3545 ccline.cmdlen = ccline.cmdpos + len; |
3546 } | |
3547 mch_memmove(ccline.cmdbuff + ccline.cmdpos, str, (size_t)len); | |
3548 ccline.cmdbuff[ccline.cmdlen] = NUL; | |
3549 | |
3550 if (enc_utf8) | |
3551 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3552 // 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
|
3553 // backup to the character before it. There could be two of them. |
7 | 3554 i = 0; |
3555 c = utf_ptr2char(ccline.cmdbuff + ccline.cmdpos); | |
3556 while (ccline.cmdpos > 0 && utf_iscomposing(c)) | |
3557 { | |
3558 i = (*mb_head_off)(ccline.cmdbuff, | |
3559 ccline.cmdbuff + ccline.cmdpos - 1) + 1; | |
3560 ccline.cmdpos -= i; | |
3561 len += i; | |
3562 c = utf_ptr2char(ccline.cmdbuff + ccline.cmdpos); | |
3563 } | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15575
diff
changeset
|
3564 #ifdef FEAT_ARABIC |
7 | 3565 if (i == 0 && ccline.cmdpos > 0 && arabic_maycombine(c)) |
3566 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3567 // Check the previous character for Arabic combining pair. |
7 | 3568 i = (*mb_head_off)(ccline.cmdbuff, |
3569 ccline.cmdbuff + ccline.cmdpos - 1) + 1; | |
3570 if (arabic_combine(utf_ptr2char(ccline.cmdbuff | |
3571 + ccline.cmdpos - i), c)) | |
3572 { | |
3573 ccline.cmdpos -= i; | |
3574 len += i; | |
3575 } | |
3576 else | |
3577 i = 0; | |
3578 } | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15575
diff
changeset
|
3579 #endif |
7 | 3580 if (i != 0) |
3581 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3582 // Also backup the cursor position. |
7 | 3583 i = ptr2cells(ccline.cmdbuff + ccline.cmdpos); |
3584 ccline.cmdspos -= i; | |
3585 msg_col -= i; | |
3586 if (msg_col < 0) | |
3587 { | |
3588 msg_col += Columns; | |
3589 --msg_row; | |
3590 } | |
3591 } | |
3592 } | |
3593 | |
3594 if (redraw && !cmd_silent) | |
3595 { | |
3596 msg_no_more = TRUE; | |
3597 i = cmdline_row; | |
3114 | 3598 cursorcmd(); |
7 | 3599 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
|
3600 // Avoid clearing the rest of the line too often. |
7 | 3601 if (cmdline_row != i || ccline.overstrike) |
3602 msg_clr_eos(); | |
3603 msg_no_more = FALSE; | |
3604 } | |
15850
a6ca8cf07a98
patch 8.1.0932: Farsi support is outdated and unused
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
3605 if (KeyTyped) |
a6ca8cf07a98
patch 8.1.0932: Farsi support is outdated and unused
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
3606 { |
a6ca8cf07a98
patch 8.1.0932: Farsi support is outdated and unused
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
3607 m = Columns * Rows; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3608 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
|
3609 m = MAXCOL; |
a6ca8cf07a98
patch 8.1.0932: Farsi support is outdated and unused
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
3610 } |
a6ca8cf07a98
patch 8.1.0932: Farsi support is outdated and unused
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
3611 else |
a6ca8cf07a98
patch 8.1.0932: Farsi support is outdated and unused
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
3612 m = MAXCOL; |
a6ca8cf07a98
patch 8.1.0932: Farsi support is outdated and unused
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
3613 for (i = 0; i < len; ++i) |
7 | 3614 { |
15850
a6ca8cf07a98
patch 8.1.0932: Farsi support is outdated and unused
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
3615 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
|
3616 // 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
|
3617 if (has_mbyte) |
a6ca8cf07a98
patch 8.1.0932: Farsi support is outdated and unused
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
3618 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
|
3619 // 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
|
3620 // 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
|
3621 // 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
|
3622 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
|
3623 ccline.cmdspos += c; |
a6ca8cf07a98
patch 8.1.0932: Farsi support is outdated and unused
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
3624 |
a6ca8cf07a98
patch 8.1.0932: Farsi support is outdated and unused
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
3625 if (has_mbyte) |
7 | 3626 { |
15850
a6ca8cf07a98
patch 8.1.0932: Farsi support is outdated and unused
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
3627 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
|
3628 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
|
3629 c = len - i - 1; |
a6ca8cf07a98
patch 8.1.0932: Farsi support is outdated and unused
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
3630 ccline.cmdpos += c; |
a6ca8cf07a98
patch 8.1.0932: Farsi support is outdated and unused
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
3631 i += c; |
7 | 3632 } |
15850
a6ca8cf07a98
patch 8.1.0932: Farsi support is outdated and unused
Bram Moolenaar <Bram@vim.org>
parents:
15597
diff
changeset
|
3633 ++ccline.cmdpos; |
7 | 3634 } |
3635 } | |
3636 if (redraw) | |
3637 msg_check(); | |
3638 return retval; | |
3639 } | |
3640 | |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
3641 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
|
3642 static int prev_ccline_used = FALSE; |
95 | 3643 |
3644 /* | |
3645 * Save ccline, because obtaining the "=" register may execute "normal :cmd" | |
3646 * and overwrite it. But get_cmdline_str() may need it, thus make it | |
3647 * available globally in prev_ccline. | |
3648 */ | |
3649 static void | |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
3650 save_cmdline(cmdline_info_T *ccp) |
95 | 3651 { |
3652 if (!prev_ccline_used) | |
3653 { | |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
3654 CLEAR_FIELD(prev_ccline); |
95 | 3655 prev_ccline_used = TRUE; |
3656 } | |
3657 *ccp = prev_ccline; | |
3658 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
|
3659 ccline.cmdbuff = NULL; // signal that ccline is not in use |
95 | 3660 } |
3661 | |
3662 /* | |
1214 | 3663 * Restore ccline after it has been saved with save_cmdline(). |
95 | 3664 */ |
3665 static void | |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
3666 restore_cmdline(cmdline_info_T *ccp) |
95 | 3667 { |
3668 ccline = prev_ccline; | |
3669 prev_ccline = *ccp; | |
3670 } | |
3671 | |
15 | 3672 /* |
7336
4c5f53a60543
commit https://github.com/vim/vim/commit/6f62fed349bf829da2adb02619dc9acba13c8ab6
Christian Brabandt <cb@256bit.org>
parents:
7250
diff
changeset
|
3673 * 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
|
3674 * Used by CTRL-R command in command-line mode. |
15 | 3675 * insert_reg() can't be used here, because special characters from the |
3676 * register contents will be interpreted as commands. | |
3677 * | |
7336
4c5f53a60543
commit https://github.com/vim/vim/commit/6f62fed349bf829da2adb02619dc9acba13c8ab6
Christian Brabandt <cb@256bit.org>
parents:
7250
diff
changeset
|
3678 * Return FAIL for failure, OK otherwise. |
15 | 3679 */ |
3680 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3681 cmdline_paste( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3682 int regname, |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3683 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
|
3684 int remcr) // remove trailing CR |
15 | 3685 { |
3686 long i; | |
3687 char_u *arg; | |
772 | 3688 char_u *p; |
15 | 3689 int allocated; |
3690 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3691 // 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
|
3692 // the command line |
15 | 3693 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
|
3694 && 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
|
3695 && !valid_yank_reg(regname, FALSE)) |
15 | 3696 return FAIL; |
3697 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3698 // 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
|
3699 // CTRL-C to break the loop. |
15 | 3700 line_breakcheck(); |
3701 if (got_int) | |
3702 return FAIL; | |
3703 | |
3704 #ifdef FEAT_CLIPBOARD | |
3705 regname = may_get_selection(regname); | |
3706 #endif | |
3707 | |
29014
45c182c4f7e9
patch 8.2.5029: "textlock" is always zero
Bram Moolenaar <Bram@vim.org>
parents:
28905
diff
changeset
|
3708 // Need to set "textlock" 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
|
3709 // buffer when evaluating an expression. |
29014
45c182c4f7e9
patch 8.2.5029: "textlock" is always zero
Bram Moolenaar <Bram@vim.org>
parents:
28905
diff
changeset
|
3710 ++textlock; |
15 | 3711 i = get_spec_reg(regname, &arg, &allocated, TRUE); |
29014
45c182c4f7e9
patch 8.2.5029: "textlock" is always zero
Bram Moolenaar <Bram@vim.org>
parents:
28905
diff
changeset
|
3712 --textlock; |
15 | 3713 |
3714 if (i) | |
3715 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3716 // Got the value of a special register in "arg". |
15 | 3717 if (arg == NULL) |
3718 return FAIL; | |
772 | 3719 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3720 // 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
|
3721 // part of the word. |
772 | 3722 p = arg; |
3723 if (p_is && regname == Ctrl_W) | |
3724 { | |
3725 char_u *w; | |
3726 int len; | |
3727 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3728 // Locate start of last word in the cmd buffer. |
2937 | 3729 for (w = ccline.cmdbuff + ccline.cmdpos; w > ccline.cmdbuff; ) |
772 | 3730 { |
3731 if (has_mbyte) | |
3732 { | |
3733 len = (*mb_head_off)(ccline.cmdbuff, w - 1) + 1; | |
3734 if (!vim_iswordc(mb_ptr2char(w - len))) | |
3735 break; | |
3736 w -= len; | |
3737 } | |
3738 else | |
3739 { | |
3740 if (!vim_iswordc(w[-1])) | |
3741 break; | |
3742 --w; | |
3743 } | |
3744 } | |
2937 | 3745 len = (int)((ccline.cmdbuff + ccline.cmdpos) - w); |
772 | 3746 if (p_ic ? STRNICMP(w, arg, len) == 0 : STRNCMP(w, arg, len) == 0) |
3747 p += len; | |
3748 } | |
3749 | |
3750 cmdline_paste_str(p, literally); | |
15 | 3751 if (allocated) |
3752 vim_free(arg); | |
3753 return OK; | |
3754 } | |
3755 | |
1015 | 3756 return cmdline_paste_reg(regname, literally, remcr); |
15 | 3757 } |
3758 | |
3759 /* | |
3760 * Put a string on the command line. | |
3761 * When "literally" is TRUE, insert literally. | |
3762 * When "literally" is FALSE, insert as typed, but don't leave the command | |
3763 * line. | |
3764 */ | |
3765 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3766 cmdline_paste_str(char_u *s, int literally) |
15 | 3767 { |
3768 int c, cv; | |
3769 | |
3770 if (literally) | |
3771 put_on_cmdline(s, -1, TRUE); | |
3772 else | |
3773 while (*s != NUL) | |
3774 { | |
3775 cv = *s; | |
3776 if (cv == Ctrl_V && s[1]) | |
3777 ++s; | |
3778 if (has_mbyte) | |
1606 | 3779 c = mb_cptr2char_adv(&s); |
15 | 3780 else |
3781 c = *s++; | |
3628 | 3782 if (cv == Ctrl_V || c == ESC || c == Ctrl_C |
3783 || c == CAR || c == NL || c == Ctrl_L | |
15 | 3784 #ifdef UNIX |
3785 || c == intr_char | |
3786 #endif | |
3787 || (c == Ctrl_BSL && *s == Ctrl_N)) | |
3788 stuffcharReadbuff(Ctrl_V); | |
3789 stuffcharReadbuff(c); | |
3790 } | |
3791 } | |
3792 | |
7 | 3793 /* |
9066
c7bdd383275d
commit https://github.com/vim/vim/commit/89c79b99328b66f77f1d12dc8c6701dfe2c57f15
Christian Brabandt <cb@256bit.org>
parents:
8765
diff
changeset
|
3794 * 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
|
3795 * 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
|
3796 * overwritten. |
7 | 3797 */ |
3798 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3799 redrawcmdline(void) |
7 | 3800 { |
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
|
3801 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
|
3802 } |
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
|
3803 |
26466
d413104a94c8
patch 8.2.3763: when editing the cmdline a callback may cause a scroll up
Bram Moolenaar <Bram@vim.org>
parents:
26195
diff
changeset
|
3804 /* |
d413104a94c8
patch 8.2.3763: when editing the cmdline a callback may cause a scroll up
Bram Moolenaar <Bram@vim.org>
parents:
26195
diff
changeset
|
3805 * When "do_compute_cmdrow" is TRUE the command line is redrawn at the bottom. |
d413104a94c8
patch 8.2.3763: when editing the cmdline a callback may cause a scroll up
Bram Moolenaar <Bram@vim.org>
parents:
26195
diff
changeset
|
3806 * If FALSE cmdline_row is used, which should redraw in the same place. |
d413104a94c8
patch 8.2.3763: when editing the cmdline a callback may cause a scroll up
Bram Moolenaar <Bram@vim.org>
parents:
26195
diff
changeset
|
3807 */ |
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
|
3808 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
|
3809 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
|
3810 { |
7 | 3811 if (cmd_silent) |
3812 return; | |
3813 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
|
3814 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
|
3815 compute_cmdrow(); |
7 | 3816 redrawcmd(); |
3817 cursorcmd(); | |
3818 } | |
3819 | |
3820 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3821 redrawcmdprompt(void) |
7 | 3822 { |
3823 int i; | |
3824 | |
3825 if (cmd_silent) | |
3826 return; | |
531 | 3827 if (ccline.cmdfirstc != NUL) |
7 | 3828 msg_putchar(ccline.cmdfirstc); |
3829 if (ccline.cmdprompt != NULL) | |
3830 { | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
3831 msg_puts_attr((char *)ccline.cmdprompt, ccline.cmdattr); |
7 | 3832 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
|
3833 // do the reverse of set_cmdspos() |
531 | 3834 if (ccline.cmdfirstc != NUL) |
7 | 3835 --ccline.cmdindent; |
3836 } | |
3837 else | |
3838 for (i = ccline.cmdindent; i > 0; --i) | |
3839 msg_putchar(' '); | |
3840 } | |
3841 | |
3842 /* | |
3843 * Redraw what is currently on the command line. | |
3844 */ | |
3845 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3846 redrawcmd(void) |
7 | 3847 { |
29966
5dfd4bd66ad8
patch 9.0.0321: cannot use the message popup window directly
Bram Moolenaar <Bram@vim.org>
parents:
29964
diff
changeset
|
3848 int save_in_echowindow = in_echowindow; |
5dfd4bd66ad8
patch 9.0.0321: cannot use the message popup window directly
Bram Moolenaar <Bram@vim.org>
parents:
29964
diff
changeset
|
3849 |
7 | 3850 if (cmd_silent) |
3851 return; | |
3852 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3853 // when 'incsearch' is set there may be no command line while redrawing |
683 | 3854 if (ccline.cmdbuff == NULL) |
3855 { | |
3856 windgoto(cmdline_row, 0); | |
3857 msg_clr_eos(); | |
3858 return; | |
3859 } | |
3860 | |
29966
5dfd4bd66ad8
patch 9.0.0321: cannot use the message popup window directly
Bram Moolenaar <Bram@vim.org>
parents:
29964
diff
changeset
|
3861 // Do not put this in the message window. |
5dfd4bd66ad8
patch 9.0.0321: cannot use the message popup window directly
Bram Moolenaar <Bram@vim.org>
parents:
29964
diff
changeset
|
3862 in_echowindow = FALSE; |
5dfd4bd66ad8
patch 9.0.0321: cannot use the message popup window directly
Bram Moolenaar <Bram@vim.org>
parents:
29964
diff
changeset
|
3863 |
29515
e988bbf50e09
patch 9.0.0099: scrollback can be wrong after redrawing the command line
Bram Moolenaar <Bram@vim.org>
parents:
29489
diff
changeset
|
3864 sb_text_restart_cmdline(); |
7 | 3865 msg_start(); |
3866 redrawcmdprompt(); | |
3867 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3868 // Don't use more prompt, truncate the cmdline if it doesn't fit. |
7 | 3869 msg_no_more = TRUE; |
3870 draw_cmdline(0, ccline.cmdlen); | |
3871 msg_clr_eos(); | |
3872 msg_no_more = FALSE; | |
3873 | |
3874 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
|
3875 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
|
3876 putcmdline(extra_char, extra_char_shift); |
7 | 3877 |
3878 /* | |
3879 * An emsg() before may have set msg_scroll. This is used in normal mode, | |
3880 * in cmdline mode we can reset them now. | |
3881 */ | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3882 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
|
3883 |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3884 // 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
|
3885 // in cmdline mode |
7 | 3886 skip_redraw = FALSE; |
29966
5dfd4bd66ad8
patch 9.0.0321: cannot use the message popup window directly
Bram Moolenaar <Bram@vim.org>
parents:
29964
diff
changeset
|
3887 |
5dfd4bd66ad8
patch 9.0.0321: cannot use the message popup window directly
Bram Moolenaar <Bram@vim.org>
parents:
29964
diff
changeset
|
3888 in_echowindow = save_in_echowindow; |
7 | 3889 } |
3890 | |
3891 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3892 compute_cmdrow(void) |
7 | 3893 { |
30222
b871016ea7c1
patch 9.0.0447: using :echowin while at the hit-enter prompt causes problems
Bram Moolenaar <Bram@vim.org>
parents:
30005
diff
changeset
|
3894 // ignore "msg_scrolled" in update_screen(), it will be reset soon. |
b871016ea7c1
patch 9.0.0447: using :echowin while at the hit-enter prompt causes problems
Bram Moolenaar <Bram@vim.org>
parents:
30005
diff
changeset
|
3895 if (exmode_active || (msg_scrolled != 0 && !updating_screen)) |
7 | 3896 cmdline_row = Rows - 1; |
3897 else | |
3898 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
|
3899 + lastwin->w_status_height; |
7 | 3900 } |
3901 | |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
3902 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3903 cursorcmd(void) |
7 | 3904 { |
3905 if (cmd_silent) | |
3906 return; | |
3907 | |
3908 #ifdef FEAT_RIGHTLEFT | |
3909 if (cmdmsg_rl) | |
3910 { | |
3911 msg_row = cmdline_row + (ccline.cmdspos / (int)(Columns - 1)); | |
3912 msg_col = (int)Columns - (ccline.cmdspos % (int)(Columns - 1)) - 1; | |
3913 if (msg_row <= 0) | |
3914 msg_row = Rows - 1; | |
3915 } | |
3916 else | |
3917 #endif | |
3918 { | |
3919 msg_row = cmdline_row + (ccline.cmdspos / (int)Columns); | |
3920 msg_col = ccline.cmdspos % (int)Columns; | |
3921 if (msg_row >= Rows) | |
3922 msg_row = Rows - 1; | |
3923 } | |
3924 | |
3925 windgoto(msg_row, msg_col); | |
3926 #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
|
3927 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
|
3928 redrawcmd_preedit(); |
7 | 3929 #endif |
3930 #ifdef MCH_CURSOR_SHAPE | |
3931 mch_update_cursor(); | |
3932 #endif | |
3933 } | |
3934 | |
3935 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3936 gotocmdline(int clr) |
7 | 3937 { |
3938 msg_start(); | |
3939 #ifdef FEAT_RIGHTLEFT | |
3940 if (cmdmsg_rl) | |
3941 msg_col = Columns - 1; | |
3942 else | |
3943 #endif | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3944 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
|
3945 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
|
3946 msg_clr_eos(); // will reset clear_cmdline |
7 | 3947 windgoto(cmdline_row, 0); |
3948 } | |
3949 | |
3950 /* | |
3951 * Check the word in front of the cursor for an abbreviation. | |
3952 * Called when the non-id character "c" has been entered. | |
3953 * When an abbreviation is recognized it is removed from the text with | |
3954 * backspaces and the replacement string is inserted, followed by "c". | |
3955 */ | |
3956 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
3957 ccheck_abbr(int c) |
7 | 3958 { |
13933
bea665293ea0
patch 8.0.1837: one character cmdline abbreviation not triggered after '<,'>
Christian Brabandt <cb@256bit.org>
parents:
13831
diff
changeset
|
3959 int spos = 0; |
bea665293ea0
patch 8.0.1837: one character cmdline abbreviation not triggered after '<,'>
Christian Brabandt <cb@256bit.org>
parents:
13831
diff
changeset
|
3960 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3961 if (p_paste || no_abbr) // no abbreviations or in paste mode |
7 | 3962 return FALSE; |
3963 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3964 // 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
|
3965 // 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
|
3966 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
|
3967 spos++; |
bea665293ea0
patch 8.0.1837: one character cmdline abbreviation not triggered after '<,'>
Christian Brabandt <cb@256bit.org>
parents:
13831
diff
changeset
|
3968 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
|
3969 && ccline.cmdbuff[spos] == '\'' |
bea665293ea0
patch 8.0.1837: one character cmdline abbreviation not triggered after '<,'>
Christian Brabandt <cb@256bit.org>
parents:
13831
diff
changeset
|
3970 && 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
|
3971 && 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
|
3972 spos += 5; |
bea665293ea0
patch 8.0.1837: one character cmdline abbreviation not triggered after '<,'>
Christian Brabandt <cb@256bit.org>
parents:
13831
diff
changeset
|
3973 else |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
3974 // 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
|
3975 spos = 0; |
bea665293ea0
patch 8.0.1837: one character cmdline abbreviation not triggered after '<,'>
Christian Brabandt <cb@256bit.org>
parents:
13831
diff
changeset
|
3976 |
bea665293ea0
patch 8.0.1837: one character cmdline abbreviation not triggered after '<,'>
Christian Brabandt <cb@256bit.org>
parents:
13831
diff
changeset
|
3977 return check_abbr(c, ccline.cmdbuff, ccline.cmdpos, spos); |
7 | 3978 } |
3979 | |
3980 /* | |
25994
e8873138ffbb
patch 8.2.3530: ":buf {a}" fails while ":edit {a}" works
Bram Moolenaar <Bram@vim.org>
parents:
25874
diff
changeset
|
3981 * Escape special characters in "fname", depending on "what": |
e8873138ffbb
patch 8.2.3530: ":buf {a}" fails while ":edit {a}" works
Bram Moolenaar <Bram@vim.org>
parents:
25874
diff
changeset
|
3982 * VSE_NONE: for when used as a file name argument after a Vim command. |
e8873138ffbb
patch 8.2.3530: ":buf {a}" fails while ":edit {a}" works
Bram Moolenaar <Bram@vim.org>
parents:
25874
diff
changeset
|
3983 * VSE_SHELL: for a shell command. |
e8873138ffbb
patch 8.2.3530: ":buf {a}" fails while ":edit {a}" works
Bram Moolenaar <Bram@vim.org>
parents:
25874
diff
changeset
|
3984 * VSE_BUFFER: for the ":buffer" command. |
1586 | 3985 * Returns the result in allocated memory. |
3986 */ | |
3987 char_u * | |
25994
e8873138ffbb
patch 8.2.3530: ":buf {a}" fails while ":edit {a}" works
Bram Moolenaar <Bram@vim.org>
parents:
25874
diff
changeset
|
3988 vim_strsave_fnameescape(char_u *fname, int what) |
1586 | 3989 { |
1685 | 3990 char_u *p; |
1586 | 3991 #ifdef BACKSLASH_IN_FILENAME |
3992 char_u buf[20]; | |
3993 int j = 0; | |
3994 | |
25994
e8873138ffbb
patch 8.2.3530: ":buf {a}" fails while ":edit {a}" works
Bram Moolenaar <Bram@vim.org>
parents:
25874
diff
changeset
|
3995 // Don't escape '[', '{' and '!' if they are in 'isfname' and for the |
e8873138ffbb
patch 8.2.3530: ":buf {a}" fails while ":edit {a}" works
Bram Moolenaar <Bram@vim.org>
parents:
25874
diff
changeset
|
3996 // ":buffer" command. |
e8873138ffbb
patch 8.2.3530: ":buf {a}" fails while ":edit {a}" works
Bram Moolenaar <Bram@vim.org>
parents:
25874
diff
changeset
|
3997 for (p = what == VSE_BUFFER ? BUFFER_ESC_CHARS : PATH_ESC_CHARS; |
e8873138ffbb
patch 8.2.3530: ":buf {a}" fails while ":edit {a}" works
Bram Moolenaar <Bram@vim.org>
parents:
25874
diff
changeset
|
3998 *p != NUL; ++p) |
5481 | 3999 if ((*p != '[' && *p != '{' && *p != '!') || !vim_isfilec(*p)) |
1586 | 4000 buf[j++] = *p; |
4001 buf[j] = NUL; | |
1700 | 4002 p = vim_strsave_escaped(fname, buf); |
1586 | 4003 #else |
25994
e8873138ffbb
patch 8.2.3530: ":buf {a}" fails while ":edit {a}" works
Bram Moolenaar <Bram@vim.org>
parents:
25874
diff
changeset
|
4004 p = vim_strsave_escaped(fname, what == VSE_SHELL ? SHELL_ESC_CHARS |
e8873138ffbb
patch 8.2.3530: ":buf {a}" fails while ":edit {a}" works
Bram Moolenaar <Bram@vim.org>
parents:
25874
diff
changeset
|
4005 : what == VSE_BUFFER ? BUFFER_ESC_CHARS : PATH_ESC_CHARS); |
e8873138ffbb
patch 8.2.3530: ":buf {a}" fails while ":edit {a}" works
Bram Moolenaar <Bram@vim.org>
parents:
25874
diff
changeset
|
4006 if (what == VSE_SHELL && csh_like_shell() && p != NULL) |
1685 | 4007 { |
4008 char_u *s; | |
4009 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4010 // 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
|
4011 // One is taken by Vim, one by the shell. |
1685 | 4012 s = vim_strsave_escaped(p, (char_u *)"!"); |
4013 vim_free(p); | |
4014 p = s; | |
4015 } | |
1700 | 4016 #endif |
4017 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4018 // '>' 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
|
4019 // ":write". "cd -" has a special meaning. |
2445
04dae202d316
Fixes for coverity warnings.
Bram Moolenaar <bram@vim.org>
parents:
2433
diff
changeset
|
4020 if (p != NULL && (*p == '>' || *p == '+' || (*p == '-' && p[1] == NUL))) |
1700 | 4021 escape_fname(&p); |
4022 | |
1685 | 4023 return p; |
1586 | 4024 } |
4025 | |
4026 /* | |
435 | 4027 * Put a backslash before the file name in "pp", which is in allocated memory. |
4028 */ | |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
4029 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4030 escape_fname(char_u **pp) |
435 | 4031 { |
4032 char_u *p; | |
4033 | |
16764
ef00b6bc186b
patch 8.1.1384: using "int" for alloc() often results in compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
16706
diff
changeset
|
4034 p = alloc(STRLEN(*pp) + 2); |
31565
7d40c8c10a12
patch 9.0.1115: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31414
diff
changeset
|
4035 if (p == NULL) |
7d40c8c10a12
patch 9.0.1115: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31414
diff
changeset
|
4036 return; |
7d40c8c10a12
patch 9.0.1115: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31414
diff
changeset
|
4037 |
7d40c8c10a12
patch 9.0.1115: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31414
diff
changeset
|
4038 p[0] = '\\'; |
7d40c8c10a12
patch 9.0.1115: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31414
diff
changeset
|
4039 STRCPY(p + 1, *pp); |
7d40c8c10a12
patch 9.0.1115: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31414
diff
changeset
|
4040 vim_free(*pp); |
7d40c8c10a12
patch 9.0.1115: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31414
diff
changeset
|
4041 *pp = p; |
435 | 4042 } |
4043 | |
4044 /* | |
7 | 4045 * For each file name in files[num_files]: |
4046 * If 'orig_pat' starts with "~/", replace the home directory with "~". | |
4047 */ | |
4048 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4049 tilde_replace( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4050 char_u *orig_pat, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4051 int num_files, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4052 char_u **files) |
7 | 4053 { |
4054 int i; | |
4055 char_u *p; | |
4056 | |
4057 if (orig_pat[0] == '~' && vim_ispathsep(orig_pat[1])) | |
4058 { | |
4059 for (i = 0; i < num_files; ++i) | |
4060 { | |
4061 p = home_replace_save(NULL, files[i]); | |
4062 if (p != NULL) | |
4063 { | |
4064 vim_free(files[i]); | |
4065 files[i] = p; | |
4066 } | |
4067 } | |
4068 } | |
4069 } | |
4070 | |
4071 /* | |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
4072 * Get a pointer to the current command line info. |
7 | 4073 */ |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
4074 cmdline_info_T * |
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
4075 get_cmdline_info(void) |
7 | 4076 { |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
4077 return &ccline; |
7 | 4078 } |
4079 | |
8645
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4080 /* |
29515
e988bbf50e09
patch 9.0.0099: scrollback can be wrong after redrawing the command line
Bram Moolenaar <Bram@vim.org>
parents:
29489
diff
changeset
|
4081 * Get pointer to the command line info to use. save_cmdline() may clear |
8645
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4082 * 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
|
4083 */ |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
4084 static cmdline_info_T * |
8645
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4085 get_ccline_ptr(void) |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4086 { |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28771
diff
changeset
|
4087 if ((State & MODE_CMDLINE) == 0) |
8645
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4088 return NULL; |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4089 if (ccline.cmdbuff != NULL) |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4090 return &ccline; |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4091 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
|
4092 return &prev_ccline; |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4093 return NULL; |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4094 } |
30645
101f08b49ed3
patch 9.0.0657: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
30329
diff
changeset
|
4095 |
29964
444dd4cc49d6
patch 9.0.0320: command line type of CmdlineChange differs from getcmdtype()
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
4096 /* |
444dd4cc49d6
patch 9.0.0320: command line type of CmdlineChange differs from getcmdtype()
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
4097 * Get the current command-line type. |
444dd4cc49d6
patch 9.0.0320: command line type of CmdlineChange differs from getcmdtype()
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
4098 * Returns ':' or '/' or '?' or '@' or '>' or '-' |
444dd4cc49d6
patch 9.0.0320: command line type of CmdlineChange differs from getcmdtype()
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
4099 * Only works when the command line is being edited. |
444dd4cc49d6
patch 9.0.0320: command line type of CmdlineChange differs from getcmdtype()
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
4100 * Returns NUL when something is wrong. |
444dd4cc49d6
patch 9.0.0320: command line type of CmdlineChange differs from getcmdtype()
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
4101 */ |
444dd4cc49d6
patch 9.0.0320: command line type of CmdlineChange differs from getcmdtype()
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
4102 static int |
444dd4cc49d6
patch 9.0.0320: command line type of CmdlineChange differs from getcmdtype()
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
4103 get_cmdline_type(void) |
444dd4cc49d6
patch 9.0.0320: command line type of CmdlineChange differs from getcmdtype()
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
4104 { |
444dd4cc49d6
patch 9.0.0320: command line type of CmdlineChange differs from getcmdtype()
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
4105 cmdline_info_T *p = get_ccline_ptr(); |
444dd4cc49d6
patch 9.0.0320: command line type of CmdlineChange differs from getcmdtype()
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
4106 |
444dd4cc49d6
patch 9.0.0320: command line type of CmdlineChange differs from getcmdtype()
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
4107 if (p == NULL) |
444dd4cc49d6
patch 9.0.0320: command line type of CmdlineChange differs from getcmdtype()
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
4108 return NUL; |
444dd4cc49d6
patch 9.0.0320: command line type of CmdlineChange differs from getcmdtype()
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
4109 if (p->cmdfirstc == NUL) |
444dd4cc49d6
patch 9.0.0320: command line type of CmdlineChange differs from getcmdtype()
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
4110 return |
444dd4cc49d6
patch 9.0.0320: command line type of CmdlineChange differs from getcmdtype()
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
4111 # ifdef FEAT_EVAL |
444dd4cc49d6
patch 9.0.0320: command line type of CmdlineChange differs from getcmdtype()
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
4112 (p->input_fn) ? '@' : |
444dd4cc49d6
patch 9.0.0320: command line type of CmdlineChange differs from getcmdtype()
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
4113 # endif |
444dd4cc49d6
patch 9.0.0320: command line type of CmdlineChange differs from getcmdtype()
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
4114 '-'; |
444dd4cc49d6
patch 9.0.0320: command line type of CmdlineChange differs from getcmdtype()
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
4115 return p->cmdfirstc; |
444dd4cc49d6
patch 9.0.0320: command line type of CmdlineChange differs from getcmdtype()
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
4116 } |
444dd4cc49d6
patch 9.0.0320: command line type of CmdlineChange differs from getcmdtype()
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
4117 |
8647
59866aabe737
commit https://github.com/vim/vim/commit/064154c3fedd6a46ca2f61463d7e5567bd22d9f1
Christian Brabandt <cb@256bit.org>
parents:
8645
diff
changeset
|
4118 #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
|
4119 /* |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4120 * 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
|
4121 * 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
|
4122 * Returns NULL when something is wrong. |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4123 */ |
17970
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4124 static char_u * |
8645
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4125 get_cmdline_str(void) |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4126 { |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
4127 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
|
4128 |
45d8aa272dbe
patch 8.1.0436: can get the text of inputsecret() with getcmdline()
Christian Brabandt <cb@256bit.org>
parents:
14842
diff
changeset
|
4129 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
|
4130 return NULL; |
45d8aa272dbe
patch 8.1.0436: can get the text of inputsecret() with getcmdline()
Christian Brabandt <cb@256bit.org>
parents:
14842
diff
changeset
|
4131 p = get_ccline_ptr(); |
8645
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4132 if (p == NULL) |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4133 return NULL; |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4134 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
|
4135 } |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4136 |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4137 /* |
28757
add09d468c0d
patch 8.2.4903: cannot get the current cmdline completion type and position
Bram Moolenaar <Bram@vim.org>
parents:
28749
diff
changeset
|
4138 * Get the current command-line completion type. |
add09d468c0d
patch 8.2.4903: cannot get the current cmdline completion type and position
Bram Moolenaar <Bram@vim.org>
parents:
28749
diff
changeset
|
4139 */ |
add09d468c0d
patch 8.2.4903: cannot get the current cmdline completion type and position
Bram Moolenaar <Bram@vim.org>
parents:
28749
diff
changeset
|
4140 static char_u * |
add09d468c0d
patch 8.2.4903: cannot get the current cmdline completion type and position
Bram Moolenaar <Bram@vim.org>
parents:
28749
diff
changeset
|
4141 get_cmdline_completion(void) |
add09d468c0d
patch 8.2.4903: cannot get the current cmdline completion type and position
Bram Moolenaar <Bram@vim.org>
parents:
28749
diff
changeset
|
4142 { |
add09d468c0d
patch 8.2.4903: cannot get the current cmdline completion type and position
Bram Moolenaar <Bram@vim.org>
parents:
28749
diff
changeset
|
4143 cmdline_info_T *p; |
add09d468c0d
patch 8.2.4903: cannot get the current cmdline completion type and position
Bram Moolenaar <Bram@vim.org>
parents:
28749
diff
changeset
|
4144 |
add09d468c0d
patch 8.2.4903: cannot get the current cmdline completion type and position
Bram Moolenaar <Bram@vim.org>
parents:
28749
diff
changeset
|
4145 if (cmdline_star > 0) |
add09d468c0d
patch 8.2.4903: cannot get the current cmdline completion type and position
Bram Moolenaar <Bram@vim.org>
parents:
28749
diff
changeset
|
4146 return NULL; |
add09d468c0d
patch 8.2.4903: cannot get the current cmdline completion type and position
Bram Moolenaar <Bram@vim.org>
parents:
28749
diff
changeset
|
4147 |
add09d468c0d
patch 8.2.4903: cannot get the current cmdline completion type and position
Bram Moolenaar <Bram@vim.org>
parents:
28749
diff
changeset
|
4148 p = get_ccline_ptr(); |
28771
cf9f5b5c8079
patch 8.2.4910: imperfect coding
Bram Moolenaar <Bram@vim.org>
parents:
28757
diff
changeset
|
4149 if (p != NULL && p->xpc != NULL) |
28757
add09d468c0d
patch 8.2.4903: cannot get the current cmdline completion type and position
Bram Moolenaar <Bram@vim.org>
parents:
28749
diff
changeset
|
4150 { |
add09d468c0d
patch 8.2.4903: cannot get the current cmdline completion type and position
Bram Moolenaar <Bram@vim.org>
parents:
28749
diff
changeset
|
4151 char_u *cmd_compl; |
add09d468c0d
patch 8.2.4903: cannot get the current cmdline completion type and position
Bram Moolenaar <Bram@vim.org>
parents:
28749
diff
changeset
|
4152 |
add09d468c0d
patch 8.2.4903: cannot get the current cmdline completion type and position
Bram Moolenaar <Bram@vim.org>
parents:
28749
diff
changeset
|
4153 set_expand_context(p->xpc); |
add09d468c0d
patch 8.2.4903: cannot get the current cmdline completion type and position
Bram Moolenaar <Bram@vim.org>
parents:
28749
diff
changeset
|
4154 |
add09d468c0d
patch 8.2.4903: cannot get the current cmdline completion type and position
Bram Moolenaar <Bram@vim.org>
parents:
28749
diff
changeset
|
4155 cmd_compl = cmdcomplete_type_to_str(p->xpc->xp_context); |
add09d468c0d
patch 8.2.4903: cannot get the current cmdline completion type and position
Bram Moolenaar <Bram@vim.org>
parents:
28749
diff
changeset
|
4156 if (cmd_compl != NULL) |
28771
cf9f5b5c8079
patch 8.2.4910: imperfect coding
Bram Moolenaar <Bram@vim.org>
parents:
28757
diff
changeset
|
4157 return vim_strsave(cmd_compl); |
28757
add09d468c0d
patch 8.2.4903: cannot get the current cmdline completion type and position
Bram Moolenaar <Bram@vim.org>
parents:
28749
diff
changeset
|
4158 } |
add09d468c0d
patch 8.2.4903: cannot get the current cmdline completion type and position
Bram Moolenaar <Bram@vim.org>
parents:
28749
diff
changeset
|
4159 |
add09d468c0d
patch 8.2.4903: cannot get the current cmdline completion type and position
Bram Moolenaar <Bram@vim.org>
parents:
28749
diff
changeset
|
4160 return NULL; |
add09d468c0d
patch 8.2.4903: cannot get the current cmdline completion type and position
Bram Moolenaar <Bram@vim.org>
parents:
28749
diff
changeset
|
4161 } |
add09d468c0d
patch 8.2.4903: cannot get the current cmdline completion type and position
Bram Moolenaar <Bram@vim.org>
parents:
28749
diff
changeset
|
4162 |
add09d468c0d
patch 8.2.4903: cannot get the current cmdline completion type and position
Bram Moolenaar <Bram@vim.org>
parents:
28749
diff
changeset
|
4163 /* |
add09d468c0d
patch 8.2.4903: cannot get the current cmdline completion type and position
Bram Moolenaar <Bram@vim.org>
parents:
28749
diff
changeset
|
4164 * "getcmdcompltype()" function |
add09d468c0d
patch 8.2.4903: cannot get the current cmdline completion type and position
Bram Moolenaar <Bram@vim.org>
parents:
28749
diff
changeset
|
4165 */ |
add09d468c0d
patch 8.2.4903: cannot get the current cmdline completion type and position
Bram Moolenaar <Bram@vim.org>
parents:
28749
diff
changeset
|
4166 void |
add09d468c0d
patch 8.2.4903: cannot get the current cmdline completion type and position
Bram Moolenaar <Bram@vim.org>
parents:
28749
diff
changeset
|
4167 f_getcmdcompltype(typval_T *argvars UNUSED, typval_T *rettv) |
add09d468c0d
patch 8.2.4903: cannot get the current cmdline completion type and position
Bram Moolenaar <Bram@vim.org>
parents:
28749
diff
changeset
|
4168 { |
add09d468c0d
patch 8.2.4903: cannot get the current cmdline completion type and position
Bram Moolenaar <Bram@vim.org>
parents:
28749
diff
changeset
|
4169 rettv->v_type = VAR_STRING; |
add09d468c0d
patch 8.2.4903: cannot get the current cmdline completion type and position
Bram Moolenaar <Bram@vim.org>
parents:
28749
diff
changeset
|
4170 rettv->vval.v_string = get_cmdline_completion(); |
add09d468c0d
patch 8.2.4903: cannot get the current cmdline completion type and position
Bram Moolenaar <Bram@vim.org>
parents:
28749
diff
changeset
|
4171 } |
add09d468c0d
patch 8.2.4903: cannot get the current cmdline completion type and position
Bram Moolenaar <Bram@vim.org>
parents:
28749
diff
changeset
|
4172 |
add09d468c0d
patch 8.2.4903: cannot get the current cmdline completion type and position
Bram Moolenaar <Bram@vim.org>
parents:
28749
diff
changeset
|
4173 /* |
17970
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4174 * "getcmdline()" function |
8645
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4175 */ |
17970
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4176 void |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4177 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
|
4178 { |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4179 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
|
4180 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
|
4181 } |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4182 |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4183 /* |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4184 * "getcmdpos()" function |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4185 */ |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4186 void |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4187 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
|
4188 { |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
4189 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
|
4190 |
29964
444dd4cc49d6
patch 9.0.0320: command line type of CmdlineChange differs from getcmdtype()
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
4191 rettv->vval.v_number = p != NULL ? p->cmdpos + 1 : 0; |
28757
add09d468c0d
patch 8.2.4903: cannot get the current cmdline completion type and position
Bram Moolenaar <Bram@vim.org>
parents:
28749
diff
changeset
|
4192 } |
add09d468c0d
patch 8.2.4903: cannot get the current cmdline completion type and position
Bram Moolenaar <Bram@vim.org>
parents:
28749
diff
changeset
|
4193 |
add09d468c0d
patch 8.2.4903: cannot get the current cmdline completion type and position
Bram Moolenaar <Bram@vim.org>
parents:
28749
diff
changeset
|
4194 /* |
add09d468c0d
patch 8.2.4903: cannot get the current cmdline completion type and position
Bram Moolenaar <Bram@vim.org>
parents:
28749
diff
changeset
|
4195 * "getcmdscreenpos()" function |
add09d468c0d
patch 8.2.4903: cannot get the current cmdline completion type and position
Bram Moolenaar <Bram@vim.org>
parents:
28749
diff
changeset
|
4196 */ |
add09d468c0d
patch 8.2.4903: cannot get the current cmdline completion type and position
Bram Moolenaar <Bram@vim.org>
parents:
28749
diff
changeset
|
4197 void |
add09d468c0d
patch 8.2.4903: cannot get the current cmdline completion type and position
Bram Moolenaar <Bram@vim.org>
parents:
28749
diff
changeset
|
4198 f_getcmdscreenpos(typval_T *argvars UNUSED, typval_T *rettv) |
add09d468c0d
patch 8.2.4903: cannot get the current cmdline completion type and position
Bram Moolenaar <Bram@vim.org>
parents:
28749
diff
changeset
|
4199 { |
29964
444dd4cc49d6
patch 9.0.0320: command line type of CmdlineChange differs from getcmdtype()
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
4200 cmdline_info_T *p = get_ccline_ptr(); |
444dd4cc49d6
patch 9.0.0320: command line type of CmdlineChange differs from getcmdtype()
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
4201 |
444dd4cc49d6
patch 9.0.0320: command line type of CmdlineChange differs from getcmdtype()
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
4202 rettv->vval.v_number = p != NULL ? p->cmdspos + 1 : 0; |
444dd4cc49d6
patch 9.0.0320: command line type of CmdlineChange differs from getcmdtype()
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
4203 } |
444dd4cc49d6
patch 9.0.0320: command line type of CmdlineChange differs from getcmdtype()
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
4204 |
444dd4cc49d6
patch 9.0.0320: command line type of CmdlineChange differs from getcmdtype()
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
4205 /* |
444dd4cc49d6
patch 9.0.0320: command line type of CmdlineChange differs from getcmdtype()
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
4206 * "getcmdtype()" function |
444dd4cc49d6
patch 9.0.0320: command line type of CmdlineChange differs from getcmdtype()
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
4207 */ |
444dd4cc49d6
patch 9.0.0320: command line type of CmdlineChange differs from getcmdtype()
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
4208 void |
444dd4cc49d6
patch 9.0.0320: command line type of CmdlineChange differs from getcmdtype()
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
4209 f_getcmdtype(typval_T *argvars UNUSED, typval_T *rettv) |
444dd4cc49d6
patch 9.0.0320: command line type of CmdlineChange differs from getcmdtype()
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
4210 { |
444dd4cc49d6
patch 9.0.0320: command line type of CmdlineChange differs from getcmdtype()
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
4211 rettv->v_type = VAR_STRING; |
444dd4cc49d6
patch 9.0.0320: command line type of CmdlineChange differs from getcmdtype()
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
4212 rettv->vval.v_string = alloc(2); |
444dd4cc49d6
patch 9.0.0320: command line type of CmdlineChange differs from getcmdtype()
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
4213 if (rettv->vval.v_string != NULL) |
444dd4cc49d6
patch 9.0.0320: command line type of CmdlineChange differs from getcmdtype()
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
4214 { |
444dd4cc49d6
patch 9.0.0320: command line type of CmdlineChange differs from getcmdtype()
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
4215 rettv->vval.v_string[0] = get_cmdline_type(); |
444dd4cc49d6
patch 9.0.0320: command line type of CmdlineChange differs from getcmdtype()
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
4216 rettv->vval.v_string[1] = NUL; |
444dd4cc49d6
patch 9.0.0320: command line type of CmdlineChange differs from getcmdtype()
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
4217 } |
28757
add09d468c0d
patch 8.2.4903: cannot get the current cmdline completion type and position
Bram Moolenaar <Bram@vim.org>
parents:
28749
diff
changeset
|
4218 } |
add09d468c0d
patch 8.2.4903: cannot get the current cmdline completion type and position
Bram Moolenaar <Bram@vim.org>
parents:
28749
diff
changeset
|
4219 |
29894
d8fc1effa724
patch 9.0.0285: it is not easy to change the command line from a plugin
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
4220 // Set the command line str to "str". |
d8fc1effa724
patch 9.0.0285: it is not easy to change the command line from a plugin
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
4221 // Returns 1 when failed, 0 when OK. |
29964
444dd4cc49d6
patch 9.0.0320: command line type of CmdlineChange differs from getcmdtype()
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
4222 static int |
29894
d8fc1effa724
patch 9.0.0285: it is not easy to change the command line from a plugin
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
4223 set_cmdline_str(char_u *str, int pos) |
d8fc1effa724
patch 9.0.0285: it is not easy to change the command line from a plugin
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
4224 { |
d8fc1effa724
patch 9.0.0285: it is not easy to change the command line from a plugin
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
4225 cmdline_info_T *p = get_ccline_ptr(); |
d8fc1effa724
patch 9.0.0285: it is not easy to change the command line from a plugin
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
4226 int len; |
d8fc1effa724
patch 9.0.0285: it is not easy to change the command line from a plugin
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
4227 |
d8fc1effa724
patch 9.0.0285: it is not easy to change the command line from a plugin
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
4228 if (p == NULL) |
d8fc1effa724
patch 9.0.0285: it is not easy to change the command line from a plugin
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
4229 return 1; |
d8fc1effa724
patch 9.0.0285: it is not easy to change the command line from a plugin
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
4230 |
d8fc1effa724
patch 9.0.0285: it is not easy to change the command line from a plugin
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
4231 len = (int)STRLEN(str); |
d8fc1effa724
patch 9.0.0285: it is not easy to change the command line from a plugin
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
4232 realloc_cmdbuff(len + 1); |
d8fc1effa724
patch 9.0.0285: it is not easy to change the command line from a plugin
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
4233 p->cmdlen = len; |
d8fc1effa724
patch 9.0.0285: it is not easy to change the command line from a plugin
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
4234 STRCPY(p->cmdbuff, str); |
d8fc1effa724
patch 9.0.0285: it is not easy to change the command line from a plugin
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
4235 |
d8fc1effa724
patch 9.0.0285: it is not easy to change the command line from a plugin
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
4236 p->cmdpos = pos < 0 || pos > p->cmdlen ? p->cmdlen : pos; |
d8fc1effa724
patch 9.0.0285: it is not easy to change the command line from a plugin
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
4237 new_cmdpos = p->cmdpos; |
d8fc1effa724
patch 9.0.0285: it is not easy to change the command line from a plugin
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
4238 |
d8fc1effa724
patch 9.0.0285: it is not easy to change the command line from a plugin
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
4239 redrawcmd(); |
d8fc1effa724
patch 9.0.0285: it is not easy to change the command line from a plugin
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
4240 |
d8fc1effa724
patch 9.0.0285: it is not easy to change the command line from a plugin
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
4241 // Trigger CmdlineChanged autocommands. |
29964
444dd4cc49d6
patch 9.0.0320: command line type of CmdlineChange differs from getcmdtype()
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
4242 trigger_cmd_autocmd(get_cmdline_type(), EVENT_CMDLINECHANGED); |
29894
d8fc1effa724
patch 9.0.0285: it is not easy to change the command line from a plugin
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
4243 |
d8fc1effa724
patch 9.0.0285: it is not easy to change the command line from a plugin
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
4244 return 0; |
d8fc1effa724
patch 9.0.0285: it is not easy to change the command line from a plugin
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
4245 } |
d8fc1effa724
patch 9.0.0285: it is not easy to change the command line from a plugin
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
4246 |
28757
add09d468c0d
patch 8.2.4903: cannot get the current cmdline completion type and position
Bram Moolenaar <Bram@vim.org>
parents:
28749
diff
changeset
|
4247 /* |
8645
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4248 * 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
|
4249 * 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
|
4250 * 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
|
4251 */ |
17970
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4252 static int |
8645
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4253 set_cmdline_pos( |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4254 int pos) |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4255 { |
17779
87a8760babec
patch 8.1.1886: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
4256 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
|
4257 |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4258 if (p == NULL) |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4259 return 1; |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4260 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4261 // 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
|
4262 // changed the command line. |
8645
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4263 if (pos < 0) |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4264 new_cmdpos = 0; |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4265 else |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4266 new_cmdpos = pos; |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4267 return 0; |
f4819f0fc5ad
commit https://github.com/vim/vim/commit/d293b2b9d43ee4b7b48ca6974202cbf319438975
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
4268 } |
17970
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4269 |
29894
d8fc1effa724
patch 9.0.0285: it is not easy to change the command line from a plugin
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
4270 // "setcmdline()" function |
d8fc1effa724
patch 9.0.0285: it is not easy to change the command line from a plugin
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
4271 void |
d8fc1effa724
patch 9.0.0285: it is not easy to change the command line from a plugin
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
4272 f_setcmdline(typval_T *argvars, typval_T *rettv) |
d8fc1effa724
patch 9.0.0285: it is not easy to change the command line from a plugin
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
4273 { |
d8fc1effa724
patch 9.0.0285: it is not easy to change the command line from a plugin
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
4274 int pos = -1; |
d8fc1effa724
patch 9.0.0285: it is not easy to change the command line from a plugin
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
4275 |
29922
b366b19d1a3e
patch 9.0.0299: error messages for setcmdline() could be better
Bram Moolenaar <Bram@vim.org>
parents:
29910
diff
changeset
|
4276 if (check_for_string_arg(argvars, 0) == FAIL |
b366b19d1a3e
patch 9.0.0299: error messages for setcmdline() could be better
Bram Moolenaar <Bram@vim.org>
parents:
29910
diff
changeset
|
4277 || check_for_opt_number_arg(argvars, 1) == FAIL) |
29894
d8fc1effa724
patch 9.0.0285: it is not easy to change the command line from a plugin
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
4278 return; |
d8fc1effa724
patch 9.0.0285: it is not easy to change the command line from a plugin
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
4279 |
d8fc1effa724
patch 9.0.0285: it is not easy to change the command line from a plugin
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
4280 if (argvars[1].v_type != VAR_UNKNOWN) |
d8fc1effa724
patch 9.0.0285: it is not easy to change the command line from a plugin
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
4281 { |
d8fc1effa724
patch 9.0.0285: it is not easy to change the command line from a plugin
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
4282 int error = FALSE; |
d8fc1effa724
patch 9.0.0285: it is not easy to change the command line from a plugin
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
4283 |
d8fc1effa724
patch 9.0.0285: it is not easy to change the command line from a plugin
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
4284 pos = (int)tv_get_number_chk(&argvars[1], &error) - 1; |
d8fc1effa724
patch 9.0.0285: it is not easy to change the command line from a plugin
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
4285 if (error) |
d8fc1effa724
patch 9.0.0285: it is not easy to change the command line from a plugin
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
4286 return; |
d8fc1effa724
patch 9.0.0285: it is not easy to change the command line from a plugin
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
4287 if (pos < 0) |
d8fc1effa724
patch 9.0.0285: it is not easy to change the command line from a plugin
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
4288 { |
d8fc1effa724
patch 9.0.0285: it is not easy to change the command line from a plugin
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
4289 emsg(_(e_argument_must_be_positive)); |
d8fc1effa724
patch 9.0.0285: it is not easy to change the command line from a plugin
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
4290 return; |
d8fc1effa724
patch 9.0.0285: it is not easy to change the command line from a plugin
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
4291 } |
d8fc1effa724
patch 9.0.0285: it is not easy to change the command line from a plugin
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
4292 } |
d8fc1effa724
patch 9.0.0285: it is not easy to change the command line from a plugin
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
4293 |
d8fc1effa724
patch 9.0.0285: it is not easy to change the command line from a plugin
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
4294 rettv->vval.v_number = set_cmdline_str(argvars[0].vval.v_string, pos); |
d8fc1effa724
patch 9.0.0285: it is not easy to change the command line from a plugin
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
4295 } |
d8fc1effa724
patch 9.0.0285: it is not easy to change the command line from a plugin
Bram Moolenaar <Bram@vim.org>
parents:
29881
diff
changeset
|
4296 |
17970
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4297 /* |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4298 * "setcmdpos()" function |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4299 */ |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4300 void |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4301 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
|
4302 { |
25384
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25376
diff
changeset
|
4303 int pos; |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25376
diff
changeset
|
4304 |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25376
diff
changeset
|
4305 if (in_vim9script() && check_for_number_arg(argvars, 0) == FAIL) |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25376
diff
changeset
|
4306 return; |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25376
diff
changeset
|
4307 |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25376
diff
changeset
|
4308 pos = (int)tv_get_number(&argvars[0]) - 1; |
17970
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4309 if (pos >= 0) |
684a15da9929
patch 8.1.1981: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17922
diff
changeset
|
4310 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
|
4311 } |
27032
18cafa092e8d
patch 8.2.4045: some global functions are only used in one file
Bram Moolenaar <Bram@vim.org>
parents:
26962
diff
changeset
|
4312 #endif |
18cafa092e8d
patch 8.2.4045: some global functions are only used in one file
Bram Moolenaar <Bram@vim.org>
parents:
26962
diff
changeset
|
4313 |
17652
9efb4dda9720
patch 8.1.1823: command line history code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17588
diff
changeset
|
4314 /* |
9efb4dda9720
patch 8.1.1823: command line history code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17588
diff
changeset
|
4315 * 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
|
4316 */ |
9efb4dda9720
patch 8.1.1823: command line history code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17588
diff
changeset
|
4317 int |
9efb4dda9720
patch 8.1.1823: command line history code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17588
diff
changeset
|
4318 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
|
4319 { |
9efb4dda9720
patch 8.1.1823: command line history code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17588
diff
changeset
|
4320 return ccline.cmdfirstc; |
9efb4dda9720
patch 8.1.1823: command line history code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17588
diff
changeset
|
4321 } |
9efb4dda9720
patch 8.1.1823: command line history code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17588
diff
changeset
|
4322 |
7 | 4323 /* |
4324 * Get indices "num1,num2" that specify a range within a list (not a range of | |
4325 * text lines in a buffer!) from a string. Used for ":history" and ":clist". | |
4326 * Returns OK if parsed successfully, otherwise FAIL. | |
4327 */ | |
4328 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
4329 get_list_range(char_u **str, int *num1, int *num2) |
7 | 4330 { |
4331 int len; | |
4332 int first = FALSE; | |
9389
32e34e574716
commit https://github.com/vim/vim/commit/22fcfad29276bd5f317faf516637dcd491b96a12
Christian Brabandt <cb@256bit.org>
parents:
9301
diff
changeset
|
4333 varnumber_T num; |
7 | 4334 |
4335 *str = skipwhite(*str); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4336 if (**str == '-' || vim_isdigit(**str)) // parse "from" part of range |
7 | 4337 { |
16706
77bcb5055fec
patch 8.1.1355: obvious mistakes are accepted as valid expressions
Bram Moolenaar <Bram@vim.org>
parents:
16606
diff
changeset
|
4338 vim_str2nr(*str, NULL, &len, 0, &num, NULL, 0, FALSE); |
7 | 4339 *str += len; |
4340 *num1 = (int)num; | |
4341 first = TRUE; | |
4342 } | |
4343 *str = skipwhite(*str); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4344 if (**str == ',') // parse "to" part of range |
7 | 4345 { |
4346 *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
|
4347 vim_str2nr(*str, NULL, &len, 0, &num, NULL, 0, FALSE); |
7 | 4348 if (len > 0) |
4349 { | |
4350 *num2 = (int)num; | |
4351 *str = skipwhite(*str + len); | |
4352 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4353 else if (!first) // no number given at all |
7 | 4354 return FAIL; |
4355 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4356 else if (first) // only one number given |
7 | 4357 *num2 = *num1; |
4358 return OK; | |
4359 } | |
4360 | |
4361 /* | |
18679
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
4362 * 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
|
4363 * 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
|
4364 */ |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
4365 char * |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
4366 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
|
4367 { |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
4368 int n; |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
4369 |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
4370 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
|
4371 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
|
4372 else |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
4373 { |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
4374 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
|
4375 if (vim_isprintc(n)) |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26861
diff
changeset
|
4376 return e_invalid_argument; |
18679
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
4377 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
|
4378 } |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
4379 return NULL; |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
4380 } |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
4381 |
fd95d4dbeb37
patch 8.1.2331: the option.c file is still very big
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
4382 /* |
7 | 4383 * Open a window on the current command line and history. Allow editing in |
4384 * the window. Returns when the window is closed. | |
4385 * Returns: | |
4386 * CR if the command is to be executed | |
4387 * Ctrl_C if it is to be abandoned | |
4388 * K_IGNORE if editing continues | |
4389 */ | |
4390 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
|
4391 open_cmdwin(void) |
7 | 4392 { |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
4393 bufref_T old_curbuf; |
7 | 4394 win_T *old_curwin = curwin; |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
4395 bufref_T bufref; |
7 | 4396 win_T *wp; |
4397 int i; | |
4398 linenr_T lnum; | |
4399 int histtype; | |
4400 garray_T winsizes; | |
4401 int save_restart_edit = restart_edit; | |
4402 int save_State = State; | |
4403 int save_exmode = exmode_active; | |
510 | 4404 #ifdef FEAT_RIGHTLEFT |
4405 int save_cmdmsg_rl = cmdmsg_rl; | |
4406 #endif | |
6145 | 4407 #ifdef FEAT_FOLDING |
4408 int save_KeyTyped; | |
4409 #endif | |
7 | 4410 |
29042
e150d0e4701f
patch 8.2.5043: can open a cmdline window from a substitute expression
Bram Moolenaar <Bram@vim.org>
parents:
29014
diff
changeset
|
4411 // Can't do this when text or buffer is locked. |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4412 // Can't do this recursively. Can't do it when typing a password. |
29044
55ce8628cd9b
patch 8.2.5044: command line test fails
Bram Moolenaar <Bram@vim.org>
parents:
29042
diff
changeset
|
4413 if (text_or_buf_locked() |
55ce8628cd9b
patch 8.2.5044: command line test fails
Bram Moolenaar <Bram@vim.org>
parents:
29042
diff
changeset
|
4414 || cmdwin_type != 0 |
7 | 4415 # if defined(FEAT_CRYPT) || defined(FEAT_EVAL) |
4416 || cmdline_star > 0 | |
4417 # endif | |
4418 ) | |
4419 { | |
4420 beep_flush(); | |
4421 return K_IGNORE; | |
4422 } | |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
4423 set_bufref(&old_curbuf, curbuf); |
7 | 4424 |
18043
5a0d5f8e1778
patch 8.1.2017: cannot execute commands after closing the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
17970
diff
changeset
|
4425 // Save current window sizes. |
7 | 4426 win_size_save(&winsizes); |
4427 | |
15569
43fa814a7977
patch 8.1.0792: bad display if opening cmdline window from Insert completion
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
4428 // 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
|
4429 // 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
|
4430 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
|
4431 |
18043
5a0d5f8e1778
patch 8.1.2017: cannot execute commands after closing the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
17970
diff
changeset
|
4432 // 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
|
4433 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
|
4434 cmdmod.cmod_flags |= CMOD_NOSWAPFILE; |
683 | 4435 |
18043
5a0d5f8e1778
patch 8.1.2017: cannot execute commands after closing the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
17970
diff
changeset
|
4436 // Create a window for the command-line buffer. |
7 | 4437 if (win_split((int)p_cwh, WSP_BOT) == FAIL) |
4438 { | |
4439 beep_flush(); | |
19685
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19475
diff
changeset
|
4440 ga_clear(&winsizes); |
7 | 4441 return K_IGNORE; |
4442 } | |
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
|
4443 // 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
|
4444 got_int = FALSE; |
7 | 4445 |
23744
fc031340f8f9
patch 8.2.2413: crash when using :all while using a cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
23505
diff
changeset
|
4446 // 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
|
4447 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
|
4448 |
18043
5a0d5f8e1778
patch 8.1.2017: cannot execute commands after closing the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
17970
diff
changeset
|
4449 // 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
|
4450 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
|
4451 { |
abebcc20af26
patch 8.2.0911: crash when opening a buffer for the cmdline window fails
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
4452 // 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
|
4453 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
|
4454 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
|
4455 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
|
4456 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
|
4457 } |
abebcc20af26
patch 8.2.0911: crash when opening a buffer for the cmdline window fails
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
4458 |
19713
8514e8b7e661
patch 8.2.0413: buffer menu does not handle special buffers properly
Bram Moolenaar <Bram@vim.org>
parents:
19685
diff
changeset
|
4459 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
|
4460 (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
|
4461 apply_autocmds(EVENT_BUFFILEPOST, NULL, NULL, FALSE, curbuf); |
28457
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28397
diff
changeset
|
4462 set_option_value_give_err((char_u *)"bt", |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28397
diff
changeset
|
4463 0L, (char_u *)"nofile", OPT_LOCAL); |
7 | 4464 curbuf->b_p_ma = TRUE; |
1865 | 4465 #ifdef FEAT_FOLDING |
4466 curwin->w_p_fen = FALSE; | |
4467 #endif | |
7 | 4468 # ifdef FEAT_RIGHTLEFT |
510 | 4469 curwin->w_p_rl = cmdmsg_rl; |
4470 cmdmsg_rl = FALSE; | |
7 | 4471 # endif |
2583 | 4472 RESET_BINDING(curwin); |
7 | 4473 |
18043
5a0d5f8e1778
patch 8.1.2017: cannot execute commands after closing the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
17970
diff
changeset
|
4474 // 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
|
4475 ++curbuf_lock; |
7 | 4476 |
18043
5a0d5f8e1778
patch 8.1.2017: cannot execute commands after closing the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
17970
diff
changeset
|
4477 // Showing the prompt may have set need_wait_return, reset it. |
510 | 4478 need_wait_return = FALSE; |
4479 | |
1831 | 4480 histtype = hist_char2type(cmdwin_type); |
7 | 4481 if (histtype == HIST_CMD || histtype == HIST_DEBUG) |
4482 { | |
4483 if (p_wc == TAB) | |
4484 { | |
29173
1ec1ba7e7728
patch 8.2.5106: default cmdwin mappings are re-mappable
Bram Moolenaar <Bram@vim.org>
parents:
29136
diff
changeset
|
4485 add_map((char_u *)"<buffer> <Tab> <C-X><C-V>", MODE_INSERT, TRUE); |
1ec1ba7e7728
patch 8.2.5106: default cmdwin mappings are re-mappable
Bram Moolenaar <Bram@vim.org>
parents:
29136
diff
changeset
|
4486 add_map((char_u *)"<buffer> <Tab> a<C-X><C-V>", MODE_NORMAL, TRUE); |
7 | 4487 } |
28457
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28397
diff
changeset
|
4488 set_option_value_give_err((char_u *)"ft", |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28397
diff
changeset
|
4489 0L, (char_u *)"vim", OPT_LOCAL); |
7 | 4490 } |
11589
39787def24bb
patch 8.0.0677: setting 'filetype' may switch buffers
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
4491 --curbuf_lock; |
7 | 4492 |
18043
5a0d5f8e1778
patch 8.1.2017: cannot execute commands after closing the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
17970
diff
changeset
|
4493 // 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
|
4494 // sets 'textwidth' to 78). |
10 | 4495 curbuf->b_p_tw = 0; |
4496 | |
18043
5a0d5f8e1778
patch 8.1.2017: cannot execute commands after closing the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
17970
diff
changeset
|
4497 // Fill the buffer with the history. |
7 | 4498 init_history(); |
17652
9efb4dda9720
patch 8.1.1823: command line history code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17588
diff
changeset
|
4499 if (get_hislen() > 0) |
7 | 4500 { |
17652
9efb4dda9720
patch 8.1.1823: command line history code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17588
diff
changeset
|
4501 i = *get_hisidx(histtype); |
7 | 4502 if (i >= 0) |
4503 { | |
4504 lnum = 0; | |
4505 do | |
4506 { | |
17652
9efb4dda9720
patch 8.1.1823: command line history code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17588
diff
changeset
|
4507 if (++i == get_hislen()) |
7 | 4508 i = 0; |
17652
9efb4dda9720
patch 8.1.1823: command line history code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17588
diff
changeset
|
4509 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
|
4510 ml_append(lnum++, get_histentry(histtype)[i].hisstr, |
7 | 4511 (colnr_T)0, FALSE); |
4512 } | |
17652
9efb4dda9720
patch 8.1.1823: command line history code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17588
diff
changeset
|
4513 while (i != *get_hisidx(histtype)); |
7 | 4514 } |
4515 } | |
4516 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4517 // 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
|
4518 // cursor there. |
7 | 4519 ml_replace(curbuf->b_ml.ml_line_count, ccline.cmdbuff, TRUE); |
4520 curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; | |
4521 curwin->w_cursor.col = ccline.cmdpos; | |
510 | 4522 changed_line_abv_curs(); |
4523 invalidate_botline(); | |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
4524 redraw_later(UPD_SOME_VALID); |
7 | 4525 |
18227
7d90fa3e5f8d
patch 8.1.2108: cannot close the cmdline window from CmdWinEnter
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
4526 // No Ex mode here! |
7 | 4527 exmode_active = 0; |
4528 | |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28771
diff
changeset
|
4529 State = MODE_NORMAL; |
7 | 4530 setmouse(); |
4531 | |
18227
7d90fa3e5f8d
patch 8.1.2108: cannot close the cmdline window from CmdWinEnter
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
4532 // 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
|
4533 cmdwin_result = 0; |
7d90fa3e5f8d
patch 8.1.2108: cannot close the cmdline window from CmdWinEnter
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
4534 |
18043
5a0d5f8e1778
patch 8.1.2017: cannot execute commands after closing the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
17970
diff
changeset
|
4535 // 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
|
4536 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
|
4537 if (restart_edit != 0) // autocmd with ":startinsert" |
929 | 4538 stuffcharReadbuff(K_NOP); |
7 | 4539 |
4540 i = RedrawingDisabled; | |
4541 RedrawingDisabled = 0; | |
4542 | |
4543 /* | |
4544 * Call the main loop until <CR> or CTRL-C is typed. | |
4545 */ | |
168 | 4546 main_loop(TRUE, FALSE); |
7 | 4547 |
4548 RedrawingDisabled = i; | |
4549 | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13256
diff
changeset
|
4550 # ifdef FEAT_FOLDING |
6145 | 4551 save_KeyTyped = KeyTyped; |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13256
diff
changeset
|
4552 # endif |
6145 | 4553 |
18043
5a0d5f8e1778
patch 8.1.2017: cannot execute commands after closing the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
17970
diff
changeset
|
4554 // 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
|
4555 trigger_cmd_autocmd(cmdwin_type, EVENT_CMDWINLEAVE); |
6145 | 4556 |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13256
diff
changeset
|
4557 # 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
|
4558 // Restore KeyTyped in case it is modified by autocommands |
6145 | 4559 KeyTyped = save_KeyTyped; |
7 | 4560 # endif |
4561 | |
4562 cmdwin_type = 0; | |
4563 exmode_active = save_exmode; | |
4564 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4565 // 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
|
4566 // this happens! |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
4567 if (!win_valid(old_curwin) || !bufref_valid(&old_curbuf)) |
7 | 4568 { |
4569 cmdwin_result = Ctrl_C; | |
26861
df2de1e63de0
patch 8.2.3959: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26804
diff
changeset
|
4570 emsg(_(e_active_window_or_buffer_deleted)); |
7 | 4571 } |
4572 else | |
4573 { | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13256
diff
changeset
|
4574 # if defined(FEAT_EVAL) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4575 // autocmds may abort script processing |
7 | 4576 if (aborting() && cmdwin_result != K_IGNORE) |
4577 cmdwin_result = Ctrl_C; | |
4578 # endif | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4579 // Set the new command line from the cmdline buffer. |
7 | 4580 vim_free(ccline.cmdbuff); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4581 if (cmdwin_result == K_XF1 || cmdwin_result == K_XF2) // :qa[!] typed |
7 | 4582 { |
510 | 4583 char *p = (cmdwin_result == K_XF2) ? "qa" : "qa!"; |
4584 | |
4585 if (histtype == HIST_CMD) | |
4586 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4587 // Execute the command directly. |
510 | 4588 ccline.cmdbuff = vim_strsave((char_u *)p); |
4589 cmdwin_result = CAR; | |
4590 } | |
4591 else | |
4592 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4593 // First need to cancel what we were doing. |
510 | 4594 ccline.cmdbuff = NULL; |
4595 stuffcharReadbuff(':'); | |
4596 stuffReadbuff((char_u *)p); | |
4597 stuffcharReadbuff(CAR); | |
4598 } | |
7 | 4599 } |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4600 else if (cmdwin_result == K_XF2) // :qa typed |
7 | 4601 { |
4602 ccline.cmdbuff = vim_strsave((char_u *)"qa"); | |
4603 cmdwin_result = CAR; | |
4604 } | |
2839 | 4605 else if (cmdwin_result == Ctrl_C) |
4606 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18717
diff
changeset
|
4607 // :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
|
4608 // and don't modify the cmd window. |
2839 | 4609 ccline.cmdbuff = NULL; |
4610 } | |
7 | 4611 else |
4612 ccline.cmdbuff = vim_strsave(ml_get_curline()); | |
4613 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
|
4614 { |
aa426eb9589d
patch 8.0.0706: crash when cancelling the cmdline window in Ex mode
Christian Brabandt <cb@256bit.org>
parents:
11619
diff
changeset
|
4615 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
|
4616 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
|
4617 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
|
4618 ccline.cmdpos = 0; |
7 | 4619 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
|
4620 } |
7 | 4621 else |
4622 { | |
4623 ccline.cmdlen = (int)STRLEN(ccline.cmdbuff); | |
4624 ccline.cmdbufflen = ccline.cmdlen + 1; | |
4625 ccline.cmdpos = curwin->w_cursor.col; | |
30329
8496a2c45962
patch 9.0.0500: when quitting cmdline window with CTRL-C it remains visible
Bram Moolenaar <Bram@vim.org>
parents:
30308
diff
changeset
|
4626 // If the cursor is on the last character, it probably should be |
8496a2c45962
patch 9.0.0500: when quitting cmdline window with CTRL-C it remains visible
Bram Moolenaar <Bram@vim.org>
parents:
30308
diff
changeset
|
4627 // after it. |
8496a2c45962
patch 9.0.0500: when quitting cmdline window with CTRL-C it remains visible
Bram Moolenaar <Bram@vim.org>
parents:
30308
diff
changeset
|
4628 if (ccline.cmdpos == ccline.cmdlen - 1 |
8496a2c45962
patch 9.0.0500: when quitting cmdline window with CTRL-C it remains visible
Bram Moolenaar <Bram@vim.org>
parents:
30308
diff
changeset
|
4629 || ccline.cmdpos > ccline.cmdlen) |
7 | 4630 ccline.cmdpos = ccline.cmdlen; |
4631 } | |
4632 | |
6876 | 4633 # 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
|
4634 // Avoid command-line window first character being concealed. |
6876 | 4635 curwin->w_p_cole = 0; |
4636 # endif | |
23746
7c730cf4fb82
patch 8.2.2414: using freed memory when closing the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
23744
diff
changeset
|
4637 // First go back to the original window. |
7 | 4638 wp = curwin; |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9389
diff
changeset
|
4639 set_bufref(&bufref, curbuf); |
30259
48db7f8f1b44
patch 9.0.0465: cursor moves when cmdwin is closed when 'splitscroll' is off
Bram Moolenaar <Bram@vim.org>
parents:
30222
diff
changeset
|
4640 |
30267
be97adfeac3a
patch 9.0.0469: cursor moves if cmdwin is closed when 'splitscroll' is off
Bram Moolenaar <Bram@vim.org>
parents:
30259
diff
changeset
|
4641 skip_win_fix_cursor = TRUE; |
7 | 4642 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
|
4643 |
7c730cf4fb82
patch 8.2.2414: using freed memory when closing the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
23744
diff
changeset
|
4644 // 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
|
4645 // 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
|
4646 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
|
4647 win_close(wp, TRUE); |
2099
c1f67ce5740a
updated for version 7.2.382
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4648 |
18043
5a0d5f8e1778
patch 8.1.2017: cannot execute commands after closing the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
17970
diff
changeset
|
4649 // 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
|
4650 // 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
|
4651 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
|
4652 close_buffer(NULL, bufref.br_buf, DOBUF_WIPE, FALSE, FALSE); |
7 | 4653 |
18043
5a0d5f8e1778
patch 8.1.2017: cannot execute commands after closing the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
17970
diff
changeset
|
4654 // Restore window sizes. |
7 | 4655 win_size_restore(&winsizes); |
30267
be97adfeac3a
patch 9.0.0469: cursor moves if cmdwin is closed when 'splitscroll' is off
Bram Moolenaar <Bram@vim.org>
parents:
30259
diff
changeset
|
4656 skip_win_fix_cursor = FALSE; |
30329
8496a2c45962
patch 9.0.0500: when quitting cmdline window with CTRL-C it remains visible
Bram Moolenaar <Bram@vim.org>
parents:
30308
diff
changeset
|
4657 |
8496a2c45962
patch 9.0.0500: when quitting cmdline window with CTRL-C it remains visible
Bram Moolenaar <Bram@vim.org>
parents:
30308
diff
changeset
|
4658 if (cmdwin_result == K_IGNORE) |
8496a2c45962
patch 9.0.0500: when quitting cmdline window with CTRL-C it remains visible
Bram Moolenaar <Bram@vim.org>
parents:
30308
diff
changeset
|
4659 { |
8496a2c45962
patch 9.0.0500: when quitting cmdline window with CTRL-C it remains visible
Bram Moolenaar <Bram@vim.org>
parents:
30308
diff
changeset
|
4660 // It can be confusing that the cmdwin still shows, redraw the |
8496a2c45962
patch 9.0.0500: when quitting cmdline window with CTRL-C it remains visible
Bram Moolenaar <Bram@vim.org>
parents:
30308
diff
changeset
|
4661 // screen. |
8496a2c45962
patch 9.0.0500: when quitting cmdline window with CTRL-C it remains visible
Bram Moolenaar <Bram@vim.org>
parents:
30308
diff
changeset
|
4662 update_screen(UPD_VALID); |
8496a2c45962
patch 9.0.0500: when quitting cmdline window with CTRL-C it remains visible
Bram Moolenaar <Bram@vim.org>
parents:
30308
diff
changeset
|
4663 set_cmdspos_cursor(); |
8496a2c45962
patch 9.0.0500: when quitting cmdline window with CTRL-C it remains visible
Bram Moolenaar <Bram@vim.org>
parents:
30308
diff
changeset
|
4664 redrawcmd(); |
8496a2c45962
patch 9.0.0500: when quitting cmdline window with CTRL-C it remains visible
Bram Moolenaar <Bram@vim.org>
parents:
30308
diff
changeset
|
4665 } |
7 | 4666 } |
4667 | |
4668 ga_clear(&winsizes); | |
4669 restart_edit = save_restart_edit; | |
510 | 4670 # ifdef FEAT_RIGHTLEFT |
4671 cmdmsg_rl = save_cmdmsg_rl; | |
4672 # endif | |
7 | 4673 |
4674 State = save_State; | |
29483
2a327999c05c
patch 9.0.0083: ModeChanged event not triggered when leaving cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
29481
diff
changeset
|
4675 may_trigger_modechanged(); |
7 | 4676 setmouse(); |
4677 | |
4678 return cmdwin_result; | |
4679 } | |
26195
41b3718d84c3
patch 8.2.3629: command completion in cmdline window uses global commands
Bram Moolenaar <Bram@vim.org>
parents:
25994
diff
changeset
|
4680 |
41b3718d84c3
patch 8.2.3629: command completion in cmdline window uses global commands
Bram Moolenaar <Bram@vim.org>
parents:
25994
diff
changeset
|
4681 /* |
41b3718d84c3
patch 8.2.3629: command completion in cmdline window uses global commands
Bram Moolenaar <Bram@vim.org>
parents:
25994
diff
changeset
|
4682 * Return TRUE if in the cmdwin, not editing the command line. |
41b3718d84c3
patch 8.2.3629: command completion in cmdline window uses global commands
Bram Moolenaar <Bram@vim.org>
parents:
25994
diff
changeset
|
4683 */ |
41b3718d84c3
patch 8.2.3629: command completion in cmdline window uses global commands
Bram Moolenaar <Bram@vim.org>
parents:
25994
diff
changeset
|
4684 int |
41b3718d84c3
patch 8.2.3629: command completion in cmdline window uses global commands
Bram Moolenaar <Bram@vim.org>
parents:
25994
diff
changeset
|
4685 is_in_cmdwin(void) |
41b3718d84c3
patch 8.2.3629: command completion in cmdline window uses global commands
Bram Moolenaar <Bram@vim.org>
parents:
25994
diff
changeset
|
4686 { |
41b3718d84c3
patch 8.2.3629: command completion in cmdline window uses global commands
Bram Moolenaar <Bram@vim.org>
parents:
25994
diff
changeset
|
4687 return cmdwin_type != 0 && get_cmdline_type() == NUL; |
41b3718d84c3
patch 8.2.3629: command completion in cmdline window uses global commands
Bram Moolenaar <Bram@vim.org>
parents:
25994
diff
changeset
|
4688 } |
7 | 4689 |
4690 /* | |
4691 * Used for commands that either take a simple command string argument, or: | |
4692 * cmd << endmarker | |
4693 * {script} | |
4694 * endmarker | |
4695 * Returns a pointer to allocated memory with {script} or NULL. | |
4696 */ | |
4697 char_u * | |
20045
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
4698 script_get(exarg_T *eap UNUSED, char_u *cmd UNUSED) |
7 | 4699 { |
20045
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
4700 #ifdef FEAT_EVAL |
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
4701 list_T *l; |
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
4702 listitem_T *li; |
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
4703 char_u *s; |
7 | 4704 garray_T ga; |
4705 | |
4706 if (cmd[0] != '<' || cmd[1] != '<' || eap->getline == NULL) | |
4707 return NULL; | |
20045
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
4708 cmd += 2; |
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
4709 |
28560
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28457
diff
changeset
|
4710 l = heredoc_get(eap, cmd, TRUE, FALSE); |
20045
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
4711 if (l == NULL) |
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
4712 return NULL; |
7 | 4713 |
4714 ga_init2(&ga, 1, 0x400); | |
4715 | |
20045
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
4716 FOR_ALL_LIST_ITEMS(l, li) |
7 | 4717 { |
20045
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
4718 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
|
4719 ga_concat(&ga, s); |
7 | 4720 ga_append(&ga, '\n'); |
4721 } | |
21 | 4722 ga_append(&ga, NUL); |
7 | 4723 |
20045
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
4724 list_free(l); |
7 | 4725 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
|
4726 #else |
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
4727 return NULL; |
04ef2ccf2519
patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
4728 #endif |
7 | 4729 } |
17922
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4730 |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4731 #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
|
4732 /* |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4733 * 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
|
4734 * 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
|
4735 * 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
|
4736 * 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
|
4737 */ |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4738 void |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4739 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
|
4740 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
|
4741 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
|
4742 int inputdialog, |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4743 int secret) |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4744 { |
25384
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25376
diff
changeset
|
4745 char_u *prompt; |
17922
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4746 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
|
4747 int c; |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4748 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
|
4749 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
|
4750 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
|
4751 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
|
4752 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
|
4753 |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4754 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
|
4755 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
|
4756 if (input_busy) |
8d9229c4781a
patch 8.2.0662: cannot use input() in a channel callback
Bram Moolenaar <Bram@vim.org>
parents:
20164
diff
changeset
|
4757 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
|
4758 |
25384
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25376
diff
changeset
|
4759 if (in_vim9script() |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25376
diff
changeset
|
4760 && (check_for_string_arg(argvars, 0) == FAIL |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25376
diff
changeset
|
4761 || check_for_opt_string_arg(argvars, 1) == FAIL |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25376
diff
changeset
|
4762 || (argvars[1].v_type != VAR_UNKNOWN |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25376
diff
changeset
|
4763 && check_for_opt_string_arg(argvars, 2) == FAIL))) |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25376
diff
changeset
|
4764 return; |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25376
diff
changeset
|
4765 |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25376
diff
changeset
|
4766 prompt = tv_get_string_chk(&argvars[0]); |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25376
diff
changeset
|
4767 |
17922
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4768 #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
|
4769 // 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
|
4770 // 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
|
4771 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
|
4772 return; |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4773 #endif |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4774 |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4775 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
|
4776 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
|
4777 { |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4778 // 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
|
4779 // 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
|
4780 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
|
4781 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
|
4782 p = prompt; |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4783 else |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4784 { |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4785 ++p; |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4786 c = *p; |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4787 *p = NUL; |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4788 msg_start(); |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4789 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
|
4790 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
|
4791 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
|
4792 msg_starthere(); |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4793 *p = c; |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4794 } |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4795 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
|
4796 |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4797 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
|
4798 { |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4799 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
|
4800 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
|
4801 stuffReadbuffSpec(defstr); |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4802 |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4803 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
|
4804 { |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4805 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
|
4806 int xp_namelen; |
27887
7a60eaa9cb26
patch 8.2.4469: Coverity warns for uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
27744
diff
changeset
|
4807 long argt = 0; |
17922
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4808 |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4809 // 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
|
4810 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
|
4811 |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4812 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
|
4813 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
|
4814 return; |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4815 |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4816 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
|
4817 |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4818 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
|
4819 &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
|
4820 return; |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4821 } |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4822 } |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4823 |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4824 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
|
4825 { |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4826 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
|
4827 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
|
4828 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
|
4829 |
8d9229c4781a
patch 8.2.0662: cannot use input() in a channel callback
Bram Moolenaar <Bram@vim.org>
parents:
20164
diff
changeset
|
4830 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
|
4831 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
|
4832 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
|
4833 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
|
4834 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
|
4835 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
|
4836 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
|
4837 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
|
4838 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
|
4839 } |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4840 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
|
4841 && 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
|
4842 && 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
|
4843 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
|
4844 &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
|
4845 |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4846 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
|
4847 |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4848 // 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
|
4849 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
|
4850 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
|
4851 } |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4852 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
|
4853 } |
4d63d47d87ef
patch 8.1.1957: more code can be moved to evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
17809
diff
changeset
|
4854 #endif |