From 79b728ec3b58721a1cad10f26f3f1d8fb259a254 Mon Sep 17 00:00:00 2001 From: haranp Date: Mon, 2 Jul 2007 14:14:55 +0000 Subject: 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 --- crawl-ref/source/menu.cc | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'crawl-ref/source/menu.cc') 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; -- cgit v1.2.3-54-g00ecf