fix #H7840 - curses ':' menu search+toggle

Using ':' to have search string matching toggle items chosen for
selection would show selection highlighting on the current page for
items matched off-page.
This commit is contained in:
PatR
2019-06-24 19:28:50 -07:00
parent 8a9c06f5c1
commit 6506f769a6
2 changed files with 39 additions and 24 deletions

View File

@@ -1,4 +1,4 @@
$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.68 $ $NHDT-Date: 1561427671 2019/06/25 01:54:31 $
$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.69 $ $NHDT-Date: 1561429723 2019/06/25 02:28:43 $
This fixes36.3 file is here to capture information about updates in the 3.6.x
lineage following the release of 3.6.2 in May 2019. Please note, however,
@@ -145,6 +145,9 @@ curses: don't convert ^M (or <return> or <enter> key) into ^J; both ^J and ^M
cause the hero to try to move
curses: draw map in screen columns 1..79 like tty, rather than in 2..80
curses: make text windows wider so that help feedback is more readable
curses: using ':' for search string matching to toggle menu items in a multple
page menu would highlight arbitrary items on the currently visible
page in sync with the lines that matching items had on other pages
curses+'perm_invent': entries were wrapping without any control; usually not
noticeable because next entry overwrote, but visible for final entry
when whole inventory fit within the available height; looked ok with

View File

@@ -101,7 +101,7 @@ static void menu_display_page(nhmenu *menu, WINDOW * win, int page_num,
char *);
static int menu_get_selections(WINDOW * win, nhmenu *menu, int how);
static void menu_select_deselect(WINDOW * win, nhmenu_item *item,
menu_op operation);
menu_op operation, int);
static int menu_operation(WINDOW * win, nhmenu *menu, menu_op operation,
int page_num);
static void menu_clear_selections(nhmenu *menu);
@@ -1257,7 +1257,6 @@ menu_get_selections(WINDOW * win, nhmenu *menu, int how)
num_selected = -1;
} else {
num_selected = 0;
}
dismiss = TRUE;
break;
@@ -1361,12 +1360,14 @@ menu_get_selections(WINDOW * win, nhmenu *menu, int how)
&& strstri(menu_item_ptr->str, search_key)) {
if (how == PICK_ONE) {
menu_clear_selections(menu);
menu_select_deselect(win, menu_item_ptr, SELECT);
menu_select_deselect(win, menu_item_ptr,
SELECT, curpage);
num_selected = 1;
dismiss = TRUE;
break;
} else {
menu_select_deselect(win, menu_item_ptr, INVERT);
menu_select_deselect(win, menu_item_ptr,
INVERT, curpage);
}
}
@@ -1399,19 +1400,22 @@ menu_get_selections(WINDOW * win, nhmenu *menu, int how)
if (how == PICK_ONE) {
menu_clear_selections(menu);
menu_select_deselect(win, menu_item_ptr, SELECT);
menu_select_deselect(win, menu_item_ptr,
SELECT, curpage);
if (count)
menu_item_ptr->count = count;
num_selected = 1;
dismiss = TRUE;
break;
} else if (how == PICK_ANY && curletter == count_letter) {
menu_select_deselect(win, menu_item_ptr, SELECT);
menu_select_deselect(win, menu_item_ptr,
SELECT, curpage);
menu_item_ptr->count = count;
count = 0;
count_letter = '\0';
} else {
menu_select_deselect(win, menu_item_ptr, INVERT);
menu_select_deselect(win, menu_item_ptr,
INVERT, curpage);
}
}
}
@@ -1437,30 +1441,38 @@ menu_get_selections(WINDOW * win, nhmenu *menu, int how)
}
/* Select, deselect, or toggle selected for the given menu entry */
/* Select, deselect, or toggle selected for the given menu entry.
For search operations, the toggled entry might be on a different
page than the one currently shown. */
static void
menu_select_deselect(WINDOW * win, nhmenu_item *item, menu_op operation)
menu_select_deselect(WINDOW *win, nhmenu_item *item,
menu_op operation, int current_page)
{
int curletter = item->accelerator;
boolean visible = (item->page_num == current_page);
if ((operation == DESELECT) || (item->selected && (operation == INVERT))) {
if (operation == DESELECT || (item->selected && operation == INVERT)) {
item->selected = FALSE;
mvwaddch(win, item->line_num + 1, 1, ' ');
curses_toggle_color_attr(win, HIGHLIGHT_COLOR, NONE, ON);
mvwaddch(win, item->line_num + 1, 2, curletter);
curses_toggle_color_attr(win, HIGHLIGHT_COLOR, NONE, OFF);
mvwaddch(win, item->line_num + 1, 3, ')');
if (visible) {
mvwaddch(win, item->line_num + 1, 1, ' ');
curses_toggle_color_attr(win, HIGHLIGHT_COLOR, NONE, ON);
mvwaddch(win, item->line_num + 1, 2, curletter);
curses_toggle_color_attr(win, HIGHLIGHT_COLOR, NONE, OFF);
mvwaddch(win, item->line_num + 1, 3, ')');
}
} else {
item->selected = TRUE;
curses_toggle_color_attr(win, HIGHLIGHT_COLOR, A_REVERSE, ON);
mvwaddch(win, item->line_num + 1, 1, '<');
mvwaddch(win, item->line_num + 1, 2, curletter);
mvwaddch(win, item->line_num + 1, 3, '>');
curses_toggle_color_attr(win, HIGHLIGHT_COLOR, A_REVERSE, OFF);
if (visible) {
curses_toggle_color_attr(win, HIGHLIGHT_COLOR, A_REVERSE, ON);
mvwaddch(win, item->line_num + 1, 1, '<');
mvwaddch(win, item->line_num + 1, 2, curletter);
mvwaddch(win, item->line_num + 1, 3, '>');
curses_toggle_color_attr(win, HIGHLIGHT_COLOR, A_REVERSE, OFF);
}
}
wrefresh(win);
if (visible)
wrefresh(win);
}
@@ -1513,7 +1525,7 @@ menu_operation(WINDOW * win, nhmenu *menu, menu_op
}
if (menu_item_ptr->identifier.a_void != NULL) {
menu_select_deselect(win, menu_item_ptr, operation);
menu_select_deselect(win, menu_item_ptr, operation, current_page);
}
menu_item_ptr = menu_item_ptr->next_item;