From cd00d0975edc869128081f6dfff1f3af95ac934c Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Fri, 27 Sep 2019 18:49:39 +0200 Subject: [PATCH] tweaks: move a fragment of common code into the appropriate function --- src/global.c | 5 ++++- src/winio.c | 9 ++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/global.c b/src/global.c index 9bdbc0d0..17ca5a60 100644 --- a/src/global.c +++ b/src/global.c @@ -438,7 +438,10 @@ size_t length_of_list(int menu) if ((f->menus & menu) && first_sc_for(menu, f->func) != NULL) i++; - return i; + if (i > MAIN_VISIBLE) + return MAIN_VISIBLE; + else + return i; } /* Return the shortcut that corresponds to the values of kbinput (the diff --git a/src/winio.c b/src/winio.c index 917233c1..d5e29bc3 100644 --- a/src/winio.c +++ b/src/winio.c @@ -1695,10 +1695,8 @@ int get_mouseinput(int *mouse_y, int *mouse_x, bool allow_shortcuts) return 0; } - /* Determine how many shortcuts will be shown. */ + /* Determine how many shortcuts are being shown. */ number = length_of_list(currmenu); - if (number > MAIN_VISIBLE) - number = MAIN_VISIBLE; /* Calculate the width of each non-rightmost shortcut item; * the rightmost ones will "absorb" any remaining slack. */ @@ -2294,12 +2292,9 @@ void bottombars(int menu) if (ISSET(NO_HELP) || LINES < 5) return; - /* Determine how many shortcuts there are to show. */ + /* Determine how many shortcuts must be shown. */ number = length_of_list(menu); - if (number > MAIN_VISIBLE) - number = MAIN_VISIBLE; - /* Compute the width of each keyname-plus-explanation pair. */ itemwidth = COLS / ((number / 2) + (number % 2));