mirror of
https://github.com/mawww/kakoune.git
synced 2024-12-25 04:24:48 +03:00
add a reg command to set a register
This commit is contained in:
parent
5fe7315df9
commit
2de0d0fccf
@ -434,6 +434,7 @@ Some helper commands can be used to define composite commands:
|
||||
* +try <commands> catch <on_error_commands>+: prevent an error in <commands>
|
||||
from aborting the whole commands execution, execute <on_error_commands>
|
||||
instead.
|
||||
* +reg <name> <content>+: set register <name> to <content>
|
||||
|
||||
Note that these commands are available in interactive command mode, but are
|
||||
not that useful in this context.
|
||||
|
@ -713,6 +713,16 @@ void set_client_name(const CommandParameters& params, Context& context)
|
||||
ClientManager::instance().set_client_name(context, params[0]);
|
||||
}
|
||||
|
||||
void set_register(const CommandParameters& params, Context& context)
|
||||
{
|
||||
if (params.size() != 2)
|
||||
throw wrong_argument_count();
|
||||
|
||||
if (params[0].length() != 1)
|
||||
throw runtime_error("register names are single character");
|
||||
RegisterManager::instance()[params[0][0]] = memoryview<String>(params[1]);
|
||||
}
|
||||
|
||||
class RegisterRestorer
|
||||
{
|
||||
public:
|
||||
@ -908,6 +918,8 @@ void register_commands()
|
||||
|
||||
cm.register_commands({"ca", "colalias"}, define_color_alias);
|
||||
cm.register_commands({"name"}, set_client_name);
|
||||
|
||||
cm.register_command("reg", set_register);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user