Added ModuleLoad hook that uses the module name as the parameter

This commit is contained in:
Justin Frank 2019-03-13 12:46:53 -07:00
parent c3f694a28f
commit 7866d88131
2 changed files with 6 additions and 2 deletions

View File

@ -65,6 +65,8 @@ void CommandManager::load_module(StringView module_name, Context& context)
module->value.loaded = true;
execute(module->value.commands, context);
module->value.commands.clear();
context.hooks().run_hook(Hook::ModuleLoad, module_name, context);
}
struct parse_error : runtime_error

View File

@ -57,12 +57,13 @@ enum class Hook
WinCreate,
WinDisplay,
WinResize,
WinSetOption
WinSetOption,
ModuleLoad
};
constexpr auto enum_desc(Meta::Type<Hook>)
{
return make_array<EnumDesc<Hook>, 41>({
return make_array<EnumDesc<Hook>, 42>({
{Hook::BufCreate, "BufCreate"},
{Hook::BufNewFile, "BufNewFile"},
{Hook::BufOpenFile, "BufOpenFile"},
@ -104,6 +105,7 @@ constexpr auto enum_desc(Meta::Type<Hook>)
{Hook::WinDisplay, "WinDisplay"},
{Hook::WinResize, "WinResize"},
{Hook::WinSetOption, "WinSetOption"},
{Hook::ModuleLoad, "ModuleLoad"}
});
}