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