mirror of
https://github.com/mawww/kakoune.git
synced 2024-12-19 01:11:36 +03:00
parent
8f2c6eb586
commit
e340e0ed39
@ -708,12 +708,14 @@ void Buffer::on_option_changed(const Option& option)
|
||||
format("{}={}", option.name(), option.get_as_string()));
|
||||
}
|
||||
|
||||
void Buffer::run_hook_in_own_context(StringView hook_name, StringView param)
|
||||
void Buffer::run_hook_in_own_context(StringView hook_name, StringView param, String client_name)
|
||||
{
|
||||
if (m_flags & Buffer::Flags::NoHooks)
|
||||
return;
|
||||
|
||||
InputHandler hook_handler({ *this, Selection{} }, Context::Flags::Transient);
|
||||
InputHandler hook_handler{{ *this, Selection{} },
|
||||
Context::Flags::Transient,
|
||||
std::move(client_name)};
|
||||
hooks().run_hook(hook_name, param, hook_handler.context());
|
||||
}
|
||||
|
||||
|
@ -190,7 +190,8 @@ public:
|
||||
|
||||
ValueMap& values() const { return m_values; }
|
||||
|
||||
void run_hook_in_own_context(StringView hook_name, StringView param);
|
||||
void run_hook_in_own_context(StringView hook_name, StringView param,
|
||||
String client_name = "");
|
||||
|
||||
void reload(StringView data, timespec fs_timestamp = InvalidTime);
|
||||
|
||||
|
@ -338,7 +338,7 @@ const CommandDesc write_cmd = {
|
||||
write_buffer,
|
||||
};
|
||||
|
||||
void write_all_buffers()
|
||||
void write_all_buffers(Context& context)
|
||||
{
|
||||
// Copy buffer list because hooks might be creating/deleting buffers
|
||||
Vector<SafePtr<Buffer>> buffers;
|
||||
@ -350,9 +350,9 @@ void write_all_buffers()
|
||||
if ((buffer->flags() & Buffer::Flags::File) and buffer->is_modified()
|
||||
and !(buffer->flags() & Buffer::Flags::ReadOnly))
|
||||
{
|
||||
buffer->run_hook_in_own_context("BufWritePre", buffer->name());
|
||||
buffer->run_hook_in_own_context("BufWritePre", buffer->name(), context.name());
|
||||
write_buffer_to_file(*buffer, buffer->name());
|
||||
buffer->run_hook_in_own_context("BufWritePost", buffer->name());
|
||||
buffer->run_hook_in_own_context("BufWritePost", buffer->name(), context.name());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -365,7 +365,7 @@ const CommandDesc write_all_cmd = {
|
||||
CommandFlags::None,
|
||||
CommandHelper{},
|
||||
CommandCompleter{},
|
||||
[](const ParametersParser&, Context&, const ShellContext&){ write_all_buffers(); }
|
||||
[](const ParametersParser&, Context& context, const ShellContext&){ write_all_buffers(context); }
|
||||
};
|
||||
|
||||
static void ensure_all_buffers_are_saved()
|
||||
@ -490,7 +490,7 @@ const CommandDesc write_all_quit_cmd = {
|
||||
CommandCompleter{},
|
||||
[](const ParametersParser& parser, Context& context, const ShellContext&)
|
||||
{
|
||||
write_all_buffers();
|
||||
write_all_buffers(context);
|
||||
quit<false>(context);
|
||||
}
|
||||
};
|
||||
|
@ -367,12 +367,15 @@ void Window::on_option_changed(const Option& option)
|
||||
}
|
||||
|
||||
|
||||
void Window::run_hook_in_own_context(StringView hook_name, StringView param)
|
||||
void Window::run_hook_in_own_context(StringView hook_name, StringView param,
|
||||
String client_name)
|
||||
{
|
||||
if (m_buffer->flags() & Buffer::Flags::NoHooks)
|
||||
return;
|
||||
|
||||
InputHandler hook_handler({ *m_buffer, Selection{} }, Context::Flags::Transient);
|
||||
InputHandler hook_handler{{ *m_buffer, Selection{} },
|
||||
Context::Flags::Transient,
|
||||
std::move(client_name)};
|
||||
hook_handler.context().set_window(*this);
|
||||
if (m_client)
|
||||
hook_handler.context().set_client(*m_client);
|
||||
|
@ -56,7 +56,8 @@ private:
|
||||
void on_option_changed(const Option& option) override;
|
||||
void scroll_to_keep_selection_visible_ifn(const Context& context);
|
||||
|
||||
void run_hook_in_own_context(StringView hook_name, StringView param);
|
||||
void run_hook_in_own_context(StringView hook_name, StringView param,
|
||||
String client_name = "");
|
||||
|
||||
SafePtr<Buffer> m_buffer;
|
||||
SafePtr<Client> m_client;
|
||||
|
Loading…
Reference in New Issue
Block a user