From 94f59fc9be03cf0ee3ac20f2715738f017439502 Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Thu, 5 Jun 2014 08:25:53 -0300 Subject: api: Implement vim_command_output function This function can be used by API clients to execute a command and capture the output. --- src/nvim/api/vim.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/nvim/api/vim.c') diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index c90e7039ce..9afefd6fa3 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -96,6 +96,19 @@ String vim_replace_termcodes(String str, Boolean from_part, Boolean do_lt, return cstr_as_string(ptr); } +String vim_command_output(String str, Error *err) +{ + do_cmdline_cmd((char_u *)"redir => v:command_output"); + vim_command(str, err); + do_cmdline_cmd((char_u *)"redir END"); + + if (err->set) { + return (String) STRING_INIT; + } + + return cstr_to_string((char *)get_vim_var_str(VV_COMMAND_OUTPUT)); +} + /// Evaluates the expression str using the vim internal expression /// evaluator (see |expression|). /// Dictionaries and lists are recursively expanded. -- cgit