nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 78def852d1ffb84a1f4712a182a11511f80bb3ee
parent a4933873c9e1ab4718ab24737cadc0be71d608cd
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Tue,  1 Oct 2019 12:29:02 +0200

mouse: make the clickable width of menu items more consistent

When there are fewer than four menu items, act as if there are four:
make their clickable width half the width of the screen.

Until now, when there were two menu items, their clickable width would
be the full width of the screen, which was overwide.  But when there
was just one menu item, its clickable width would suddenly be as small
as when the menu had the maximum number of items (12 for an 80-column
screen).  This was odd.

Also, slightly simplify another computation.

Diffstat:
Msrc/winio.c | 9++++-----
1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/winio.c b/src/winio.c @@ -1694,12 +1694,11 @@ int get_mouseinput(int *mouse_y, int *mouse_x, bool allow_shortcuts) /* Determine how many shortcuts are being shown. */ number = shown_entries_for(currmenu); - /* Calculate the width of each non-rightmost shortcut item; - * the rightmost ones will "absorb" any remaining slack. */ - if (number < 2) - width = COLS / (MAIN_VISIBLE / 2); + /* Calculate the clickable width of each menu item. */ + if (number < 5) + width = COLS / 2; else - width = COLS / ((number / 2) + (number % 2)); + width = COLS / ((number + 1) / 2); /* Calculate the one-based index in the shortcut list. */ index = (*mouse_x / width) * 2 + *mouse_y;