summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTobias Pisani <topisani@hamsterpoison.com>2024-03-03 04:29:32 +0100
committerTobias Pisani <topisani@hamsterpoison.com>2024-03-27 17:59:05 +0100
commit5515383ae4683c3d691004cbc422ee1f6e36ee07 (patch)
treeb45f864897dd5ac6a3d531f79db1d019870dcf39 /src
parent2f7568485ff6ac6aaf83f6ac5988de6a723083c4 (diff)
Add ClientRenamed hook
Diffstat (limited to 'src')
-rw-r--r--src/context.cc5
-rw-r--r--src/context.hh2
-rw-r--r--src/hook_manager.hh2
3 files changed, 8 insertions, 1 deletions
diff --git a/src/context.cc b/src/context.cc
index 0c1b8aad..71a5becd 100644
--- a/src/context.cc
+++ b/src/context.cc
@@ -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);
+}
}
diff --git a/src/context.hh b/src/context.hh
index fca4ba06..7834bde4 100644
--- a/src/context.hh
+++ b/src/context.hh
@@ -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; }
diff --git a/src/hook_manager.hh b/src/hook_manager.hh
index 24e88e1a..4a5c85b3 100644
--- a/src/hook_manager.hh
+++ b/src/hook_manager.hh
@@ -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"},