aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/doc/msgpack_rpc.txt3
-rw-r--r--src/nvim/eval.c18
-rw-r--r--src/nvim/ex_getln.c21
3 files changed, 30 insertions, 12 deletions
diff --git a/runtime/doc/msgpack_rpc.txt b/runtime/doc/msgpack_rpc.txt
index 4a82b3a1bd..b7c790bb64 100644
--- a/runtime/doc/msgpack_rpc.txt
+++ b/runtime/doc/msgpack_rpc.txt
@@ -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
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index aab777955c..72b97cbab9 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -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;
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 87bf46d4d0..a05331d13a 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -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;
+}