feat(--headless): add on_print callback to stdioopen

This commit adds an on_print callback to stdioopen's dictionary
argument which lets the caller specify a function called each time
neovim will try to output something to stdout (e.g. on "echo" or
"echoerr" in --headless mode).
This commit is contained in:
glacambre
2021-10-03 16:19:25 +02:00
parent 326e74571b
commit a4069a3eed
5 changed files with 51 additions and 1 deletions

View File

@@ -10213,6 +10213,10 @@ static void f_stdioopen(typval_T *argvars, typval_T *rettv, FunPtr fptr)
if (!tv_dict_get_callback(opts, S_LEN("on_stdin"), &on_stdin.cb)) {
return;
}
if (!tv_dict_get_callback(opts, S_LEN("on_print"), &on_print)) {
return;
}
on_stdin.buffered = tv_dict_get_number(opts, "stdin_buffered");
if (on_stdin.buffered && on_stdin.cb.type == kCallbackNone) {
on_stdin.self = opts;