home/src/shell_manager.hh
Maxime Coste 942fc224af Specify if ShellManager should read output or not using a flag
Some program (xclip), will fork a daemon keeping stdout/stderr open,
so waiting for them to be closed make kakoune hang. Commands discarding
stdout can then just not wait on it.
2015-06-08 13:45:20 +01:00

48 lines
1.1 KiB
C++

#ifndef shell_manager_hh_INCLUDED
#define shell_manager_hh_INCLUDED
#include "array_view.hh"
#include "regex.hh"
#include "utils.hh"
#include "env_vars.hh"
#include "flags.hh"
namespace Kakoune
{
class Context;
class String;
class StringView;
using EnvVarRetriever = std::function<String (StringView name, const Context&)>;
class ShellManager : public Singleton<ShellManager>
{
public:
ShellManager();
enum class Flags
{
None = 0,
ReadOutput = 1
};
std::pair<String, int> eval(StringView cmdline, const Context& context,
StringView input = {},
Flags flags = Flags::ReadOutput,
ConstArrayView<String> params = {},
const EnvVarMap& env_vars = EnvVarMap{});
void register_env_var(StringView regex, EnvVarRetriever retriever);
String get_val(StringView name, const Context& context) const;
private:
Vector<std::pair<Regex, EnvVarRetriever>> m_env_vars;
};
template<> struct WithBitOps<ShellManager::Flags> : std::true_type {};
}
#endif // shell_manager_hh_INCLUDED