From 8d9b40e71ab62f43c65a52225cb833ecc0d1bf6b Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 25 Jul 2010 15:49:07 +0200 Subject: Add support for horizontal scroll wheel. (Bjorn Winckler) --- src/edit.c | 46 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 10 deletions(-) (limited to 'src/edit.c') diff --git a/src/edit.c b/src/edit.c index 3370a28f2d..4754fd9bde 100644 --- a/src/edit.c +++ b/src/edit.c @@ -224,7 +224,7 @@ static void ins_del __ARGS((void)); static int ins_bs __ARGS((int c, int mode, int *inserted_space_p)); #ifdef FEAT_MOUSE static void ins_mouse __ARGS((int c)); -static void ins_mousescroll __ARGS((int up)); +static void ins_mousescroll __ARGS((int dir)); #endif #if defined(FEAT_GUI_TABLINE) || defined(PROTO) static void ins_tabline __ARGS((int c)); @@ -1112,11 +1112,19 @@ doESCkey: break; case K_MOUSEDOWN: /* Default action for scroll wheel up: scroll up */ - ins_mousescroll(FALSE); + ins_mousescroll(MSCR_DOWN); break; case K_MOUSEUP: /* Default action for scroll wheel down: scroll down */ - ins_mousescroll(TRUE); + ins_mousescroll(MSCR_UP); + break; + + case K_MOUSELEFT: /* Scroll wheel left */ + ins_mousescroll(MSCR_LEFT); + break; + + case K_MOUSERIGHT: /* Scroll wheel right */ + ins_mousescroll(MSCR_RIGHT); break; #endif #ifdef FEAT_GUI_TABLINE @@ -3516,7 +3524,8 @@ ins_compl_prep(c) edit_submode_extra = NULL; /* Ignore end of Select mode mapping and mouse scroll buttons. */ - if (c == K_SELECT || c == K_MOUSEDOWN || c == K_MOUSEUP) + if (c == K_SELECT || c == K_MOUSEDOWN || c == K_MOUSEUP + || c == K_MOUSELEFT || c == K_MOUSERIGHT) return retval; /* Set "compl_get_longest" when finding the first matches. */ @@ -8859,8 +8868,8 @@ ins_mouse(c) } static void -ins_mousescroll(up) - int up; +ins_mousescroll(dir) + int dir; { pos_T tpos; # if defined(FEAT_WINDOWS) @@ -8898,10 +8907,27 @@ ins_mousescroll(up) ) # endif { - if (mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL)) - scroll_redraw(up, (long)(curwin->w_botline - curwin->w_topline)); + if (dir == MSCR_DOWN || dir == MSCR_UP) + { + if (mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL)) + scroll_redraw(dir, + (long)(curwin->w_botline - curwin->w_topline)); + else + scroll_redraw(dir, 3L); + } +#ifdef FEAT_GUI else - scroll_redraw(up, 3L); + { + int val, step = 6; + + if (mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL)) + step = W_WIDTH(curwin); + val = curwin->w_leftcol + (dir == MSCR_RIGHT ? -step : step); + if (val < 0) + val = 0; + gui_do_horiz_scroll(val, TRUE); + } +#endif # ifdef FEAT_INS_EXPAND did_scroll = TRUE; # endif @@ -8985,7 +9011,7 @@ ins_horscroll() undisplay_dollar(); tpos = curwin->w_cursor; - if (gui_do_horiz_scroll()) + if (gui_do_horiz_scroll(scrollbar_value, FALSE)) { start_arrow(&tpos); # ifdef FEAT_CINDENT -- cgit v1.2.3