-/* NetHack 3.5 winmenu.c $NHDT-Date: 1427881480 2015/04/01 09:44:40 $ $NHDT-Branch: master $:$NHDT-Revision: 1.5 $ */
+/* NetHack 3.5 winmenu.c $NHDT-Date: 1428828477 2015/04/12 08:47:57 $ $NHDT-Branch: master $:$NHDT-Revision: 1.7 $ */
/* NetHack 3.5 winmenu.c $Date: 2009/05/06 10:55:53 $ $Revision: 1.5 $ */
/* SCCS Id: @(#)winmenu.c 3.5 1996/08/15 */
/* Copyright (c) Dean Luick, 1992 */
return;
} else if (ch == MENU_SEARCH) { /* search */
if (menu_info->how == PICK_ANY || menu_info->how == PICK_ONE) {
- char buf[BUFSZ];
- X11_getlin("Search for:", buf);
- if (!*buf || *buf == '\033') return;
+ char buf[BUFSZ+2], tmpbuf[BUFSZ];
+
+ X11_getlin("Search for:", tmpbuf);
+ if (!*tmpbuf || *tmpbuf == '\033') return;
+ /* convert "string" into "*string*" for use with pmatch() */
+ Sprintf(buf, "*%s*", tmpbuf);
+
if (menu_info->how == PICK_ANY) {
invert_match(wp, buf);
return;
{
struct xwindow *wp = (struct xwindow *) client_data;
struct menu_info_t *menu_info = wp->menu_information;
+ char buf[BUFSZ+2], tmpbuf[BUFSZ];
- char buf[BUFSZ];
- X11_getlin("Search for:", buf);
- if (!*buf || *buf == '\033') return;
+ X11_getlin("Search for:", tmpbuf);
+ if (!*tmpbuf || *tmpbuf == '\033') return;
+ /* convert "string" into "*string*" for use with pmatch() */
+ Sprintf(buf, "*%s*", tmpbuf);
if (menu_info->how == PICK_ANY)
invert_match(wp, buf);
static void
invert_match(wp, match)
struct xwindow *wp;
- char *match;
+ char *match; /* wildcard pattern for pmatch() */
{
x11_menu_item *curr;
int count;
reset_menu_count(wp->menu_information);
for (count = 0, curr = wp->menu_information->curr_menu.base; curr;
curr = curr->next, count++)
- if (curr->identifier.a_void != 0 && strstri(curr->str, match)) {
+ if (curr->identifier.a_void != 0 && pmatchi(match, curr->str)) {
invert_line(wp, curr, count, -1L);
changed = TRUE;
}
static void
select_match(wp, match)
struct xwindow *wp;
- char *match;
+ char *match; /* wildcard pattern for pmatch() */
{
x11_menu_item *curr;
int count;
reset_menu_count(wp->menu_information);
for (count = 0, curr = wp->menu_information->curr_menu.base; curr;
curr = curr->next, count++)
- if (curr->identifier.a_void != 0 && strstri(curr->str, match)) {
+ if (curr->identifier.a_void != 0 && pmatchi(match, curr->str)) {
if (!curr->selected) {
invert_line(wp, curr, count, -1L);
#ifndef USE_FWF
- XawListChange(wp->w, wp->menu_information->curr_menu.list_pointer,
+ XawListChange(wp->w,
+ wp->menu_information->curr_menu.list_pointer,
0, 0, True);
#endif
}
-/* NetHack 3.5 wintty.c $NHDT-Date: 1428394244 2015/04/07 08:10:44 $ $NHDT-Branch: master $:$NHDT-Revision: 1.84 $ */
+/* NetHack 3.5 wintty.c $NHDT-Date: 1428828474 2015/04/12 08:47:54 $ $NHDT-Branch: master $:$NHDT-Revision: 1.85 $ */
/* NetHack 3.5 wintty.c $Date: 2012/01/22 06:27:09 $ $Revision: 1.66 $ */
/* Copyright (c) David Cohrs, 1991 */
/* NetHack may be freely redistributed. See license for details. */
tty_nhbell();
break;
} else {
- char searchbuf[BUFSZ], tmpbuf[BUFSZ];
+ char searchbuf[BUFSZ+2], tmpbuf[BUFSZ];
boolean on_curr_page = FALSE;
int lineno = 0;
+
tty_getlin("Search for:", tmpbuf);
if (!tmpbuf[0] || tmpbuf[0] == '\033') break;
Sprintf(searchbuf, "*%s*", tmpbuf);
+
for (curr = cw->mlist; curr; curr = curr->next) {
if (on_curr_page) lineno++;
if (curr == page_start)
on_curr_page = TRUE;
else if (curr == page_end)
on_curr_page = FALSE;
- if (curr->identifier.a_void && pmatch(searchbuf, curr->str)) {
- toggle_menu_curr(window, curr, lineno, on_curr_page, counting, count);
+ if (curr->identifier.a_void
+ && pmatchi(searchbuf, curr->str)) {
+ toggle_menu_curr(window, curr, lineno,
+ on_curr_page, counting, count);
if (cw->how == PICK_ONE) {
finished = TRUE;
break;