mirror of
https://github.com/jarun/nnn.git
synced 2025-01-10 09:59:56 +00:00
Support mouse scroll
This is limited to libncurses support of full mouse scrolling. Ref: https://invisible-island.net/ncurses/man/curs_mouse.3x.html#h3-Mouse-events
This commit is contained in:
parent
beabe62467
commit
9b0cf4a2b9
22
src/nnn.c
22
src/nnn.c
|
@ -911,7 +911,12 @@ static bool initcurses(void)
|
||||||
nonl();
|
nonl();
|
||||||
//intrflush(stdscr, FALSE);
|
//intrflush(stdscr, FALSE);
|
||||||
keypad(stdscr, TRUE);
|
keypad(stdscr, TRUE);
|
||||||
|
#if NCURSES_MOUSE_VERSION <= 1
|
||||||
mousemask(BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED | BUTTON2_CLICKED, NULL);
|
mousemask(BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED | BUTTON2_CLICKED, NULL);
|
||||||
|
#else
|
||||||
|
mousemask(BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED | BUTTON2_CLICKED
|
||||||
|
| BUTTON4_PRESSED | BUTTON5_PRESSED, NULL);
|
||||||
|
#endif
|
||||||
mouseinterval(400);
|
mouseinterval(400);
|
||||||
curs_set(FALSE); /* Hide cursor */
|
curs_set(FALSE); /* Hide cursor */
|
||||||
start_color();
|
start_color();
|
||||||
|
@ -3355,6 +3360,23 @@ nochange:
|
||||||
goto begin;
|
goto begin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if NCURSES_MOUSE_VERSION > 1
|
||||||
|
if (event.bstate == BUTTON4_PRESSED || event.bstate == BUTTON5_PRESSED)
|
||||||
|
{
|
||||||
|
/* Scroll up */
|
||||||
|
if (event.bstate == BUTTON4_PRESSED && ndents) {
|
||||||
|
move_cursor((cur + ndents - 1) % ndents, 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Scroll down */
|
||||||
|
if (event.bstate == BUTTON5_PRESSED && ndents) {
|
||||||
|
move_cursor((cur + 1) % ndents, 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Handle clicking on a context at the top:
|
// Handle clicking on a context at the top:
|
||||||
if (event.y == 0) {
|
if (event.y == 0) {
|
||||||
// Get context from: "[1 2 3 4]..."
|
// Get context from: "[1 2 3 4]..."
|
||||||
|
|
Loading…
Reference in a new issue