From 6e5001ef5b8d564e59ac8e48552e90561bda7fe3 Mon Sep 17 00:00:00 2001
From: Bjorn Winckler <bjorn.winckler@gmail.com>
Date: Wed, 21 Jul 2010 22:12:34 +0200
Subject: [PATCH] Address Bram's comments

---
 src/edit.c   |   15 ++++++++-------
 src/gui.c    |    1 +
 src/normal.c |   15 ++++++++-------
 src/vim.h    |    6 ++++++
 4 files changed, 23 insertions(+), 14 deletions(-)

diff --git a/src/edit.c b/src/edit.c
index 36d4d34..4a53e3e 100644
--- a/src/edit.c
+++ b/src/edit.c
@@ -1106,19 +1106,19 @@ doESCkey:
 	    break;
 
 	case K_MOUSEDOWN: /* Default action for scroll wheel up: scroll up */
-	    ins_mousescroll(0);
+	    ins_mousescroll(MSCR_DOWN);
 	    break;
 
 	case K_MOUSEUP:	/* Default action for scroll wheel down: scroll down */
-	    ins_mousescroll(1);
+	    ins_mousescroll(MSCR_UP);
 	    break;
 
 	case K_MOUSELEFT: /* Scroll wheel left */
-	    ins_mousescroll(-1);
+	    ins_mousescroll(MSCR_LEFT);
 	    break;
 
 	case K_MOUSERIGHT: /* Scroll wheel right */
-	    ins_mousescroll(-2);
+	    ins_mousescroll(MSCR_RIGHT);
 	    break;
 #endif
 #ifdef FEAT_GUI_TABLINE
@@ -8897,7 +8897,7 @@ ins_mousescroll(dir)
 	    )
 # endif
     {
-	if (dir >= 0)
+	if (dir == MSCR_DOWN || dir == MSCR_UP)
 	{
 	    if (mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL))
 		scroll_redraw(dir,
@@ -8911,8 +8911,9 @@ ins_mousescroll(dir)
 	    int val, step = 6;
 	    if (mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL))
 		step = W_WIDTH(curwin);
-	    val = curwin->w_leftcol + (dir < -1 ? -step : +step);
-	    if (val < 0) val = 0;
+	    val = curwin->w_leftcol + (dir == MSCR_RIGHT ? -step : +step);
+	    if (val < 0)
+		val = 0;
 
 	    gui_do_horiz_scroll(val, TRUE);
 	}
diff --git a/src/gui.c b/src/gui.c
index ee92256..1a86922 100644
--- a/src/gui.c
+++ b/src/gui.c
@@ -31,6 +31,7 @@ static int gui_has_tabline __ARGS((void));
 #endif
 static void gui_do_scrollbar __ARGS((win_T *wp, int which, int enable));
 static colnr_T scroll_line_len __ARGS((linenr_T lnum));
+static linenr_T gui_find_longest_lnum __ARGS((void));
 static void gui_update_horiz_scrollbar __ARGS((int));
 static void gui_set_fg_color __ARGS((char_u *name));
 static void gui_set_bg_color __ARGS((char_u *name));
diff --git a/src/normal.c b/src/normal.c
index 14be384..69d2937 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -368,10 +368,10 @@ static const struct nv_cmd
     /* pound sign */
     {POUND,	nv_ident,	0,			0},
 #ifdef FEAT_MOUSE
-    {K_MOUSEUP, nv_mousescroll,	0,			1},
-    {K_MOUSEDOWN, nv_mousescroll, 0,			0},
-    {K_MOUSELEFT, nv_mousescroll, 0,			-1},
-    {K_MOUSERIGHT, nv_mousescroll, 0,			-2},
+    {K_MOUSEUP, nv_mousescroll,	0,			MSCR_UP},
+    {K_MOUSEDOWN, nv_mousescroll, 0,			MSCR_DOWN},
+    {K_MOUSELEFT, nv_mousescroll, 0,			MSCR_LEFT},
+    {K_MOUSERIGHT, nv_mousescroll, 0,			MSCR_RIGHT},
     {K_LEFTMOUSE, nv_mouse,	0,			0},
     {K_LEFTMOUSE_NM, nv_mouse,	0,			0},
     {K_LEFTDRAG, nv_mouse,	0,			0},
@@ -4563,7 +4563,7 @@ nv_mousescroll(cap)
     }
 # endif
 
-    if (cap->arg >= 0)
+    if (cap->arg == MSCR_UP || cap->arg == MSCR_DOWN)
     {
 	if (mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL))
 	{
@@ -4585,8 +4585,9 @@ nv_mousescroll(cap)
 	    int val, step = 6;
 	    if (mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL))
 		step = W_WIDTH(curwin);
-	    val = curwin->w_leftcol + (cap->arg < -1 ? -step : +step);
-	    if (val < 0) val = 0;
+	    val = curwin->w_leftcol + (cap->arg == MSCR_RIGHT ? -step : +step);
+	    if (val < 0)
+		val = 0;
 
 	    gui_do_horiz_scroll(val, TRUE);
 	}
diff --git a/src/vim.h b/src/vim.h
index 97e736f..0ea05ce 100644
--- a/src/vim.h
+++ b/src/vim.h
@@ -2180,4 +2180,10 @@ typedef int VimClipboard;	/* This is required for the prototypes. */
 #define VIF_FORCEIT		4	/* overwrite info already read */
 #define VIF_GET_OLDFILES	8	/* load v:oldfiles */
 
+/* direction for nv_mousescroll() and ins_mousescroll() */
+#define MSCR_DOWN	0	/* DOWN must be FALSE */
+#define MSCR_UP		1
+#define MSCR_LEFT	-1
+#define MSCR_RIGHT	-2
+
 #endif /* VIM__H */
-- 
1.7.2.rc3.57.g77b5b

