1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-12-21 02:21:32 +03:00
kakoune/src/shell_manager.hh

47 lines
1.2 KiB
C++
Raw Normal View History

#ifndef shell_manager_hh_INCLUDED
#define shell_manager_hh_INCLUDED
#include "array_view.hh"
#include "env_vars.hh"
#include "flags.hh"
#include "string.hh"
#include "utils.hh"
namespace Kakoune
{
2014-01-28 00:28:38 +04:00
class Context;
2014-11-13 00:27:07 +03:00
2014-04-20 15:15:31 +04:00
using EnvVarRetriever = std::function<String (StringView name, const Context&)>;
class ShellManager : public Singleton<ShellManager>
{
public:
ShellManager();
enum class Flags
{
None = 0,
WaitForStdout = 1
};
std::pair<String, int> eval(StringView cmdline, const Context& context,
StringView input = {},
Flags flags = Flags::WaitForStdout,
ConstArrayView<String> params = {},
const EnvVarMap& env_vars = EnvVarMap{});
void register_env_var(StringView str, bool prefix, EnvVarRetriever retriever);
String get_val(StringView name, const Context& context) const;
private:
struct EnvVarDesc { String str; bool prefix; EnvVarRetriever func; };
Vector<EnvVarDesc> m_env_vars;
};
template<> struct WithBitOps<ShellManager::Flags> : std::true_type {};
}
#endif // shell_manager_hh_INCLUDED