ext_cmdline: interact with cmdline window

This commit is contained in:
Björn Linse 2017-08-27 09:57:30 +02:00
parent bed0a3a842
commit 91d8e26bc7
3 changed files with 115 additions and 9 deletions

View File

@ -2810,7 +2810,10 @@ void cmdline_screen_cleared(void)
CmdlineInfo *prev_ccline = ccline.prev_ccline;
while (prev_level > 0 && prev_ccline) {
if (prev_ccline->level == prev_level) {
ui_ext_cmdline_show(prev_ccline);
// don't redraw a cmdline already shown in the cmdline window
if (prev_level != cmdwin_level) {
ui_ext_cmdline_show(prev_ccline);
}
prev_level--;
}
prev_ccline = prev_ccline->prev_ccline;
@ -5781,6 +5784,7 @@ static int ex_window(void)
return K_IGNORE;
}
cmdwin_type = get_cmdline_type();
cmdwin_level = ccline.level;
// Create empty command-line buffer.
buf_open_scratch(0, "[Command Line]");
@ -5833,6 +5837,9 @@ static int ex_window(void)
curwin->w_cursor.col = ccline.cmdpos;
changed_line_abv_curs();
invalidate_botline();
if (ui_is_external(kUICmdline)) {
ui_call_cmdline_hide(ccline.level);
}
redraw_later(SOME_VALID);
// Save the command line info, can be used recursively.
@ -5875,6 +5882,7 @@ static int ex_window(void)
// Restore the command line info.
restore_cmdline(&save_ccline);
cmdwin_type = 0;
cmdwin_level = 0;
exmode_active = save_exmode;

View File

@ -981,9 +981,10 @@ EXTERN int fill_diff INIT(= '-');
EXTERN int km_stopsel INIT(= FALSE);
EXTERN int km_startsel INIT(= FALSE);
EXTERN int cedit_key INIT(= -1); /* key value of 'cedit' option */
EXTERN int cmdwin_type INIT(= 0); /* type of cmdline window or 0 */
EXTERN int cmdwin_result INIT(= 0); /* result of cmdline window or 0 */
EXTERN int cedit_key INIT(= -1); ///< key value of 'cedit' option
EXTERN int cmdwin_type INIT(= 0); ///< type of cmdline window or 0
EXTERN int cmdwin_result INIT(= 0); ///< result of cmdline window or 0
EXTERN int cmdwin_level INIT(= 0); ///< cmdline level of cmdline window or 0
EXTERN char_u no_lines_msg[] INIT(= N_("--No lines in buffer--"));

View File

@ -232,7 +232,7 @@ describe('external cmdline', function()
indent = 0,
pos = 3,
prompt = "",
}}
}}
screen:expect([[
^ |
~ |
@ -345,19 +345,116 @@ describe('external cmdline', function()
end)
end)
pending("works with cmdline window", function()
feed(':sign<c-f>')
it("works with cmdline window", function()
feed(':make')
screen:expect([[
^ |
~ |
~ |
~ |
|
]], nil, nil, function()
eq({{
content = { { {}, "make" } },
firstc = ":",
indent = 0,
pos = 4,
prompt = ""
}}, cmdline)
end)
feed('<c-f>')
screen:expect([[
|
[No Name] |
:sign^ |
:make^ |
[Command Line] |
|
]], nil, nil, function()
eq({}, cmdline)
end)
feed(":blargh")
-- nested cmdline
feed(':yank')
screen:expect([[
|
[No Name] |
:make^ |
[Command Line] |
|
]], nil, nil, function()
eq({nil, {
content = { { {}, "yank" } },
firstc = ":",
indent = 0,
pos = 4,
prompt = ""
}}, cmdline)
end)
cmdline = {}
command("redraw!")
screen:expect([[
|
[No Name] |
:make |
[Command Line] |
^ |
]], nil, nil, function()
eq({nil, {
content = { { {}, "yank" } },
firstc = ":",
indent = 0,
pos = 4,
prompt = ""
}}, cmdline)
end)
feed("<c-c>")
screen:expect([[
|
[No Name] |
:make^ |
[Command Line] |
|
]], nil, nil, function()
eq({}, cmdline)
end)
feed("<c-c>")
screen:expect([[
|
[No Name] |
:make^ |
[Command Line] |
|
]], nil, nil, function()
eq({{
content = { { {}, "make" } },
firstc = ":",
indent = 0,
pos = 4,
prompt = ""
}}, cmdline)
end)
cmdline = {}
command("redraw!")
screen:expect([[
|
~ |
~ |
~ |
^ |
]], nil, nil, function()
eq({{
content = { { {}, "make" } },
firstc = ":",
indent = 0,
pos = 4,
prompt = ""
}}, cmdline)
end)
end)
it('works with highlighted cmdline', function()