From 2de0d0fccfb6385c11d5bf3e6f0e94391531b169 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 18 Mar 2013 22:43:48 +0100 Subject: [PATCH] add a reg command to set a register --- README.asciidoc | 1 + src/commands.cc | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/README.asciidoc b/README.asciidoc index 630ecec3c..98ff905ea 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -434,6 +434,7 @@ Some helper commands can be used to define composite commands: * +try catch +: prevent an error in from aborting the whole commands execution, execute instead. + * +reg +: set register to Note that these commands are available in interactive command mode, but are not that useful in this context. diff --git a/src/commands.cc b/src/commands.cc index b56de71e6..c4944c7d0 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -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(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); } }