summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/command.cc
diff options
context:
space:
mode:
authorzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2007-12-06 10:54:17 +0000
committerzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2007-12-06 10:54:17 +0000
commit3a8c26c188557c9255281ed2b3ed10b5bca203d3 (patch)
treea5e50420a73488f0af016d865e66f0d4e0be134f /crawl-ref/source/command.cc
parent47173f1092b4f4f3bdc0da19d6dc4553f62cdee7 (diff)
downloadcrawl-ref-3a8c26c188557c9255281ed2b3ed10b5bca203d3.tar.gz
crawl-ref-3a8c26c188557c9255281ed2b3ed10b5bca203d3.zip
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
Diffstat (limited to 'crawl-ref/source/command.cc')
-rw-r--r--crawl-ref/source/command.cc54
1 files changed, 45 insertions, 9 deletions
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<std::string> &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<std::string> 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;
}