ext_cmdline: Added cmdline prompt

This commit is contained in:
Dongdong Zhou 2017-02-23 09:53:12 +00:00 committed by Björn Linse
parent 439c39a2cf
commit 6e90bc7200
3 changed files with 30 additions and 12 deletions

View File

@ -462,6 +462,9 @@ states might be represented as separate modes.
The first character of the command, which could be : / ? etc. With The first character of the command, which could be : / ? etc. With
the firstc, you know wheither it's a command or a search. the firstc, you know wheither it's a command or a search.
["cmdline_prompt", prompt]
The prompt of the cmdline.
["cmdline", content, pos] ["cmdline", content, pos]
When cmdline_external is set to true, nvim will not draw the cmdline When cmdline_external is set to true, nvim will not draw the cmdline
on the grad, instead nvim will send ui events of the cmdline content on the grad, instead nvim will send ui events of the cmdline content

View File

@ -11149,15 +11149,19 @@ void get_user_input(const typval_T *const argvars,
// Only the part of the message after the last NL is considered as // Only the part of the message after the last NL is considered as
// prompt for the command line. // prompt for the command line.
const char *p = strrchr(prompt, '\n'); const char *p = strrchr(prompt, '\n');
if (p == NULL) { if (ui_is_external(kUICmdline)) {
p = prompt; p = prompt;
} else { } else {
p++; if (p == NULL) {
msg_start(); p = prompt;
msg_clr_eos(); } else {
msg_puts_attr_len(prompt, p - prompt, echo_attr); p++;
msg_didout = false; msg_start();
msg_starthere(); msg_clr_eos();
msg_puts_attr_len(prompt, p - prompt, echo_attr);
msg_didout = false;
msg_starthere();
}
} }
cmdline_row = msg_row; cmdline_row = msg_row;

View File

@ -3114,11 +3114,17 @@ static void redrawcmdprompt(void)
} }
} }
if (ccline.cmdprompt != NULL) { if (ccline.cmdprompt != NULL) {
msg_puts_attr((const char *)ccline.cmdprompt, ccline.cmdattr); if (cmdline_external) {
ccline.cmdindent = msg_col + (msg_row - cmdline_row) * Columns; Array args = ARRAY_DICT_INIT;
/* do the reverse of set_cmdspos() */ ADD(args, STRING_OBJ(cstr_to_string((char *)(ccline.cmdprompt))));
if (ccline.cmdfirstc != NUL) ui_event("cmdline_prompt", args);
--ccline.cmdindent; } else {
msg_puts_attr((const char *)ccline.cmdprompt, ccline.cmdattr);
ccline.cmdindent = msg_col + (msg_row - cmdline_row) * Columns;
/* do the reverse of set_cmdspos() */
if (ccline.cmdfirstc != NUL)
--ccline.cmdindent;
}
} else } else
for (i = ccline.cmdindent; i > 0; --i) for (i = ccline.cmdindent; i > 0; --i)
msg_putchar(' '); msg_putchar(' ');
@ -6036,3 +6042,8 @@ void cmdline_set_external(bool external)
{ {
cmdline_external = external; cmdline_external = external;
} }
bool cmdline_get_external(void)
{
return cmdline_external;
}