kakoune/src/shell_manager.hh
Maxime Coste 7fb49b183e ShellManager environment variable use a regex instead of an exact match
when a kakoune releated env var used in a shell command, the ShellManager
tries to match it with given regex and the first that matches calls its
value retriever.

For this to be useful, EnvVarRetrievers now also take the variable
name in its parameters.
2012-06-25 19:40:18 +02:00

39 lines
903 B
C++

#ifndef shell_manager_hh_INCLUDED
#define shell_manager_hh_INCLUDED
#include "utils.hh"
#include "regex.hh"
#include <unordered_map>
namespace Kakoune
{
class Context;
typedef std::function<String (const String& name, const Context&)> EnvVarRetriever;
typedef std::unordered_map<String, String> EnvVarMap;
class ShellManager : public Singleton<ShellManager>
{
public:
ShellManager();
String eval(const String& cmdline, const Context& context,
const EnvVarMap& env_vars);
String pipe(const String& input,
const String& cmdline, const Context& context,
const EnvVarMap& env_vars);
void register_env_var(const String& regex, EnvVarRetriever retriever);
private:
Regex m_regex;
std::vector<std::pair<Regex, EnvVarRetriever>> m_env_vars;
};
}
#endif // shell_manager_hh_INCLUDED