Merge pull request #1824 from H3rnand3zzz/feature/mouse-scroll

Smooth scrolling support (+mouse wheel scrolling in some terminals)
This commit is contained in:
Michael Vetter
2023-12-05 12:25:41 +01:00
committed by GitHub
5 changed files with 60 additions and 21 deletions

View File

@@ -136,6 +136,7 @@ static int _inp_rl_subwin_pageup_handler(int count, int key);
static int _inp_rl_subwin_pagedown_handler(int count, int key);
static int _inp_rl_startup_hook(void);
static int _inp_rl_down_arrow_handler(int count, int key);
static int _inp_rl_scroll_handler(int count, int key);
static int _inp_rl_send_to_editor(int count, int key);
static int _inp_rl_print_newline_symbol(int count, int key);
@@ -555,6 +556,8 @@ _inp_rl_startup_hook(void)
rl_bind_key('\t', _inp_rl_tab_handler);
rl_bind_keyseq("\\e[Z", _inp_rl_shift_tab_handler);
rl_bind_keyseq("\\e[1;3A", _inp_rl_scroll_handler); // alt + scroll/arrow up
rl_bind_keyseq("\\e[1;3B", _inp_rl_scroll_handler); // alt + scroll/arrow down
rl_bind_keyseq("\\e[1;5B", _inp_rl_down_arrow_handler); // ctrl+arrow down
rl_bind_keyseq("\\eOb", _inp_rl_down_arrow_handler);
@@ -907,7 +910,7 @@ static int
_inp_rl_win_pageup_handler(int count, int key)
{
ProfWin* current = wins_get_current();
win_page_up(current);
win_page_up(current, 0);
return 0;
}
@@ -915,7 +918,7 @@ static int
_inp_rl_win_pagedown_handler(int count, int key)
{
ProfWin* current = wins_get_current();
win_page_down(current);
win_page_down(current, 0);
return 0;
}
@@ -935,6 +938,21 @@ _inp_rl_subwin_pagedown_handler(int count, int key)
return 0;
}
static int
_inp_rl_scroll_handler(int count, int key)
{
ProfWin* window = wins_get_current();
if (key == 'B') {
// mouse wheel down
win_page_down(window, 4);
} else if (key == 'A') {
// mouse wheel up
win_page_up(window, 4);
}
return 0;
}
static int
_inp_rl_down_arrow_handler(int count, int key)
{