1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-12-22 19:11:40 +03:00
kakoune/src/hook_manager.hh

48 lines
1.2 KiB
C++
Raw Normal View History

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
2017-03-07 04:12:37 +03:00
#include "hash_map.hh"
#include "completion.hh"
2016-05-15 12:37:42 +03:00
#include "safe_ptr.hh"
#include "regex.hh"
2011-11-25 18:26:29 +04:00
namespace Kakoune
{
2013-11-11 23:10:49 +04:00
class Context;
2011-11-25 18:26:29 +04:00
2016-05-15 12:37:42 +03:00
class HookManager : public SafeCountable
2011-11-25 18:26:29 +04:00
{
public:
HookManager(HookManager& parent) : SafeCountable{}, m_parent(&parent) {}
void add_hook(StringView hook_name, String group, Regex filter, String commands);
void remove_hooks(StringView group);
2014-07-22 00:14:32 +04:00
CandidateList complete_hook_group(StringView prefix, ByteCount pos_in_token);
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:
HookManager()
: m_parent(nullptr) {}
// the only one allowed to construct a root hook manager
friend class Scope;
struct Hook
{
String group;
Regex filter;
String commands;
};
2016-05-15 12:37:42 +03:00
SafePtr<HookManager> m_parent;
HashMap<String, Vector<std::unique_ptr<Hook>, MemoryDomain::Hooks>, MemoryDomain::Hooks> m_hooks;
mutable Vector<std::pair<StringView, StringView>, MemoryDomain::Hooks> m_running_hooks;
mutable Vector<std::unique_ptr<Hook>, MemoryDomain::Hooks> m_hooks_trash;
2011-11-25 18:26:29 +04:00
};
}
2012-04-03 16:01:01 +04:00
#endif // hook_manager_hh_INCLUDED