blob: 1336ca9b969b2d92f088ca4a6b9fe41152b49d3d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
#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"
#include "completion.hh"
namespace Kakoune
{
class Context;
using EnvVarRetriever = std::function<String (StringView name, const Context&)>;
struct ShellContext
{
ConstArrayView<String> params;
EnvVarMap env_vars;
};
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,
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;
private:
String m_shell;
struct EnvVarDesc { String str; bool prefix; EnvVarRetriever func; };
Vector<EnvVarDesc, MemoryDomain::EnvVars> m_env_vars;
};
template<> struct WithBitOps<ShellManager::Flags> : std::true_type {};
}
#endif // shell_manager_hh_INCLUDED
|