| 1699 | all pages in menu. Returns last page displayed. */ |
| 1700 | |
| 1701 | static int |
| 1702 | menu_operation( |
| 1703 | WINDOW *win, |
| 1704 | nhmenu *menu, |
| 1705 | menu_op operation, |
| 1706 | int page_num) |
| 1707 | { |
| 1708 | int first_page, last_page, current_page; |
| 1709 | nhmenu_item *menu_item_ptr = menu->entries; |
| 1710 | |
| 1711 | if (page_num == 0) { /* Operation to occur on all pages */ |
| 1712 | first_page = 1; |
| 1713 | last_page = menu->num_pages; |
| 1714 | } else { |
| 1715 | first_page = page_num; |
| 1716 | last_page = page_num; |
| 1717 | } |
| 1718 | |
| 1719 | /* Cycle through entries until we are on the correct page */ |
| 1720 | while (menu_item_ptr != NULL) { |
| 1721 | if (menu_item_ptr->page_num == first_page) { |
| 1722 | break; |
| 1723 | } |
| 1724 | menu_item_ptr = menu_item_ptr->next_item; |
| 1725 | } |
| 1726 | |
| 1727 | current_page = first_page; |
| 1728 | |
| 1729 | if (page_num == 0) { |
| 1730 | menu_display_page(win, menu, current_page, (char *) 0, (char *) 0); |
| 1731 | } |
| 1732 | |
| 1733 | if (menu_item_ptr == NULL) { /* Page not found */ |
| 1734 | impossible("menu_display_page: attempt to display nonexistent page"); |
| 1735 | return 0; |
| 1736 | } |
| 1737 | |
| 1738 | while (menu_item_ptr != NULL) { |
| 1739 | if (menu_item_ptr->page_num != current_page) { |
| 1740 | if (menu_item_ptr->page_num > last_page) { |
| 1741 | break; |
| 1742 | } |
| 1743 | |
| 1744 | current_page = menu_item_ptr->page_num; |
| 1745 | menu_display_page(win, menu, current_page, (char *) 0, (char *) 0); |
| 1746 | } |
| 1747 | |
| 1748 | if (menu_item_ptr->identifier.a_void != NULL) { |
| 1749 | if (menuitem_invert_test(((operation == INVERT) ? 0 |
| 1750 | : (operation == SELECT) ? 1 : 2), |
| 1751 | menu_item_ptr->itemflags, |
| 1752 | menu_item_ptr->selected)) |
| 1753 | menu_select_deselect(win, menu_item_ptr, |
| 1754 | operation, current_page); |
| 1755 | } |
| 1756 | |
| 1757 | menu_item_ptr = menu_item_ptr->next_item; |
| 1758 | } |
no test coverage detected