diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2018-07-28 11:09:23 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2018-07-28 11:09:23 +0000 |
commit | f73363f1dd94996356cefbf24388f561891acf0b (patch) | |
tree | e3c31248bdb36eaec5fd833490d4278162dba2a0 /source/Commands/CommandObjectMultiword.cpp | |
parent | 160ee69dd7ae18978f4068116777639ea98dc951 (diff) |
Notes
Diffstat (limited to 'source/Commands/CommandObjectMultiword.cpp')
-rw-r--r-- | source/Commands/CommandObjectMultiword.cpp | 70 |
1 files changed, 25 insertions, 45 deletions
diff --git a/source/Commands/CommandObjectMultiword.cpp b/source/Commands/CommandObjectMultiword.cpp index 0d0aa108a4ceb..ade1a2d01f382 100644 --- a/source/Commands/CommandObjectMultiword.cpp +++ b/source/Commands/CommandObjectMultiword.cpp @@ -55,8 +55,7 @@ CommandObjectSP CommandObjectMultiword::GetSubcommandSP(llvm::StringRef sub_cmd, if (num_matches == 1) { // Cleaner, but slightly less efficient would be to call back into this - // function, since I now - // know I have an exact match... + // function, since I now know I have an exact match... sub_cmd = matches->GetStringAtIndex(0); pos = m_subcommand_dict.find(sub_cmd); @@ -121,8 +120,8 @@ bool CommandObjectMultiword::Execute(const char *args_string, CommandObject *sub_cmd_obj = GetSubcommandObject(sub_command, &matches); if (sub_cmd_obj != nullptr) { // Now call CommandObject::Execute to process options in `rest_of_line`. - // From there the command-specific version of Execute will be called, - // with the processed arguments. + // From there the command-specific version of Execute will be called, with + // the processed arguments. args.Shift(); sub_cmd_obj->Execute(args_string, result); @@ -156,8 +155,8 @@ bool CommandObjectMultiword::Execute(const char *args_string, } void CommandObjectMultiword::GenerateHelpText(Stream &output_stream) { - // First time through here, generate the help text for the object and - // push it to the return result object as well + // First time through here, generate the help text for the object and push it + // to the return result object as well CommandObject::GenerateHelpText(output_stream); output_stream.PutCString("\nThe following subcommands are supported:\n\n"); @@ -187,18 +186,14 @@ void CommandObjectMultiword::GenerateHelpText(Stream &output_stream) { "'help <command> <subcommand>'.\n"); } -int CommandObjectMultiword::HandleCompletion(Args &input, int &cursor_index, - int &cursor_char_position, - int match_start_point, - int max_return_elements, - bool &word_complete, - StringList &matches) { +int CommandObjectMultiword::HandleCompletion(CompletionRequest &request) { // Any of the command matches will provide a complete word, otherwise the // individual completers will override this. - word_complete = true; + request.SetWordComplete(true); + auto &matches = request.GetMatches(); - auto arg0 = input[0].ref; - if (cursor_index == 0) { + auto arg0 = request.GetParsedLine()[0].ref; + if (request.GetCursorIndex() == 0) { AddNamesMatchingPartialString(m_subcommand_dict, arg0, matches); if (matches.GetSize() == 1 && matches.GetStringAtIndex(0) != nullptr && @@ -206,16 +201,14 @@ int CommandObjectMultiword::HandleCompletion(Args &input, int &cursor_index, StringList temp_matches; CommandObject *cmd_obj = GetSubcommandObject(arg0, &temp_matches); if (cmd_obj != nullptr) { - if (input.GetArgumentCount() == 1) { - word_complete = true; + if (request.GetParsedLine().GetArgumentCount() == 1) { + request.SetWordComplete(true); } else { matches.DeleteStringAtIndex(0); - input.Shift(); - cursor_char_position = 0; - input.AppendArgument(llvm::StringRef()); - return cmd_obj->HandleCompletion( - input, cursor_index, cursor_char_position, match_start_point, - max_return_elements, word_complete, matches); + request.GetParsedLine().Shift(); + request.SetCursorCharPosition(0); + request.GetParsedLine().AppendArgument(llvm::StringRef()); + return cmd_obj->HandleCompletion(request); } } } @@ -227,11 +220,9 @@ int CommandObjectMultiword::HandleCompletion(Args &input, int &cursor_index, } else { // Remove the one match that we got from calling GetSubcommandObject. matches.DeleteStringAtIndex(0); - input.Shift(); - cursor_index--; - return sub_command_object->HandleCompletion( - input, cursor_index, cursor_char_position, match_start_point, - max_return_elements, word_complete, matches); + request.GetParsedLine().Shift(); + request.SetCursorIndex(request.GetCursorIndex() - 1); + return sub_command_object->HandleCompletion(request); } } } @@ -371,31 +362,20 @@ Options *CommandObjectProxy::GetOptions() { return nullptr; } -int CommandObjectProxy::HandleCompletion(Args &input, int &cursor_index, - int &cursor_char_position, - int match_start_point, - int max_return_elements, - bool &word_complete, - StringList &matches) { +int CommandObjectProxy::HandleCompletion(CompletionRequest &request) { CommandObject *proxy_command = GetProxyCommandObject(); if (proxy_command) - return proxy_command->HandleCompletion( - input, cursor_index, cursor_char_position, match_start_point, - max_return_elements, word_complete, matches); - matches.Clear(); + return proxy_command->HandleCompletion(request); + request.GetMatches().Clear(); return 0; } int CommandObjectProxy::HandleArgumentCompletion( - Args &input, int &cursor_index, int &cursor_char_position, - OptionElementVector &opt_element_vector, int match_start_point, - int max_return_elements, bool &word_complete, StringList &matches) { + CompletionRequest &request, OptionElementVector &opt_element_vector) { CommandObject *proxy_command = GetProxyCommandObject(); if (proxy_command) - return proxy_command->HandleArgumentCompletion( - input, cursor_index, cursor_char_position, opt_element_vector, - match_start_point, max_return_elements, word_complete, matches); - matches.Clear(); + return proxy_command->HandleArgumentCompletion(request, opt_element_vector); + request.GetMatches().Clear(); return 0; } |