Add ClientRenamed hook
This commit is contained in:
parent
2f7568485f
commit
5515383ae4
|
@ -140,6 +140,9 @@ name. Hooks with no description will always use an empty string.
|
|||
*ClientClose* `client name`::
|
||||
executed when a client is closed, after it was removed from the client
|
||||
list.
|
||||
|
||||
*ClientRenamed* `<old name>:<new name>`::
|
||||
executed when a client is renamed using the `rename-client` command
|
||||
|
||||
*RuntimeError* `error message`::
|
||||
an error was encountered while executing a user command
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "client.hh"
|
||||
#include "face_registry.hh"
|
||||
#include "buffer_manager.hh"
|
||||
#include "hook_manager.hh"
|
||||
#include "register_manager.hh"
|
||||
#include "window.hh"
|
||||
|
||||
|
@ -417,4 +418,8 @@ StringView Context::main_sel_register_value(StringView reg) const
|
|||
return RegisterManager::instance()[reg].get_main(*this, index);
|
||||
}
|
||||
|
||||
void Context::set_name(String name) {
|
||||
String old_name = std::exchange(m_name, std::move(name));
|
||||
hooks().run_hook(Hook::ClientRenamed, format("{}:{}", old_name, m_name), *this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -110,7 +110,7 @@ public:
|
|||
StringView main_sel_register_value(StringView reg) const;
|
||||
|
||||
const String& name() const { return m_name; }
|
||||
void set_name(String name) { m_name = std::move(name); }
|
||||
void set_name(String name);
|
||||
|
||||
bool is_editing() const { return m_edition_level!= 0; }
|
||||
void disable_undo_handling() { m_edition_level = -1; }
|
||||
|
|
|
@ -30,6 +30,7 @@ enum class Hook
|
|||
BufSetOption,
|
||||
ClientCreate,
|
||||
ClientClose,
|
||||
ClientRenamed,
|
||||
InsertChar,
|
||||
InsertDelete,
|
||||
InsertIdle,
|
||||
|
@ -75,6 +76,7 @@ constexpr auto enum_desc(Meta::Type<Hook>)
|
|||
{Hook::BufSetOption, "BufSetOption"},
|
||||
{Hook::ClientCreate, "ClientCreate"},
|
||||
{Hook::ClientClose, "ClientClose"},
|
||||
{Hook::ClientRenamed, "ClientRenamed"},
|
||||
{Hook::InsertChar, "InsertChar"},
|
||||
{Hook::InsertDelete, "InsertDelete"},
|
||||
{Hook::InsertIdle, "InsertIdle"},
|
||||
|
|
Loading…
Reference in New Issue
Block a user