tweaks: word some comments more concisely

master
Benno Schulenberg 2018-12-30 21:27:04 +01:00
parent 0e9fb6a0da
commit 15320d3b96
1 changed files with 14 additions and 27 deletions

View File

@ -1673,37 +1673,30 @@ int get_mouseinput(int *mouse_y, int *mouse_x, bool allow_shortcuts)
* back the equivalent keystroke(s) for it. */ * back the equivalent keystroke(s) for it. */
if (allow_shortcuts && !ISSET(NO_HELP) && in_bottomwin) { if (allow_shortcuts && !ISSET(NO_HELP) && in_bottomwin) {
int width; int width;
/* The width of all the shortcuts, except for the last /* The width of each shortcut item, except the last two. */
* two, in the shortcut list in bottomwin. */
int index; int index;
/* The calculated index number of the clicked item. */ /* The calculated index of the clicked item. */
size_t number; size_t number;
/* The number of available shortcuts in the current menu. */ /* The number of shortcut items that get displayed. */
/* Translate the mouse event coordinates so that they're /* Translate the coordinates to become relative to bottomwin. */
* relative to bottomwin. */
wmouse_trafo(bottomwin, mouse_y, mouse_x, FALSE); wmouse_trafo(bottomwin, mouse_y, mouse_x, FALSE);
/* Handle releases/clicks of the first mouse button on the /* Clicks on the status bar are handled elsewhere, so
* statusbar elsewhere. */ * restore the untranslated mouse-event coordinates. */
if (*mouse_y == 0) { if (*mouse_y == 0) {
/* Restore the untranslated mouse event coordinates, so
* that they're relative to the entire screen again. */
*mouse_x = mevent.x - margin; *mouse_x = mevent.x - margin;
*mouse_y = mevent.y; *mouse_y = mevent.y;
return 0; return 0;
} }
/* Determine how many shortcuts are being shown. */ /* Determine how many shortcuts will be shown. */
number = length_of_list(currmenu); number = length_of_list(currmenu);
if (number > MAIN_VISIBLE) if (number > MAIN_VISIBLE)
number = MAIN_VISIBLE; number = MAIN_VISIBLE;
/* Calculate the width of all of the shortcuts in the list /* Calculate the width of each non-rightmost shortcut item;
* except for the last two, which are longer by (COLS % width) * the rightmost ones will "absorb" any remaining slack. */
* columns so as to not waste space. */
if (number < 2) if (number < 2)
width = COLS / (MAIN_VISIBLE / 2); width = COLS / (MAIN_VISIBLE / 2);
else else
@ -1716,13 +1709,12 @@ int get_mouseinput(int *mouse_y, int *mouse_x, bool allow_shortcuts)
if ((index > number) && (*mouse_x % width < COLS % width)) if ((index > number) && (*mouse_x % width < COLS % width))
index -= 2; index -= 2;
/* Ignore releases/clicks of the first mouse button beyond /* Ignore clicks beyond the last shortcut. */
* the last shortcut. */
if (index > number) if (index > number)
return 2; return 2;
/* Go through the list of functions to determine which /* Go through the list of functions to determine which
* shortcut in the current menu we released/clicked on. */ * shortcut in the current menu we clicked/released on. */
for (f = allfuncs; f != NULL; f = f->next) { for (f = allfuncs; f != NULL; f = f->next) {
if ((f->menus & currmenu) == 0) if ((f->menus & currmenu) == 0)
continue; continue;
@ -1740,8 +1732,7 @@ int get_mouseinput(int *mouse_y, int *mouse_x, bool allow_shortcuts)
} }
return 1; return 1;
} else } else
/* Handle releases/clicks of the first mouse button that /* Clicks outside of bottomwin are handled elsewhere. */
* aren't on the current shortcut list elsewhere. */
return 0; return 0;
} }
#if NCURSES_MOUSE_VERSION >= 2 #if NCURSES_MOUSE_VERSION >= 2
@ -1752,18 +1743,14 @@ int get_mouseinput(int *mouse_y, int *mouse_x, bool allow_shortcuts)
bool in_edit = wenclose(edit, *mouse_y, *mouse_x); bool in_edit = wenclose(edit, *mouse_y, *mouse_x);
if (in_bottomwin) if (in_bottomwin)
/* Translate the mouse event coordinates so that they're /* Translate the coordinates to become relative to bottomwin. */
* relative to bottomwin. */
wmouse_trafo(bottomwin, mouse_y, mouse_x, FALSE); wmouse_trafo(bottomwin, mouse_y, mouse_x, FALSE);
if (in_edit || (in_bottomwin && *mouse_y == 0)) { if (in_edit || (in_bottomwin && *mouse_y == 0)) {
int i;
/* One roll of the mouse wheel should move three lines. */ /* One roll of the mouse wheel should move three lines. */
for (i = 0; i < 3; i++) for (int count = 1; count <= 3; count++)
unget_kbinput((mevent.bstate & BUTTON4_PRESSED) ? unget_kbinput((mevent.bstate & BUTTON4_PRESSED) ?
KEY_UP : KEY_DOWN, FALSE); KEY_UP : KEY_DOWN, FALSE);
return 1; return 1;
} else } else
/* Ignore presses of the fourth and fifth mouse buttons /* Ignore presses of the fourth and fifth mouse buttons