From 8cddd28e195a0d4e85287f28dad5290126691649 Mon Sep 17 00:00:00 2001 From: Jari Vetoniemi Date: Fri, 19 Jul 2024 12:46:44 +0900 Subject: [PATCH] menu: reversed page up / page down on up list mode --- lib/menu.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/lib/menu.c b/lib/menu.c index a9f4fd5..741d782 100644 --- a/lib/menu.c +++ b/lib/menu.c @@ -1084,19 +1084,35 @@ bm_menu_run_with_key(struct bm_menu *menu, enum bm_key key, uint32_t unicode) break; case BM_KEY_PAGE_UP: - bm_menu_set_highlighted_index(menu, (menu->index < displayed ? 0 : menu->index - (displayed - 1))); + if (menu->lines_mode == BM_LINES_UP) { + bm_menu_set_highlighted_index(menu, (menu->index + displayed >= count ? count - 1 : menu->index + (displayed - 1))); + } else { + bm_menu_set_highlighted_index(menu, (menu->index < displayed ? 0 : menu->index - (displayed - 1))); + } break; case BM_KEY_PAGE_DOWN: - bm_menu_set_highlighted_index(menu, (menu->index + displayed >= count ? count - 1 : menu->index + (displayed - 1))); + if (menu->lines_mode == BM_LINES_UP) { + bm_menu_set_highlighted_index(menu, (menu->index < displayed ? 0 : menu->index - (displayed - 1))); + } else { + bm_menu_set_highlighted_index(menu, (menu->index + displayed >= count ? count - 1 : menu->index + (displayed - 1))); + } break; case BM_KEY_SHIFT_PAGE_UP: - bm_menu_set_highlighted_index(menu, 0); + if (menu->lines_mode == BM_LINES_UP) { + bm_menu_set_highlighted_index(menu, count - 1); + } else { + bm_menu_set_highlighted_index(menu, 0); + } break; case BM_KEY_SHIFT_PAGE_DOWN: - bm_menu_set_highlighted_index(menu, count - 1); + if (menu->lines_mode == BM_LINES_UP) { + bm_menu_set_highlighted_index(menu, 0); + } else { + bm_menu_set_highlighted_index(menu, count - 1); + } break; case BM_KEY_BACKSPACE: