mirror of
https://github.com/neovim/neovim.git
synced 2025-09-16 08:18:17 +00:00
eval,ex_getln: Add support for coloring input() prompts
This commit is contained in:
@@ -11010,6 +11010,7 @@ void get_user_input(const typval_T *const argvars,
|
||||
const char *defstr = "";
|
||||
const char *cancelreturn = NULL;
|
||||
const char *xp_name = NULL;
|
||||
Callback input_callback = { .type = kCallbackNone };
|
||||
char prompt_buf[NUMBUFLEN];
|
||||
char defstr_buf[NUMBUFLEN];
|
||||
char cancelreturn_buf[NUMBUFLEN];
|
||||
@@ -11019,7 +11020,7 @@ void get_user_input(const typval_T *const argvars,
|
||||
emsgf(_("E5050: {opts} must be the only argument"));
|
||||
return;
|
||||
}
|
||||
const dict_T *const dict = argvars[0].vval.v_dict;
|
||||
dict_T *const dict = argvars[0].vval.v_dict;
|
||||
prompt = tv_dict_get_string_buf_chk(dict, S_LEN("prompt"), prompt_buf, "");
|
||||
if (prompt == NULL) {
|
||||
return;
|
||||
@@ -11045,6 +11046,9 @@ void get_user_input(const typval_T *const argvars,
|
||||
if (xp_name == def) { // default to NULL
|
||||
xp_name = NULL;
|
||||
}
|
||||
if (!tv_dict_get_callback(dict, S_LEN("highlight"), &input_callback)) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
prompt = tv_get_string_buf_chk(&argvars[0], prompt_buf);
|
||||
if (prompt == NULL) {
|
||||
@@ -11103,12 +11107,16 @@ void get_user_input(const typval_T *const argvars,
|
||||
|
||||
stuffReadbuffSpec(defstr);
|
||||
|
||||
int save_ex_normal_busy = ex_normal_busy;
|
||||
const int save_ex_normal_busy = ex_normal_busy;
|
||||
const Callback save_getln_input_callback = getln_input_callback;
|
||||
ex_normal_busy = 0;
|
||||
getln_input_callback = input_callback;
|
||||
rettv->vval.v_string =
|
||||
getcmdline_prompt(inputsecret_flag ? NUL : '@', (char_u *)p, echo_attr,
|
||||
xp_type, (char_u *)xp_arg);
|
||||
getln_input_callback = save_getln_input_callback;
|
||||
ex_normal_busy = save_ex_normal_busy;
|
||||
callback_free(&input_callback);
|
||||
|
||||
if (rettv->vval.v_string == NULL && cancelreturn != NULL) {
|
||||
rettv->vval.v_string = (char_u *)xstrdup(cancelreturn);
|
||||
|
Reference in New Issue
Block a user