vim-patch:8.1.0027: difficult to make a plugin that feeds a line to a job

Problem:    Difficult to make a plugin that feeds a line to a job.
Solution:   Add the nitial code for the "prompt" buftype.
f273245f64
This commit is contained in:
erw7
2019-05-20 11:57:45 +09:00
parent 58ec72f9fd
commit 4813ad48cd
13 changed files with 378 additions and 46 deletions

View File

@@ -6076,6 +6076,51 @@ static void f_printf(typval_T *argvars, typval_T *rettv, FunPtr fptr)
}
}
// "prompt_setcallback({buffer}, {callback})" function
static void f_prompt_setcallback(typval_T *argvars,
typval_T *rettv, FunPtr fptr)
{
buf_T *buf;
Callback prompt_callback = { .type = kCallbackNone };
if (check_secure()) {
return;
}
buf = tv_get_buf(&argvars[0], false);
if (buf == NULL) {
return;
}
if (argvars[1].v_type != VAR_STRING || *argvars[1].vval.v_string != NUL) {
if (!callback_from_typval(&prompt_callback, &argvars[1])) {
return;
}
}
callback_free(&buf->b_prompt_callback);
buf->b_prompt_callback = prompt_callback;
}
// "prompt_setprompt({buffer}, {text})" function
static void f_prompt_setprompt(typval_T *argvars,
typval_T *rettv, FunPtr fptr)
{
buf_T *buf;
const char_u *text;
if (check_secure()) {
return;
}
buf = tv_get_buf(&argvars[0], false);
if (buf == NULL) {
return;
}
text = (const char_u *)tv_get_string(&argvars[1]);
xfree(buf->b_prompt_text);
buf->b_prompt_text = vim_strsave(text);
}
// "pum_getpos()" function
static void f_pum_getpos(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{