diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2013-11-04 21:53:10 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2013-11-04 21:59:28 +0000 |
| commit | 3e1bb777ce9c8de3dbe55dee4e454241eddc98d1 (patch) | |
| tree | 0b6635de8461910e2a6d90e3a14f48c2e5091e36 /src/command_manager.cc | |
| parent | 70e94cb00a577c53b77f7349f138d3a563745793 (diff) | |
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).
Diffstat (limited to 'src/command_manager.cc')
| -rw-r--r-- | src/command_manager.cc | 9 |
1 files changed, 5 insertions, 4 deletions
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<String> 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); } } |
