diff options
author | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-09-30 17:18:31 +0000 |
---|---|---|
committer | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-09-30 17:18:31 +0000 |
commit | 2d3f243d6828ab20789b6b95dc501806f903b927 (patch) | |
tree | ed5a2df8de1dc4670e6f8d6249def1a89f4c136c /crawl-ref/source/stash.cc | |
parent | e2179589b89a1d9786aa3111286af81878d21219 (diff) | |
download | crawl-ref-2d3f243d6828ab20789b6b95dc501806f903b927.tar.gz crawl-ref-2d3f243d6828ab20789b6b95dc501806f903b927.zip |
Fixed regex escapes for "." stash search.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2266 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/stash.cc')
-rw-r--r-- | crawl-ref/source/stash.cc | 63 |
1 files changed, 36 insertions, 27 deletions
diff --git a/crawl-ref/source/stash.cc b/crawl-ref/source/stash.cc index 86dc1c27d4..962883da9d 100644 --- a/crawl-ref/source/stash.cc +++ b/crawl-ref/source/stash.cc @@ -1365,20 +1365,32 @@ void StashTracker::update_visible_stashes( static std::string lastsearch; static input_history search_history(15); +void StashTracker::show_stash_search_prompt() +{ + std::vector<std::string> opts; + if (!lastsearch.empty()) + opts.push_back( + make_stringf("Enter for \"%s\"", lastsearch.c_str()) ); + if (level_type_is_stash_trackable(you.level_type) + && lastsearch != ".") + { + opts.push_back( + make_stringf("press . for all items on level")); + } + + std::string prompt_qual = + comma_separated_line(opts.begin(), opts.end(), ", or ", ", or "); + + if (!prompt_qual.empty()) + prompt_qual = " [" + prompt_qual + "]"; + + mprf(MSGCH_PROMPT, "Search for what%s?\n", prompt_qual.c_str()); +} + void StashTracker::search_stashes() { - char prompt[200]; - if (lastsearch.length()) - snprintf(prompt, sizeof prompt, - "Search for what [Enter for \"%s\"%s]?\n", - lastsearch.c_str(), lastsearch != "." ? - ", or press . for all items on level" : ""); - else - snprintf(prompt, sizeof prompt, - "Search for what [Press . for all items on level]?\n"); + show_stash_search_prompt(); - mpr(prompt, MSGCH_PROMPT); - char buf[400]; bool validline = !cancelable_get_line(buf, sizeof buf, 80, &search_history); @@ -1392,25 +1404,22 @@ void StashTracker::search_stashes() if (csearch == ".") { - if (you.level_type == LEVEL_DUNGEON) - { - snprintf(info, INFO_SIZE, "%s:%d", - branches[you.where_are_you].abbrevname, player_branch_depth()); - csearch = info; - } - else if (you.level_type == LEVEL_PORTAL_VAULT) - csearch = "{Port}"; - else if (you.level_type == LEVEL_PANDEMONIUM) - csearch = "{Pan}"; - // items in Abyss and Labyrinths are not tracked - else if (you.level_type == LEVEL_ABYSS - || you.level_type == LEVEL_LABYRINTH) + if (!level_type_is_stash_trackable(you.level_type)) { - mprf("Items in %s cannot be tracked.", - you.level_type == LEVEL_ABYSS ? "the Abyss" : "labyrinths"); - return; + mpr("Cannot track items on this level."); + return; } +#if defined(REGEX_PCRE) || defined(REGEX_POSIX) +#define RE_ESCAPE "\\" +#else +#define RE_ESCAPE "" +#endif + + csearch = (RE_ESCAPE "{") + + level_id::current().describe() + + (RE_ESCAPE "}"); } + std::vector<stash_search_result> results; base_pattern *search = NULL; |