From 3e1bb777ce9c8de3dbe55dee4e454241eddc98d1 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 4 Nov 2013 21:53:10 +0000 Subject: Add automatic completion display in prompt mode Controlled by the autoshowcompl option Completers now take a CompletionFlag parameter, used to specify we want fast completion (tag completion can be slow, we do not want to run it if not explicitely wanted by the user). --- src/command_manager.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/command_manager.cc') diff --git a/src/command_manager.cc b/src/command_manager.cc index c62d75fa..165a58f3 100644 --- a/src/command_manager.cc +++ b/src/command_manager.cc @@ -312,7 +312,7 @@ void CommandManager::execute(const String& command_line, execute_single_command(params, context); } -Completions CommandManager::complete(const Context& context, +Completions CommandManager::complete(const Context& context, CompletionFlags flags, const String& command_line, ByteCount cursor_pos) { TokenPosList pos_info; @@ -356,20 +356,21 @@ Completions CommandManager::complete(const Context& context, return Completions(); ByteCount start = token_to_complete < tokens.size() ? - pos_info[token_to_complete].first : cursor_pos; + pos_info[token_to_complete].first : cursor_pos; Completions result(start , cursor_pos); ByteCount cursor_pos_in_token = cursor_pos - start; std::vector params; for (auto token_it = tokens.begin()+1; token_it != tokens.end(); ++token_it) params.push_back(token_it->content()); - result.candidates = command_it->second.completer(context, params, + result.candidates = command_it->second.completer(context, flags, params, token_to_complete - 1, cursor_pos_in_token); return result; } CandidateList PerArgumentCommandCompleter::operator()(const Context& context, + CompletionFlags flags, CommandParameters params, size_t token_to_complete, ByteCount pos_in_token) const @@ -382,7 +383,7 @@ CandidateList PerArgumentCommandCompleter::operator()(const Context& context, const String& argument = token_to_complete < params.size() ? params[token_to_complete] : String(); - return m_completers[token_to_complete](context, argument, pos_in_token); + return m_completers[token_to_complete](context, flags, argument, pos_in_token); } } -- cgit v1.2.3