From 5924694bda89fab3287fc827b71b3ce488848922 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sun, 18 Feb 2018 14:52:29 +1100 Subject: 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. --- src/shell_manager.hh | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/shell_manager.hh') 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; - struct ShellContext { ConstArrayView params; EnvVarMap env_vars; }; + +struct EnvVarDesc +{ + using Retriever = String (*)(StringView name, const Context&); + + StringView str; + bool prefix; + Retriever func; +}; + class ShellManager : public Singleton { public: - ShellManager(); + ShellManager(ConstArrayView 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 m_env_vars; + ConstArrayView m_env_vars; }; } -- cgit v1.2.3