summaryrefslogtreecommitdiff
path: root/src/shell_manager.hh
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2018-02-18 14:52:29 +1100
committerMaxime Coste <mawww@kakoune.org>2018-02-18 14:52:29 +1100
commit5924694bda89fab3287fc827b71b3ce488848922 (patch)
tree4e8d8cbb2a4855e13e9928a3cddefc8e7af25ee0 /src/shell_manager.hh
parentd9cddf41f2d2cb41cb2f7b0fbe47ccdfdb942991 (diff)
ShellManager: init from a static list of env vars
No need to go through a static list and then copy them one by one in a vector.
Diffstat (limited to 'src/shell_manager.hh')
-rw-r--r--src/shell_manager.hh18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/shell_manager.hh b/src/shell_manager.hh
index df2429d6..f97935d1 100644
--- a/src/shell_manager.hh
+++ b/src/shell_manager.hh
@@ -12,18 +12,26 @@ namespace Kakoune
class Context;
-using EnvVarRetriever = std::function<String (StringView name, const Context&)>;
-
struct ShellContext
{
ConstArrayView<String> params;
EnvVarMap env_vars;
};
+
+struct EnvVarDesc
+{
+ using Retriever = String (*)(StringView name, const Context&);
+
+ StringView str;
+ bool prefix;
+ Retriever func;
+};
+
class ShellManager : public Singleton<ShellManager>
{
public:
- ShellManager();
+ ShellManager(ConstArrayView<EnvVarDesc> builtin_env_vars);
enum class Flags
{
@@ -37,7 +45,6 @@ public:
Flags flags = Flags::WaitForStdout,
const ShellContext& shell_context = {});
- void register_env_var(StringView str, bool prefix, EnvVarRetriever retriever);
String get_val(StringView name, const Context& context) const;
CandidateList complete_env_var(StringView prefix, ByteCount cursor_pos) const;
@@ -45,8 +52,7 @@ public:
private:
String m_shell;
- struct EnvVarDesc { String str; bool prefix; EnvVarRetriever func; };
- Vector<EnvVarDesc, MemoryDomain::EnvVars> m_env_vars;
+ ConstArrayView<EnvVarDesc> m_env_vars;
};
}