Add SessionRenamed hook
This commit is contained in:
parent
5515383ae4
commit
a1880a5441
|
@ -144,6 +144,9 @@ name. Hooks with no description will always use an empty string.
|
||||||
*ClientRenamed* `<old name>:<new name>`::
|
*ClientRenamed* `<old name>:<new name>`::
|
||||||
executed when a client is renamed using the `rename-client` command
|
executed when a client is renamed using the `rename-client` command
|
||||||
|
|
||||||
|
*SessionRenamed* `<old name>:<new name>`::
|
||||||
|
executed when a session is renamed using the `rename-session` command
|
||||||
|
|
||||||
*RuntimeError* `error message`::
|
*RuntimeError* `error message`::
|
||||||
an error was encountered while executing a user command
|
an error was encountered while executing a user command
|
||||||
|
|
||||||
|
|
|
@ -2577,10 +2577,12 @@ const CommandDesc rename_session_cmd = {
|
||||||
CommandFlags::None,
|
CommandFlags::None,
|
||||||
CommandHelper{},
|
CommandHelper{},
|
||||||
make_single_word_completer([](const Context&){ return Server::instance().session(); }),
|
make_single_word_completer([](const Context&){ return Server::instance().session(); }),
|
||||||
[](const ParametersParser& parser, Context&, const ShellContext&)
|
[](const ParametersParser& parser, Context& ctx, const ShellContext&)
|
||||||
{
|
{
|
||||||
|
String old_name = Server::instance().session();
|
||||||
if (not Server::instance().rename_session(parser[0]))
|
if (not Server::instance().rename_session(parser[0]))
|
||||||
throw runtime_error(format("unable to rename current session: '{}' may be already in use", parser[0]));
|
throw runtime_error(format("unable to rename current session: '{}' may be already in use", parser[0]));
|
||||||
|
ctx.hooks().run_hook(Hook::SessionRenamed, format("{}:{}", old_name, Server::instance().session()), ctx);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@ enum class Hook
|
||||||
ClientCreate,
|
ClientCreate,
|
||||||
ClientClose,
|
ClientClose,
|
||||||
ClientRenamed,
|
ClientRenamed,
|
||||||
|
SessionRenamed,
|
||||||
InsertChar,
|
InsertChar,
|
||||||
InsertDelete,
|
InsertDelete,
|
||||||
InsertIdle,
|
InsertIdle,
|
||||||
|
@ -77,6 +78,7 @@ constexpr auto enum_desc(Meta::Type<Hook>)
|
||||||
{Hook::ClientCreate, "ClientCreate"},
|
{Hook::ClientCreate, "ClientCreate"},
|
||||||
{Hook::ClientClose, "ClientClose"},
|
{Hook::ClientClose, "ClientClose"},
|
||||||
{Hook::ClientRenamed, "ClientRenamed"},
|
{Hook::ClientRenamed, "ClientRenamed"},
|
||||||
|
{Hook::SessionRenamed, "SessionRenamed"},
|
||||||
{Hook::InsertChar, "InsertChar"},
|
{Hook::InsertChar, "InsertChar"},
|
||||||
{Hook::InsertDelete, "InsertDelete"},
|
{Hook::InsertDelete, "InsertDelete"},
|
||||||
{Hook::InsertIdle, "InsertIdle"},
|
{Hook::InsertIdle, "InsertIdle"},
|
||||||
|
|
Loading…
Reference in New Issue
Block a user