MCPcopy Create free account
hub / github.com/NetHack/NetHack / invert_all

Function invert_all

win/tty/wintty.c:1269–1311  ·  view source on GitHub ↗

invert all entries that match given group accelerator (or all if zero) */

Source from the content-addressed store, hash-verified

1267
1268/* invert all entries that match given group accelerator (or all if zero) */
1269static void
1270invert_all(
1271 winid window,
1272 tty_menu_item *page_start,
1273 tty_menu_item *page_end,
1274 char acc, /* group accelerator, 0 => all */
1275 long count) /* pending count; -1L for non-group toggling */
1276{
1277 tty_menu_item *curr;
1278 boolean on_curr_page;
1279 struct WinDesc *cw = wins[window];
1280
1281 /* handle current page separately (it will need screen updating) */
1282 invert_all_on_page(window, page_start, page_end, acc, count);
1283
1284 /* invert the rest (no screen updating for them) */
1285 for (on_curr_page = FALSE, curr = cw->mlist; curr; curr = curr->next) {
1286 if (curr == page_start)
1287 on_curr_page = TRUE;
1288 else if (curr == page_end)
1289 on_curr_page = FALSE;
1290
1291 /* skip if on current page (already handled above) or not
1292 selectable (header line or similar) or if group toggling
1293 is taking place and this item isn't in specified group or
1294 group toggling is not taking place and this item is off
1295 limits to bulk toggling (assumes that an item won't be
1296 both in a group and also subject to bulk restrictions) */
1297 if (on_curr_page || !curr->identifier.a_void
1298 || (acc ? curr->gselector != acc
1299 : !menuitem_invert_test(0, curr->itemflags, curr->selected)))
1300 continue;
1301
1302 if (curr->selected) {
1303 curr->selected = FALSE;
1304 curr->count = -1;
1305 } else {
1306 curr->selected = TRUE;
1307 if (count > 0)
1308 curr->count = count;
1309 }
1310 }
1311}
1312
1313/* support menucolor in addition to caller-supplied attribute */
1314static void

Callers 1

process_menu_windowFunction · 0.70

Calls 2

menuitem_invert_testFunction · 0.85
invert_all_on_pageFunction · 0.70

Tested by

no test coverage detected