diff options
author | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-01-26 07:31:00 +0000 |
---|---|---|
committer | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-01-26 07:31:00 +0000 |
commit | aa300c86ccbb1cffa03ee8f6e0dca0e6ef48cef6 (patch) | |
tree | 026a78d32326ca88f029ddc0949b799e39317f3c /crawl-ref/source/stash.cc | |
parent | 32a6373c7a8072bfcb4567417f82f700084b6ab8 (diff) | |
download | crawl-ref-aa300c86ccbb1cffa03ee8f6e0dca0e6ef48cef6.tar.gz crawl-ref-aa300c86ccbb1cffa03ee8f6e0dca0e6ef48cef6.zip |
Added help for stash-search (dpeg).
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3338 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/stash.cc')
-rw-r--r-- | crawl-ref/source/stash.cc | 53 |
1 files changed, 47 insertions, 6 deletions
diff --git a/crawl-ref/source/stash.cc b/crawl-ref/source/stash.cc index 815146bb95..6e002ca209 100644 --- a/crawl-ref/source/stash.cc +++ b/crawl-ref/source/stash.cc @@ -11,6 +11,7 @@ #include "chardump.h" #include "cio.h" #include "clua.h" +#include "command.h" #include "describe.h" #include "direct.h" #include "food.h" @@ -1360,8 +1361,7 @@ void StashTracker::show_stash_search_prompt() if (level_type_is_stash_trackable(you.level_type) && lastsearch != ".") { - opts.push_back( - make_stringf("press . for all items on level")); + opts.push_back("? for help"); } std::string prompt_qual = @@ -1373,13 +1373,54 @@ void StashTracker::show_stash_search_prompt() mprf(MSGCH_PROMPT, "Search for what%s?\n", prompt_qual.c_str()); } +class stash_search_reader : public line_reader +{ +public: + stash_search_reader(char *buf, size_t sz, + int wcol = get_number_of_cols()) + : line_reader(buf, sz, wcol) + { + } +protected: + int process_key(int ch) + { + if (ch == '?' && !pos) + { + *buffer = 0; + return (ch); + } + return line_reader::process_key(ch); + } +}; + void StashTracker::search_stashes() { - show_stash_search_prompt(); - char buf[400]; - bool validline = - !cancelable_get_line(buf, sizeof buf, 80, &search_history); + + stash_search_reader reader(buf, sizeof buf); + + bool validline = false; + while (true) + { + show_stash_search_prompt(); + + int ret = reader.read_line(); + if (!ret) + { + validline = true; + break; + } + else if (ret == '?') + { + show_stash_search_help(); + redraw_screen(); + } + else + { + break; + } + } + mesclr(); if (!validline || (!*buf && !lastsearch.length())) return; |