2012-04-03 16:01:01 +04:00
|
|
|
#ifndef hook_manager_hh_INCLUDED
|
|
|
|
#define hook_manager_hh_INCLUDED
|
2011-11-25 18:26:29 +04:00
|
|
|
|
2013-11-19 02:24:31 +04:00
|
|
|
#include "id_map.hh"
|
2014-12-23 16:54:09 +03:00
|
|
|
#include "completion.hh"
|
2011-11-25 18:26:29 +04:00
|
|
|
|
|
|
|
namespace Kakoune
|
|
|
|
{
|
|
|
|
|
2013-11-11 23:10:49 +04:00
|
|
|
class Context;
|
2014-10-20 22:18:38 +04:00
|
|
|
using HookFunc = std::function<void (StringView, Context&)>;
|
2011-11-25 18:26:29 +04:00
|
|
|
|
2012-04-03 16:01:01 +04:00
|
|
|
class HookManager
|
2011-11-25 18:26:29 +04:00
|
|
|
{
|
|
|
|
public:
|
2012-06-07 17:29:44 +04:00
|
|
|
HookManager(HookManager& parent) : m_parent(&parent) {}
|
|
|
|
|
2015-03-05 17:59:27 +03:00
|
|
|
void add_hook(StringView hook_name, String group, HookFunc hook);
|
2014-06-16 23:42:12 +04:00
|
|
|
void remove_hooks(StringView group);
|
2014-07-22 00:14:32 +04:00
|
|
|
CandidateList complete_hook_group(StringView prefix, ByteCount pos_in_token);
|
2015-03-05 17:59:27 +03:00
|
|
|
void run_hook(StringView hook_name, StringView param,
|
2013-01-17 16:44:14 +04:00
|
|
|
Context& context) const;
|
2011-11-25 18:26:29 +04:00
|
|
|
|
|
|
|
private:
|
2012-06-07 17:29:44 +04:00
|
|
|
HookManager()
|
|
|
|
: m_parent(nullptr) {}
|
|
|
|
// the only one allowed to construct a root hook manager
|
2014-10-30 17:00:42 +03:00
|
|
|
friend class Scope;
|
2012-06-07 17:29:44 +04:00
|
|
|
|
|
|
|
HookManager* m_parent;
|
2015-03-05 17:59:27 +03:00
|
|
|
IdMap<IdMap<HookFunc, MemoryDomain::Hooks>, MemoryDomain::Hooks> m_hook;
|
2011-11-25 18:26:29 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-04-03 16:01:01 +04:00
|
|
|
#endif // hook_manager_hh_INCLUDED
|