mirror of
https://github.com/neovim/neovim.git
synced 2025-09-16 16:28:17 +00:00
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:
@@ -2647,6 +2647,17 @@ static void msg_puts_printf(const char *str, const ptrdiff_t maxlen)
|
||||
char buf[7];
|
||||
char *p;
|
||||
|
||||
if (on_print.type != kCallbackNone) {
|
||||
typval_T argv[1];
|
||||
argv[0].v_type = VAR_STRING;
|
||||
argv[0].v_lock = VAR_UNLOCKED;
|
||||
argv[0].vval.v_string = (char_u *)str;
|
||||
typval_T rettv = TV_INITIAL_VALUE;
|
||||
callback_call(&on_print, 1, argv, &rettv);
|
||||
tv_clear(&rettv);
|
||||
return;
|
||||
}
|
||||
|
||||
while ((maxlen < 0 || s - str < maxlen) && *s != NUL) {
|
||||
int len = utf_ptr2len((const char_u *)s);
|
||||
if (!(silent_mode && p_verbose == 0)) {
|
||||
|
Reference in New Issue
Block a user