summaryrefslogtreecommitdiff
path: root/src/command_manager.cc
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2012-01-15 03:02:08 +0000
committerMaxime Coste <frrrwww@gmail.com>2012-01-15 03:02:08 +0000
commitf259af9326b4e2140f856f1651eaeb0d74537621 (patch)
tree14dd4064c0562500c25c4b3e58f49ed92f292ed7 /src/command_manager.cc
parentbe5cf9236750eb1fd38f0dd3ebc4da2af1fd87ab (diff)
CommandManager: add flags support and IgnoreSemiColons flag
commands are now registred with flags, and the IgnoreSemiColons flag permit to specify a command which needs all the parameters on the line, bypassing the command sequence operator ';'. the hook command is tagged as such.
Diffstat (limited to 'src/command_manager.cc')
-rw-r--r--src/command_manager.cc9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/command_manager.cc b/src/command_manager.cc
index 973e95de..33815be4 100644
--- a/src/command_manager.cc
+++ b/src/command_manager.cc
@@ -9,16 +9,18 @@ namespace Kakoune
{
void CommandManager::register_command(const std::string& command_name, Command command,
+ unsigned flags,
const CommandCompleter& completer)
{
- m_commands[command_name] = CommandAndCompleter { command, completer };
+ m_commands[command_name] = CommandDescriptor { command, flags, completer };
}
void CommandManager::register_command(const std::vector<std::string>& command_names, Command command,
+ unsigned flags,
const CommandCompleter& completer)
{
for (auto command_name : command_names)
- register_command(command_name, command, completer);
+ register_command(command_name, command, flags, completer);
}
typedef std::vector<std::pair<size_t, size_t>> TokenList;
@@ -97,6 +99,9 @@ void CommandManager::execute(const CommandParameters& params,
if (command_it == m_commands.end())
throw command_not_found(*begin);
+ if (command_it->second.flags & IgnoreSemiColons)
+ end = params.end();
+
command_it->second.command(CommandParameters(begin + 1, end), context);
}