2012-05-03 11:25:13 +04:00
|
|
|
#ifndef shell_manager_hh_INCLUDED
|
|
|
|
#define shell_manager_hh_INCLUDED
|
|
|
|
|
|
|
|
#include "utils.hh"
|
2012-08-29 23:49:36 +04:00
|
|
|
#include "string.hh"
|
2012-05-03 11:25:13 +04:00
|
|
|
|
|
|
|
#include <unordered_map>
|
|
|
|
|
|
|
|
namespace Kakoune
|
|
|
|
{
|
|
|
|
|
2013-02-18 17:00:43 +04:00
|
|
|
struct Context;
|
2012-06-25 21:40:18 +04:00
|
|
|
typedef std::function<String (const String& name, const Context&)> EnvVarRetriever;
|
2012-05-29 09:19:27 +04:00
|
|
|
typedef std::unordered_map<String, String> EnvVarMap;
|
2012-05-03 11:25:13 +04:00
|
|
|
|
|
|
|
class ShellManager : public Singleton<ShellManager>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ShellManager();
|
|
|
|
|
2012-05-29 09:19:27 +04:00
|
|
|
String eval(const String& cmdline, const Context& context,
|
2012-09-09 19:10:53 +04:00
|
|
|
const memoryview<String>& params,
|
2012-05-29 09:19:27 +04:00
|
|
|
const EnvVarMap& env_vars);
|
2012-05-03 11:25:13 +04:00
|
|
|
|
2012-05-29 14:39:03 +04:00
|
|
|
String pipe(const String& input,
|
|
|
|
const String& cmdline, const Context& context,
|
2012-09-09 19:10:53 +04:00
|
|
|
const memoryview<String>& params,
|
2012-05-29 14:39:03 +04:00
|
|
|
const EnvVarMap& env_vars);
|
|
|
|
|
2012-06-25 21:40:18 +04:00
|
|
|
void register_env_var(const String& regex, EnvVarRetriever retriever);
|
2012-05-03 11:25:13 +04:00
|
|
|
|
|
|
|
private:
|
2012-06-25 21:40:18 +04:00
|
|
|
Regex m_regex;
|
|
|
|
std::vector<std::pair<Regex, EnvVarRetriever>> m_env_vars;
|
2012-05-03 11:25:13 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // shell_manager_hh_INCLUDED
|
|
|
|
|