{
std::string arg_prefix (arg, word - arg);
- if (result.number_matches == 1)
- printf_unfiltered ("%s%s\n", arg_prefix.c_str (), result.match_list[0]);
- else
- {
- result.sort_match_list ();
-
- for (size_t i = 0; i < result.number_matches; i++)
- {
- printf_unfiltered ("%s%s",
- arg_prefix.c_str (),
- result.match_list[i + 1]);
- if (quote_char)
- printf_unfiltered ("%c", quote_char);
- printf_unfiltered ("\n");
- }
- }
-
- if (result.number_matches == max_completions)
- {
- /* ARG_PREFIX and WORD are included in the output so that emacs
- will include the message in the output. */
- printf_unfiltered (_("%s%s %s\n"),
- arg_prefix.c_str (), word,
- get_max_completions_reached_message ());
- }
+ result.print_matches (arg_prefix, word, quote_char);
}
}
}
}
+/* See completer.h */
+
+void
+completion_result::print_matches (const std::string &prefix,
+ const char *word, int quote_char)
+{
+ if (this->number_matches == 1)
+ printf_unfiltered ("%s%s\n", prefix.c_str (), this->match_list[0]);
+ else
+ {
+ this->sort_match_list ();
+
+ for (size_t i = 0; i < this->number_matches; i++)
+ {
+ printf_unfiltered ("%s%s", prefix.c_str (),
+ this->match_list[i + 1]);
+ if (quote_char)
+ printf_unfiltered ("%c", quote_char);
+ printf_unfiltered ("\n");
+ }
+ }
+
+ if (this->number_matches == max_completions)
+ {
+ /* PREFIX and WORD are included in the output so that emacs will
+ include the message in the output. */
+ printf_unfiltered (_("%s%s %s\n"),
+ prefix.c_str (), word,
+ get_max_completions_reached_message ());
+ }
+
+}
+
/* Helper for gdb_rl_attempted_completion_function, which does most of
the work. This is called by readline to build the match list array
and to determine the lowest common denominator. The real matches
/* Sort the match list. */
void sort_match_list ();
+ /* Called to display all matches (used by the 'complete' command).
+ PREFIX is everything before the completion word. WORD is the word
+ being completed, this is only used if we reach the maximum number of
+ completions, otherwise, each line of output consists of PREFIX
+ followed by one of the possible completion words.
+
+ The QUOTE_CHAR is appended after each possible completion word and
+ should be the quote character that appears before the completion word,
+ or the null-character if there is no quote before the completion
+ word. */
+ void print_matches (const std::string &prefix, const char *word,
+ int quote_char);
+
private:
/* Destroy the match list array and its contents. */
void reset_match_list ();