tweaks: elide a small function, as it's in fact needed just once

master
Benno Schulenberg 2020-01-17 18:51:30 +01:00
parent c4939c76a5
commit 7567a67cdd
1 changed files with 8 additions and 16 deletions

View File

@ -278,18 +278,6 @@ void put_back(int keycode)
*key_buffer = 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 #ifdef ENABLE_NANORC
/* Insert the given string into the keyboard buffer. */ /* Insert the given string into the keyboard buffer. */
void implant(const char *string) 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. */ /* And put the corresponding key into the keyboard buffer. */
if (f != NULL) { if (f != NULL) {
const keystruct *s = first_sc_for(currmenu, f->func); 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; return 1;
} else } 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); 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 keycode = (mevent.bstate & BUTTON4_PRESSED) ? KEY_UP : KEY_DOWN;
/* One roll of the mouse wheel should move three lines. */ /* One roll of the mouse wheel should move three lines. */
for (int count = 1; count <= 3; count++) for (int count = 3; count > 0; count--)
stuff_into_keybuffer((mevent.bstate & BUTTON4_PRESSED) ? put_back(keycode);
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