mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
ext_cmdline: Added cmdline prompt
This commit is contained in:
parent
439c39a2cf
commit
6e90bc7200
@ -462,6 +462,9 @@ states might be represented as separate modes.
|
||||
The first character of the command, which could be : / ? etc. With
|
||||
the firstc, you know wheither it's a command or a search.
|
||||
|
||||
["cmdline_prompt", prompt]
|
||||
The prompt of the cmdline.
|
||||
|
||||
["cmdline", content, pos]
|
||||
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
|
||||
|
@ -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
|
||||
// prompt for the command line.
|
||||
const char *p = strrchr(prompt, '\n');
|
||||
if (p == NULL) {
|
||||
if (ui_is_external(kUICmdline)) {
|
||||
p = prompt;
|
||||
} else {
|
||||
p++;
|
||||
msg_start();
|
||||
msg_clr_eos();
|
||||
msg_puts_attr_len(prompt, p - prompt, echo_attr);
|
||||
msg_didout = false;
|
||||
msg_starthere();
|
||||
if (p == NULL) {
|
||||
p = prompt;
|
||||
} else {
|
||||
p++;
|
||||
msg_start();
|
||||
msg_clr_eos();
|
||||
msg_puts_attr_len(prompt, p - prompt, echo_attr);
|
||||
msg_didout = false;
|
||||
msg_starthere();
|
||||
}
|
||||
}
|
||||
cmdline_row = msg_row;
|
||||
|
||||
|
@ -3114,11 +3114,17 @@ static void redrawcmdprompt(void)
|
||||
}
|
||||
}
|
||||
if (ccline.cmdprompt != NULL) {
|
||||
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;
|
||||
if (cmdline_external) {
|
||||
Array args = ARRAY_DICT_INIT;
|
||||
ADD(args, STRING_OBJ(cstr_to_string((char *)(ccline.cmdprompt))));
|
||||
ui_event("cmdline_prompt", args);
|
||||
} 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
|
||||
for (i = ccline.cmdindent; i > 0; --i)
|
||||
msg_putchar(' ');
|
||||
@ -6036,3 +6042,8 @@ void cmdline_set_external(bool external)
|
||||
{
|
||||
cmdline_external = external;
|
||||
}
|
||||
|
||||
bool cmdline_get_external(void)
|
||||
{
|
||||
return cmdline_external;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user