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