From 1d106fd31e777efb2af425674b7bc4b27f3eaf60 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 3 Apr 2012 14:04:02 +0000 Subject: [PATCH] add set{g,global,b,buffer,w,window} command to allow changing options --- src/main.cc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/main.cc b/src/main.cc index 488e4e33..d35b51ef 100644 --- a/src/main.cc +++ b/src/main.cc @@ -548,6 +548,14 @@ void exec_commands_in_runtime_file(const CommandParameters& params, } } +void set_option(OptionManager& option_manager, const CommandParameters& params) +{ + if (params.size() != 2) + throw wrong_argument_count(); + + option_manager[params[0]] = params[1]; +} + void do_command() { try @@ -994,6 +1002,18 @@ int main(int argc, char* argv[]) command_manager.register_command("def", define_command, CommandManager::IgnoreSemiColons | CommandManager::DeferredShellEval); command_manager.register_command("echo", echo_message); + command_manager.register_commands({ "setg", "setglobal" }, + [&](const CommandParameters& params, const Context&) { set_option(option_manager, params); }, + CommandManager::None); + command_manager.register_commands({ "setb", "setbuffer" }, + [&](const CommandParameters& params, const Context& context) + { set_option(context.buffer().option_manager(), params); }, + CommandManager::None); + command_manager.register_commands({ "setw", "setwindow" }, + [&](const CommandParameters& params, const Context& context) + { set_option(context.window().option_manager(), params); }, + CommandManager::None); + register_highlighters(); register_filters();