kakoune/src/hook_manager.hh

38 lines
893 B
C++
Raw Normal View History

2012-04-03 14:01:01 +02:00
#ifndef hook_manager_hh_INCLUDED
#define hook_manager_hh_INCLUDED
2011-11-25 15:26:29 +01:00
#include "id_map.hh"
#include "completion.hh"
#include "unordered_map.hh"
2011-11-25 15:26:29 +01:00
namespace Kakoune
{
2013-11-11 20:10:49 +01:00
class Context;
using HookFunc = std::function<void (StringView, Context&)>;
2011-11-25 15:26:29 +01:00
2012-04-03 14:01:01 +02:00
class HookManager
2011-11-25 15:26:29 +01:00
{
public:
HookManager(HookManager& parent) : m_parent(&parent) {}
void add_hook(const String& hook_name, String group, HookFunc hook);
void remove_hooks(StringView group);
2014-07-21 22:14:32 +02:00
CandidateList complete_hook_group(StringView prefix, ByteCount pos_in_token);
void run_hook(const String& hook_name, StringView param,
2013-01-17 13:44:14 +01:00
Context& context) const;
2011-11-25 15:26:29 +01:00
private:
HookManager()
: m_parent(nullptr) {}
// the only one allowed to construct a root hook manager
friend class Scope;
HookManager* m_parent;
2014-12-23 23:51:00 +01:00
UnorderedMap<String, IdMap<HookFunc>> m_hook;
2011-11-25 15:26:29 +01:00
};
}
2012-04-03 14:01:01 +02:00
#endif // hook_manager_hh_INCLUDED