diff options
author | erw7 <erw7.github@gmail.com> | 2019-05-20 11:57:45 +0900 |
---|---|---|
committer | erw7 <erw7.github@gmail.com> | 2020-02-12 15:16:32 +0900 |
commit | 4813ad48cd12a03ca50c01ac1b20518bf4df57f2 (patch) | |
tree | f0c15d85ef763dc504ac8bace7a1f08bf366feb8 /src/nvim/eval/funcs.c | |
parent | 58ec72f9fdfd186e5154ce82be1da7c65b9c8ea0 (diff) | |
download | rneovim-4813ad48cd12a03ca50c01ac1b20518bf4df57f2.tar.gz rneovim-4813ad48cd12a03ca50c01ac1b20518bf4df57f2.tar.bz2 rneovim-4813ad48cd12a03ca50c01ac1b20518bf4df57f2.zip |
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.
https://github.com/vim/vim/commit/f273245f6433d5d43a5671306b520a3230c35787
Diffstat (limited to 'src/nvim/eval/funcs.c')
-rw-r--r-- | src/nvim/eval/funcs.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index 8232136783..a89d62fdfd 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -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) { |