annotate src/ex_getln.c @ 18779:8f05b3cf8557 v8.1.2379

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