From 3a8c26c188557c9255281ed2b3ed10b5bca203d3 Mon Sep 17 00:00:00 2001 From: zelgadis Date: Thu, 6 Dec 2007 10:54:17 +0000 Subject: If a "?/" query produces an exact match for the string entered, but also produces non-exact matches, then the exact match is shown right away, but with a footer saying that you can press space to look at the list of non-exact matches. When done with a "?/" query, the user is returned to the inital "/?" prompt. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3010 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/command.cc | 54 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 45 insertions(+), 9 deletions(-) (limited to 'crawl-ref/source') diff --git a/crawl-ref/source/command.cc b/crawl-ref/source/command.cc index 289abab104..b656405356 100644 --- a/crawl-ref/source/command.cc +++ b/crawl-ref/source/command.cc @@ -938,7 +938,7 @@ static void recap_feat_keys(std::vector &keys) } } -static bool do_description(std::string key) +static bool do_description(std::string key, std::string footer = "") { std::string desc = getLongDescription(key); @@ -994,11 +994,24 @@ static bool do_description(std::string key) clrscr(); print_description(key + desc); + if (footer != "") + { + const int numcols = get_number_of_cols(); + int num_lines = linebreak_string2(footer, numcols); + num_lines++; + + gotoxy(1, get_number_of_lines() - num_lines); + + cprintf(footer.c_str()); + } + return (true); } -static bool find_description() +static bool find_description(bool &again) { + again = true; + clrscr(); viewwindow(true, false); @@ -1061,6 +1074,7 @@ static bool find_description() default: list_commands_err = "Okay, then."; + again = false; return (false); } @@ -1095,16 +1109,14 @@ static bool find_description() if (by_mon_symbol) want_regex = false; - // Try to get an exact match first. + bool exact_match = false; if (want_regex && !(*filter)(regex, "")) { // Try to get an exact match first. std::string desc = getLongDescription(regex); if (desc != "") - { - return do_description(regex); - } + exact_match = true; } std::vector key_list; @@ -1167,6 +1179,22 @@ static bool find_description() return do_description(key_list[0]); } + if (exact_match) + { + std::string footer = "This entry is an exact match for '"; + footer += regex; + footer += "'. To see non-exact matches, press space."; + + if (!do_description(regex, footer)) + { + DEBUGSTR("do_description() returned false for exact_match"); + return (false); + } + + if (getch() != ' ') + return (false); + } + if (want_sort) std::sort(key_list.begin(), key_list.end()); @@ -1258,13 +1286,21 @@ static int keyhelp_keyfilter(int ch) break; case '/': - if (find_description()) - if ( getch() == 0 ) - getch(); + { + bool again = false; + do { + if (find_description(again)) + if ( getch() == 0 ) + getch(); + if (again) + mesclr(true); + } while(again); viewwindow(true, false); + return -1; } + } return ch; } -- cgit v1.2.3-54-g00ecf