| 1385 | } |
| 1386 | |
| 1387 | string Menu::get_keyhelp(bool scrollable) const |
| 1388 | { |
| 1389 | // TODO: derive this from cmd key bindings |
| 1390 | |
| 1391 | // multiselect always shows a keyhelp, for singleselect it is blank unless |
| 1392 | // it can be scrolled |
| 1393 | if (!scrollable && !is_set(MF_MULTISELECT)) |
| 1394 | return ""; |
| 1395 | |
| 1396 | string navigation = "<lightgrey>"; |
| 1397 | if (is_set(MF_ARROWS_SELECT)) |
| 1398 | navigation += menu_keyhelp_select_keys() + " select "; |
| 1399 | |
| 1400 | if (scrollable) |
| 1401 | { |
| 1402 | navigation += |
| 1403 | menu_keyhelp_cmd(CMD_MENU_PAGE_DOWN) + " page down " |
| 1404 | + menu_keyhelp_cmd(CMD_MENU_PAGE_UP) + " page up "; |
| 1405 | } |
| 1406 | if (!is_set(MF_MULTISELECT)) |
| 1407 | navigation += menu_keyhelp_cmd(CMD_MENU_EXIT) + " exit"; |
| 1408 | navigation += "</lightgrey>"; |
| 1409 | if (is_set(MF_MULTISELECT)) |
| 1410 | { |
| 1411 | navigation = pad_more_with_esc(navigation); |
| 1412 | // XX this may not work perfectly with the way InvMenu handles |
| 1413 | // selection |
| 1414 | const auto chosen_count = selected_entries().size(); |
| 1415 | navigation += |
| 1416 | "\n<lightgrey>" |
| 1417 | "Letters toggle "; |
| 1418 | if (is_set(MF_ARROWS_SELECT)) |
| 1419 | { |
| 1420 | navigation += menu_keyhelp_cmd(CMD_MENU_TOGGLE_SELECTED) |
| 1421 | + " toggle selected "; |
| 1422 | } |
| 1423 | if (chosen_count) |
| 1424 | { |
| 1425 | navigation += menu_keyhelp_cmd(CMD_MENU_ACCEPT_SELECTION) |
| 1426 | + make_stringf( |
| 1427 | " accept (%zu chosen)" |
| 1428 | "</lightgrey>", |
| 1429 | chosen_count); |
| 1430 | } |
| 1431 | } |
| 1432 | // XX this is present on non-scrolling multiselect keyhelps mostly for |
| 1433 | // aesthetic reasons, but maybe it could change with hover? |
| 1434 | // the `XXX` is replaced in the ui code with a position in the scroll. |
| 1435 | return pad_more_with(navigation, "<lightgrey>[<w>XXX</w>]</lightgrey>"); |
| 1436 | } |
| 1437 | |
| 1438 | // use the class's built in keyhelp string |
| 1439 | void Menu::set_more() |
nothing calls this directly
no test coverage detected