From 4a5758ebb30231bbd2aa8176d95d3090d392bf78 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sun, 15 Jan 2012 01:37:35 +0000 Subject: [PATCH] CommandManager: support ';' as a command separator --- src/command_manager.cc | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/src/command_manager.cc b/src/command_manager.cc index 542466d4..973e95de 100644 --- a/src/command_manager.cc +++ b/src/command_manager.cc @@ -41,12 +41,15 @@ static TokenList split(const std::string& line) size_t token_start = pos; - while ((line[pos] != delimiter or line[pos-1] == '\\') and - pos != line.length()) + while (((line[pos] != delimiter and line[pos] != ';') or + line[pos-1] == '\\') and pos != line.length()) ++pos; result.push_back(std::make_pair(token_start, pos)); + if (line[pos] == ';') + result.push_back(std::make_pair(pos, pos+1)); + ++pos; } return result; @@ -81,11 +84,28 @@ void CommandManager::execute(const CommandParameters& params, if (params.empty()) return; - auto command_it = m_commands.find(params[0]); - if (command_it == m_commands.end()) - throw command_not_found(params[0]); + auto begin = params.begin(); + auto end = begin; + while (true) + { + while (end != params.end() and *end != ";") + ++end; - command_it->second.command(CommandParameters(params.begin() + 1, params.end()), context); + if (end != begin) + { + auto command_it = m_commands.find(*begin); + if (command_it == m_commands.end()) + throw command_not_found(*begin); + + command_it->second.command(CommandParameters(begin + 1, end), context); + } + + if (end == params.end()) + break; + + begin = end+1; + end = begin; + } } Completions CommandManager::complete(const std::string& command_line, size_t cursor_pos)