summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-07-02 14:14:55 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-07-02 14:14:55 +0000
commit79b728ec3b58721a1cad10f26f3f1d8fb259a254 (patch)
treebad60f665a5fa04c24d533a02513eb23c82decc0 /crawl-ref
parentd6998c47fdd4ff96f59b234b063291ccdf546612 (diff)
downloadcrawl-ref-79b728ec3b58721a1cad10f26f3f1d8fb259a254.tar.gz
crawl-ref-79b728ec3b58721a1cad10f26f3f1d8fb259a254.zip
Drop and pickup menus now support Ctrl-F to select all items matching a regex.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1716 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/invent.cc5
-rw-r--r--crawl-ref/source/menu.cc34
-rw-r--r--crawl-ref/source/menu.h2
3 files changed, 39 insertions, 2 deletions
diff --git a/crawl-ref/source/invent.cc b/crawl-ref/source/invent.cc
index a416f411c4..d92a1a467e 100644
--- a/crawl-ref/source/invent.cc
+++ b/crawl-ref/source/invent.cc
@@ -602,7 +602,8 @@ std::vector<SelItem> select_items( const std::vector<const item_def*> &items,
menu.set_type(mtype);
menu.set_title(title);
menu.load_items(items);
- menu.set_flags(noselect ? MF_NOSELECT : MF_MULTISELECT);
+ menu.set_flags(noselect ? MF_NOSELECT :
+ MF_MULTISELECT | MF_ALLOW_FILTER);
menu.show();
selected = menu.get_selitems();
}
@@ -792,7 +793,7 @@ std::vector<SelItem> prompt_invent_items(
Options.drop_mode == DM_SINGLE
&& (!pre_select || pre_select->empty())?
MF_SINGLESELECT | MF_EASY_EXIT | MF_ANYPRINTABLE :
- MF_MULTISELECT;
+ MF_MULTISELECT | MF_ALLOW_FILTER;
// The "view inventory listing" mode.
int ch = invent_select(
prompt,
diff --git a/crawl-ref/source/menu.cc b/crawl-ref/source/menu.cc
index 85f596b1db..10573e0f6e 100644
--- a/crawl-ref/source/menu.cc
+++ b/crawl-ref/source/menu.cc
@@ -207,6 +207,40 @@ bool Menu::process_key( int keyin )
}
break;
}
+ case CONTROL('F'):
+ {
+ if ( !( flags & MF_ALLOW_FILTER ) )
+ break;
+ char linebuf[80];
+ gotoxy(1,1);
+ clear_to_end_of_line();
+ textcolor(WHITE);
+ cprintf("Select what? (regex) ");
+ textcolor(DARKGREY);
+ bool validline = !cancelable_get_line(linebuf, sizeof linebuf, 80);
+ if ( validline && linebuf[0] )
+ {
+ text_pattern tpat(linebuf);
+ for ( unsigned int i = 0; i < items.size(); ++i )
+ {
+ if ( items[i]->level == MEL_ITEM &&
+ tpat.matches(items[i]->get_text()) )
+ {
+ select_index(i);
+ if ( flags & MF_SINGLESELECT )
+ {
+ // Return the first item found.
+ get_selected(&sel);
+ return false;
+ }
+ }
+ }
+ get_selected(&sel);
+ }
+ nav = true;
+ repaint = true;
+ break;
+ }
default:
keyin = post_process(keyin);
lastch = keyin;
diff --git a/crawl-ref/source/menu.h b/crawl-ref/source/menu.h
index cfe710efd5..6ee0a1551e 100644
--- a/crawl-ref/source/menu.h
+++ b/crawl-ref/source/menu.h
@@ -152,6 +152,8 @@ enum MenuFlag
MF_ALWAYS_SHOW_MORE = 0x0020, // Always show the -more- footer
MF_NOWRAP = 0x0040, // Paging past the end will not wrap back.
+ MF_ALLOW_FILTER = 0x0080, // Control-F will ask for regex and
+ // select the appropriate items.
MF_EASY_EXIT = 0x1000
};