commit 7567a67cdd225ebe6973d8b97883ed46bd12dbc8
parent c4939c76a520a5a8eb8b6bb007ca999334f88255
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Fri, 17 Jan 2020 18:51:30 +0100
tweaks: elide a small function, as it's in fact needed just once
Diffstat:
1 file changed, 8 insertions(+), 16 deletions(-)
diff --git a/src/winio.c b/src/winio.c
@@ -278,18 +278,6 @@ void put_back(int keycode)
*key_buffer = keycode;
}
-#ifdef ENABLE_MOUSE
-/* Insert the given keycode at the start of the keyboard buffer. If it
- * is a Meta key, also insert an Escape character in front of it. */
-void stuff_into_keybuffer(int keycode, bool is_metakey)
-{
- put_back(keycode);
-
- if (is_metakey)
- put_back(ESC_CODE);
-}
-#endif
-
#ifdef ENABLE_NANORC
/* Insert the given string into the keyboard buffer. */
void implant(const char *string)
@@ -1702,7 +1690,9 @@ int get_mouseinput(int *mouse_y, int *mouse_x, bool allow_shortcuts)
/* And put the corresponding key into the keyboard buffer. */
if (f != NULL) {
const keystruct *s = first_sc_for(currmenu, f->func);
- stuff_into_keybuffer(s->keycode, s->meta);
+ put_back(s->keycode);
+ if (s->meta)
+ put_back(ESC_CODE);
}
return 1;
} else
@@ -1721,10 +1711,12 @@ int get_mouseinput(int *mouse_y, int *mouse_x, bool allow_shortcuts)
wmouse_trafo(bottomwin, mouse_y, mouse_x, FALSE);
if (in_edit || (in_bottomwin && *mouse_y == 0)) {
+ int keycode = (mevent.bstate & BUTTON4_PRESSED) ? KEY_UP : KEY_DOWN;
+
/* One roll of the mouse wheel should move three lines. */
- for (int count = 1; count <= 3; count++)
- stuff_into_keybuffer((mevent.bstate & BUTTON4_PRESSED) ?
- KEY_UP : KEY_DOWN, FALSE);
+ for (int count = 3; count > 0; count--)
+ put_back(keycode);
+
return 1;
} else
/* Ignore presses of the fourth and fifth mouse buttons