diff options
author | glacambre <code@lacamb.re> | 2021-10-03 16:19:25 +0200 |
---|---|---|
committer | glacambre <code@lacamb.re> | 2022-01-24 13:59:16 +0100 |
commit | a4069a3eed65f14b1149c6cda8638dcb49ab5027 (patch) | |
tree | dc0f0c1af6f8a9070340745c8f939b8a7d875d82 /src/nvim/message.c | |
parent | 326e74571be43823ded9fa805a3173bdabda6bec (diff) | |
download | rneovim-a4069a3eed65f14b1149c6cda8638dcb49ab5027.tar.gz rneovim-a4069a3eed65f14b1149c6cda8638dcb49ab5027.tar.bz2 rneovim-a4069a3eed65f14b1149c6cda8638dcb49ab5027.zip |
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).
Diffstat (limited to 'src/nvim/message.c')
-rw-r--r-- | src/nvim/message.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/nvim/message.c b/src/nvim/message.c index befca8c76b..76aa863bde 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -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)) { |