mirror of
https://github.com/neovim/neovim.git
synced 2025-10-05 01:16:31 +00:00
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:
@@ -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)
|
||||
{
|
||||
|
Reference in New Issue
Block a user