changeset 2409:0ca06a92adfb vim73

Add support for horizontal scroll wheel. (Bjorn Winckler)
author Bram Moolenaar <bram@vim.org>
date Sun, 25 Jul 2010 15:49:07 +0200
parents 9e2e63af1641
children 8f6106dd3d12
files runtime/doc/arabic.txt runtime/doc/if_pyth.txt runtime/doc/index.txt runtime/doc/insert.txt runtime/doc/scroll.txt runtime/doc/tags runtime/doc/todo.txt runtime/doc/version6.txt runtime/doc/version7.txt src/edit.c src/eval.c src/ex_getln.c src/gui.c src/gui_gtk_x11.c src/keymap.h src/message.c src/misc1.c src/misc2.c src/normal.c src/proto/gui.pro src/screen.c src/term.c src/vim.h
diffstat 23 files changed, 305 insertions(+), 143 deletions(-) [+]
line wrap: on
line diff
--- a/runtime/doc/arabic.txt
+++ b/runtime/doc/arabic.txt
@@ -275,7 +275,7 @@ o  Keyboard
    +  CTRL-^ in insert/replace mode toggles between Arabic/Latin mode
 
    +  Keyboard mapping is based on the Microsoft's Arabic keymap (the
-      defacto standard in the Arab world):
+      de facto standard in the Arab world):
 
   +---------------------------------------------------------------------+
   |!   |@   |#   |$   |%   |^   |&   |*   |(   |)   |_   |+   ||   |~  ّ |
--- a/runtime/doc/if_pyth.txt
+++ b/runtime/doc/if_pyth.txt
@@ -1,4 +1,4 @@
-*if_pyth.txt*   For Vim version 7.3b.  Last change: 2010 Jul 24
+*if_pyth.txt*   For Vim version 7.3b.  Last change: 2010 Jul 25
 
 
 		  VIM REFERENCE MANUAL    by Paul Moore
@@ -337,12 +337,21 @@ sure edit "gvim.exe" and search for "pyt
 ==============================================================================
 7. Python 3						*python3*
 
-Python 3 support can exist next to Python 2.x.
+							*:py3* *:python3*
+The |:py3| and |:python3| commands work similar to |:python|.
+ 								*:py3file*
+The |:py3file| command works similar to |:pyfile|.
 
-*:py3* *:python3* *:py3file*
+Vim can be built in four ways (:version output):
+1. No Python support        (-python, -python3)
+2. Python 2 support only    (+python or +python/dyn, -python3)
+3. Python 3 support only    (-python, +python3 or +python3/dyn)
+4. Python 2 and 3 support   (+python/dyn, +python3/dyn)
 
-TODO
-
+You can see that when Python 2 and Python 3 are both supported they must be
+loaded dynamically.  This may cause some problems though, therefore currently
+inside a Vim executable you can only use Python 2 or Python 3.  To switch to
+the other one you need to restart Vim.
 
 ==============================================================================
  vim:tw=78:ts=8:ft=help:norl:
--- a/runtime/doc/index.txt
+++ b/runtime/doc/index.txt
@@ -136,10 +136,14 @@ tag		char		action	~
 |i_<Help>|	<Help>		stop insert mode and display help window
 |i_<Insert>|	<Insert>	toggle Insert/Replace mode
 |i_<LeftMouse>|	<LeftMouse>	cursor at mouse click
-|i_<MouseDown>|	<MouseDown>	scroll three lines downwards
-|i_<S-MouseDown>| <S-MouseDown>	scroll a full page downwards
-|i_<MouseUp>|	<MouseUp>	scroll three lines upwards
-|i_<S-MouseUp>|	<S-MouseUp>	scroll a full page upwards
+|i_<ScrollWheelDown>|	<ScrollWheelDown>	move window three lines down
+|i_<S-ScrollWheelDown>|	<S-ScrollWheelDown>	move window one page down
+|i_<ScrollWheelUp>|	<ScrollWheelUp>		move window three lines up
+|i_<S-ScrollWheelUp>|	<S-ScrollWheelUp>	move window one page up
+|i_<ScrollWheelLeft>|	<ScrollWheelLeft>	move window six columns left
+|i_<S-ScrollWheelLeft>| <S-ScrollWheelLeft>	move window one page left
+|i_<ScrollWheelRight>|	<ScrollWheelRight>	move window six columns right
+|i_<S-ScrollWheelRight>| <S-ScrollWheelRight>	move window one page right
 
 commands in CTRL-X submode				*i_CTRL-X_index*
 
@@ -441,10 +445,14 @@ tag		char	      note action in Normal mo
 |<S-Up>|	<S-Up>		1  same as CTRL-B
 |<Undo>|	<Undo>		2  same as "u"
 |<Up>|		<Up>		1  same as "k"
-|<MouseDown>|	<MouseDown>	   scroll three lines downwards
-|<S-MouseDown>|	<S-MouseDown>	   scroll a full page downwards
-|<MouseUp>|	<MouseUp>	   scroll three lines upwards
-|<S-MouseUp>|	<S-MouseUp>	   scroll a full page upwards
+|<ScrollWheelDown>|	<ScrollWheelDown>	move window three lines down
+|<S-ScrollWheelDown>|	<S-ScrollWheelDown>	move window one page down
+|<ScrollWheelUp>|	<ScrollWheelUp>		move window three lines up
+|<S-ScrollWheelUp>|	<S-ScrollWheelUp>	move window one page up
+|<ScrollWheelLeft>|	<ScrollWheelLeft>	move window six columns left
+|<S-ScrollWheelLeft>|	<S-ScrollWheelLeft>	move window one page left
+|<ScrollWheelRight>|	<ScrollWheelRight>	move window six columns right
+|<S-ScrollWheelRight>|	<S-ScrollWheelRight>	move window one page right
 
 ==============================================================================
 2.1 Text objects						*objects*
--- a/runtime/doc/insert.txt
+++ b/runtime/doc/insert.txt
@@ -359,10 +359,14 @@ CTRL-G CTRL-J	cursor one line down, inse
 <PageUp>	move window one page up			     *i_<PageUp>*
 <S-Down>	move window one page down		     *i_<S-Down>*
 <PageDown>	move window one page down		     *i_<PageDown>*
-<MouseDown>	scroll three lines down			     *i_<MouseDown>*
-<S-MouseDown>	scroll a full page down			     *i_<S-MouseDown>*
-<MouseUp>	scroll three lines up			     *i_<MouseUp>*
-<S-MouseUp>	scroll a full page up			     *i_<S-MouseUp>*
+<ScrollWheelDown>    move window three lines down	*i_<ScrollWheelDown>*
+<S-ScrollWheelDown>  move window one page down		*i_<S-ScrollWheelDown>*
+<ScrollWheelUp>      move window three lines up		*i_<ScrollWheelUp>*
+<S-ScrollWheelUp>    move window one page up		*i_<S-ScrollWheelUp>*
+<ScrollWheelLeft>    move window six columns left	*i_<ScrollWheelLeft>*
+<S-ScrollWheelLeft>  move window one page left		*i_<S-ScrollWheelLeft>*
+<ScrollWheelRight>   move window six columns right	*i_<ScrollWheelRight>*
+<S-ScrollWheelRight> move window one page right		*i_<S-ScrollWheelRight>*
 CTRL-O		execute one command, return to Insert mode   *i_CTRL-O*
 CTRL-\ CTRL-O	like CTRL-O but don't move the cursor	     *i_CTRL-\_CTRL-O*
 CTRL-L		when 'insertmode' is set: go to Normal mode  *i_CTRL-L*
--- a/runtime/doc/scroll.txt
+++ b/runtime/doc/scroll.txt
@@ -242,7 +242,8 @@ 6. Scrolling with a mouse wheel				*scro
 
 When your mouse has a scroll wheel, it should work with Vim in the GUI.  How
 it works depends on your system.  It might also work in an xterm
-|xterm-mouse-wheel|.
+|xterm-mouse-wheel|.  By default only vertical scroll wheels are supported,
+but some GUIs also support horizontal scroll wheels.
 
 For the Win32 GUI the scroll action is hard coded.  It works just like
 dragging the scrollbar of the current window.  How many lines are scrolled
@@ -250,24 +251,36 @@ depends on your mouse driver.  If the sc
 problems, see |intellimouse-wheel-problems|.
 
 For the X11 GUIs (Motif, Athena and GTK) scrolling the wheel generates key
-presses <MouseDown> and <MouseUp>.  The default action for these keys are:
-    <MouseDown>		scroll three lines down.	*<MouseDown>*
-    <S-MouseDown>	scroll a full page down.	*<S-MouseDown>*
-    <C-MouseDown>	scroll a full page down.	*<C-MouseDown>*
-    <MouseUp>		scroll three lines up.		*<MouseUp>*
-    <S-MouseUp>		scroll a full page up.		*<S-MouseUp>*
-    <C-MouseUp>		scroll a full page up.		*<C-MouseUp>*
+presses <ScrollWheelUp>, <ScrollWheelDown>, <ScrollWheelLeft> and
+<ScrollWheelRight>.  For example, if you push the scroll wheel upwards a
+<ScrollWheelUp> key press is generated causing the window to scroll upwards
+(while the text is actually moving downwards).  The default action for these
+keys are:
+    <ScrollWheelUp>	    scroll three lines up	*<ScrollWheelUp>*
+    <S-ScrollWheelUp>	    scroll one page up		*<S-ScrollWheelUp>*
+    <C-ScrollWheelUp>	    scroll one page up		*<C-ScrollWheelUp>*
+    <ScrollWheelDown>	    scroll three lines down	*<ScrollWheelDown>*
+    <S-ScrollWheelDown>	    scroll one page down	*<S-ScrollWheelDown>*
+    <C-ScrollWheelDown>	    scroll one page down	*<C-ScrollWheelDown>*
+    <ScrollWheelLeft>	    scroll six columns left	*<ScrollWheelLeft>*
+    <S-ScrollWheelLeft>	    scroll one page left	*<S-ScrollWheelLeft>*
+    <C-ScrollWheelLeft>	    scroll one page left	*<C-ScrollWheelLeft>*
+    <ScrollWheelRight>	    scroll six columns right	*<ScrollWheelRight>*
+    <S-ScrollWheelRight>    scroll one page right	*<S-ScrollWheelRight>*
+    <C-ScrollWheelRight>    scroll one page right	*<C-ScrollWheelRight>*
 This should work in all modes, except when editing the command line.
 
-Note that <MouseDown> is used for scrolling the text down, this happens when
-you turn the mouse wheel up!
+Note that horizontal scrolling only works if 'nowrap' is set.  Also, unless
+the "h" flag in 'guioptions' is set, the cursor moves to the longest visible
+line if the cursor line is about to be scrolled off the screen (similarly to
+how the horizontal scrollbar works).
 
-You can modify this behavior by mapping the keys.  For example, to make the
-scroll wheel move one line or half a page in Normal mode: >
-   :map <MouseDown> <C-Y>
-   :map <S-MouseDown> <C-U>
-   :map <MouseUp> <C-E>
-   :map <S-MouseUp> <C-D>
+You can modify the default behavior by mapping the keys.  For example, to make
+the scroll wheel move one line or half a page in Normal mode: >
+   :map <ScrollWheelUp> <C-Y>
+   :map <S-ScrollWheelUp> <C-U>
+   :map <ScrollWheelDown> <C-E>
+   :map <S-ScrollWheelDown> <C-D>
 You can also use Alt and Ctrl modifiers.
 
 This only works when Vim gets the scroll wheel events, of course.  You can
@@ -280,6 +293,10 @@ your mouse.  For FreeBSD, this entry wor
     ZAxisMapping 4 5
 See the XFree86 documentation for information.
 
+						*<MouseDown>* *<MouseUp>*
+The keys <MouseDown> and <MouseUp> have been deprecated.  Use <ScrollWheelUp>
+instead of <MouseDown> and use <ScrollWheelDown> instead of <MouseUp>.
+
 							*xterm-mouse-wheel*
 To use the mouse wheel in a new xterm you only have to make the scroll wheel
 work in your Xserver, as mentioned above.
@@ -288,8 +305,8 @@ To use the mouse wheel in an older xterm
 1. Make it work in your Xserver, as mentioned above.
 2. Add translations for the xterm, so that the xterm will pass a scroll event
    to Vim as an escape sequence.
-3. Add mappings in Vim, to interpret the escape sequences as <MouseUp> or
-   <MouseDown> keys.
+3. Add mappings in Vim, to interpret the escape sequences as <ScrollWheelDown>
+   or <ScrollWheelUp> keys.
 
 You can do the translations by adding this to your ~.Xdefaults file (or other
 file where your X resources are kept): >
@@ -303,13 +320,13 @@ file where your X resources are kept): >
 		<Btn5Up>:
 
 Add these mappings to your vimrc file: >
-	:map <M-Esc>[62~ <MouseDown>
-	:map! <M-Esc>[62~ <MouseDown>
-	:map <M-Esc>[63~ <MouseUp>
-	:map! <M-Esc>[63~ <MouseUp>
-	:map <M-Esc>[64~ <S-MouseDown>
-	:map! <M-Esc>[64~ <S-MouseDown>
-	:map <M-Esc>[65~ <S-MouseUp>
-	:map! <M-Esc>[65~ <S-MouseUp>
+	:map <M-Esc>[62~ <ScrollWheelUp>
+	:map! <M-Esc>[62~ <ScrollWheelUp>
+	:map <M-Esc>[63~ <ScrollWheelDown>
+	:map! <M-Esc>[63~ <ScrollWheelDown>
+	:map <M-Esc>[64~ <S-ScrollWheelUp>
+	:map! <M-Esc>[64~ <S-ScrollWheelUp>
+	:map <M-Esc>[65~ <S-ScrollWheelDown>
+	:map! <M-Esc>[65~ <S-ScrollWheelDown>
 <
  vim:tw=78:ts=8:ft=help:norl:
--- a/runtime/doc/tags
+++ b/runtime/doc/tags
@@ -3056,12 +3056,14 @@ 90.5	usr_90.txt	/*90.5*
 <C-Insert>	os_dos.txt	/*<C-Insert>*
 <C-Left>	motion.txt	/*<C-Left>*
 <C-LeftMouse>	tagsrch.txt	/*<C-LeftMouse>*
-<C-MouseDown>	scroll.txt	/*<C-MouseDown>*
-<C-MouseUp>	scroll.txt	/*<C-MouseUp>*
 <C-PageDown>	tabpage.txt	/*<C-PageDown>*
 <C-PageUp>	tabpage.txt	/*<C-PageUp>*
 <C-Right>	motion.txt	/*<C-Right>*
 <C-RightMouse>	tagsrch.txt	/*<C-RightMouse>*
+<C-ScrollWheelDown>	scroll.txt	/*<C-ScrollWheelDown>*
+<C-ScrollWheelLeft>	scroll.txt	/*<C-ScrollWheelLeft>*
+<C-ScrollWheelRight>	scroll.txt	/*<C-ScrollWheelRight>*
+<C-ScrollWheelUp>	scroll.txt	/*<C-ScrollWheelUp>*
 <CR>	motion.txt	/*<CR>*
 <CSI>	intro.txt	/*<CSI>*
 <Char->	map.txt	/*<Char->*
@@ -3140,10 +3142,12 @@ 90.5	usr_90.txt	/*90.5*
 <S-Insert>	os_dos.txt	/*<S-Insert>*
 <S-Left>	motion.txt	/*<S-Left>*
 <S-LeftMouse>	term.txt	/*<S-LeftMouse>*
-<S-MouseDown>	scroll.txt	/*<S-MouseDown>*
-<S-MouseUp>	scroll.txt	/*<S-MouseUp>*
 <S-Right>	motion.txt	/*<S-Right>*
 <S-RightMouse>	term.txt	/*<S-RightMouse>*
+<S-ScrollWheelDown>	scroll.txt	/*<S-ScrollWheelDown>*
+<S-ScrollWheelLeft>	scroll.txt	/*<S-ScrollWheelLeft>*
+<S-ScrollWheelRight>	scroll.txt	/*<S-ScrollWheelRight>*
+<S-ScrollWheelUp>	scroll.txt	/*<S-ScrollWheelUp>*
 <S-Tab>	term.txt	/*<S-Tab>*
 <S-Up>	scroll.txt	/*<S-Up>*
 <S-xF1>	term.txt	/*<S-xF1>*
@@ -3152,6 +3156,10 @@ 90.5	usr_90.txt	/*90.5*
 <S-xF4>	term.txt	/*<S-xF4>*
 <SID>	map.txt	/*<SID>*
 <SNR>	map.txt	/*<SNR>*
+<ScrollWheelDown>	scroll.txt	/*<ScrollWheelDown>*
+<ScrollWheelLeft>	scroll.txt	/*<ScrollWheelLeft>*
+<ScrollWheelRight>	scroll.txt	/*<ScrollWheelRight>*
+<ScrollWheelUp>	scroll.txt	/*<ScrollWheelUp>*
 <Space>	motion.txt	/*<Space>*
 <Tab>	motion.txt	/*<Tab>*
 <Undo>	undo.txt	/*<Undo>*
@@ -6166,18 +6174,22 @@ i_<Home>	insert.txt	/*i_<Home>*
 i_<Insert>	insert.txt	/*i_<Insert>*
 i_<Left>	insert.txt	/*i_<Left>*
 i_<LeftMouse>	insert.txt	/*i_<LeftMouse>*
-i_<MouseDown>	insert.txt	/*i_<MouseDown>*
-i_<MouseUp>	insert.txt	/*i_<MouseUp>*
 i_<NL>	insert.txt	/*i_<NL>*
 i_<PageDown>	insert.txt	/*i_<PageDown>*
 i_<PageUp>	insert.txt	/*i_<PageUp>*
 i_<Right>	insert.txt	/*i_<Right>*
 i_<S-Down>	insert.txt	/*i_<S-Down>*
 i_<S-Left>	insert.txt	/*i_<S-Left>*
-i_<S-MouseDown>	insert.txt	/*i_<S-MouseDown>*
-i_<S-MouseUp>	insert.txt	/*i_<S-MouseUp>*
 i_<S-Right>	insert.txt	/*i_<S-Right>*
+i_<S-ScrollWheelDown>	insert.txt	/*i_<S-ScrollWheelDown>*
+i_<S-ScrollWheelLeft>	insert.txt	/*i_<S-ScrollWheelLeft>*
+i_<S-ScrollWheelRight>	insert.txt	/*i_<S-ScrollWheelRight>*
+i_<S-ScrollWheelUp>	insert.txt	/*i_<S-ScrollWheelUp>*
 i_<S-Up>	insert.txt	/*i_<S-Up>*
+i_<ScrollWheelDown>	insert.txt	/*i_<ScrollWheelDown>*
+i_<ScrollWheelLeft>	insert.txt	/*i_<ScrollWheelLeft>*
+i_<ScrollWheelRight>	insert.txt	/*i_<ScrollWheelRight>*
+i_<ScrollWheelUp>	insert.txt	/*i_<ScrollWheelUp>*
 i_<Tab>	insert.txt	/*i_<Tab>*
 i_<Up>	insert.txt	/*i_<Up>*
 i_BS	insert.txt	/*i_BS*
@@ -7599,6 +7611,7 @@ synIDattr()	eval.txt	/*synIDattr()*
 synIDtrans()	eval.txt	/*synIDtrans()*
 syncbind	scroll.txt	/*syncbind*
 syncolor	syntax.txt	/*syncolor*
+synconcealed()	eval.txt	/*synconcealed()*
 synload-1	syntax.txt	/*synload-1*
 synload-2	syntax.txt	/*synload-2*
 synload-3	syntax.txt	/*synload-3*
--- a/runtime/doc/todo.txt
+++ b/runtime/doc/todo.txt
@@ -30,15 +30,6 @@ be worked on, but only if you sponsor Vi
 							*known-bugs*
 -------------------- Known bugs and current work -----------------------
 
-concealends does not appear to work.
-
-if_python3.c is missing some changes that were applied to if_python.c.
-Find the old version of if_python.c from when the copy was made.
-
-Move more common code from if_python.c and if_python3.c to if_py_both.h
-
-Add documentation for Python 3 support.
-
 Include patch for horizontal scoll wheel? (Bjorn Winckler, 2010 Jul 20)
 Additional patch Jul 21.
 
@@ -50,9 +41,13 @@ 6   In the quickfix window statusline ad
 Patch for :find completion. (Nazri Ramliy)
 But I prefer to keep term.h and include/term.h  He will work on it.
 
+Add hg changes to version7.txt
+
 Before release 7.3:
 - Rename vim73 branch to default (hints: Xavier de Gaye, 2010 May 23)
 
+Move more common code from if_python.c and if_python3.c to if_py_both.h
+
 Cursor positioning wrong with 0x200e character. (John Becket, 2010 May 6)
 
 Test 69 breaks on MS-Windows, both 32 and 64 builds. (George Reilly, 2010 Feb
--- a/runtime/doc/version6.txt
+++ b/runtime/doc/version6.txt
@@ -10357,7 +10357,7 @@ Files:	    src/ex_cmds2.c
 
 Patch 6.2.066 (extra)
 Problem:    Ruby interface doesn't work with Ruby 1.8.0.
-Solution:   Change "defout" to "stdout". (Aron Grifis)
+Solution:   Change "defout" to "stdout". (Aron Griffis)
 	    Change dynamic loading. (Taro Muraoka)
 Files:	    src/if_ruby.c, src/Make_mvc.mak
 
--- a/runtime/doc/version7.txt
+++ b/runtime/doc/version7.txt
@@ -1,4 +1,4 @@
-*version7.txt*  For Vim version 7.3b.  Last change: 2010 Jul 24
+*version7.txt*  For Vim version 7.3b.  Last change: 2010 Jul 25
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -5530,7 +5530,7 @@ Files:	    src/gui_mac.c
 
 Patch 7.1.125
 Problem:    The TermResponse autocommand event is not always triggered. (Aron
-	    Griffix)
+	    Griffis)
 Solution:   When unblocking autocommands check if v:termresponse changed and
 	    trigger the event then.
 Files:	    src/buffer.c, src/diff.c, src/ex_getln.c, src/fileio.c,
@@ -8679,7 +8679,7 @@ Files:	    src/testdir/Makefile
 
 Patch 7.2.218
 Problem:    Cannot build GTK with hangul_input feature. (Dominique Pelle)
-Solution:   Adjuste #ifdef.  (SungHyun Nam)
+Solution:   Adjust #ifdef.  (SungHyun Nam)
 Files:	    src/gui.c
 
 Patch 7.2.219 (extra)
@@ -9905,7 +9905,7 @@ Files:	    runtime/doc/autocmd.txt, src/
 
 Patch 7.2.434 (after 7.2.432)
 Problem:    Compilation fails without the multi-lang feature.
-Solution:   Add #ifdefs. (Johm Marriott)
+Solution:   Add #ifdefs. (John Marriott)
 Files:	    src/menu.c
 
 Patch 7.2.435 (after 7.2.430)
@@ -10032,12 +10032,10 @@ Some versions of Ruby redefine rb_str_ne
 
 Window title not updated after file dropped.
 
-"g8" doesn't work properly on a NUL.
-
 Fixed crash for ":find" completion, might also happen in other path expansion
 usage.
 
-When 'searchhl' causes a hang make CTRL-C disable 'shearchhl'.
+When 'searchhl' causes a hang make CTRL-C disable 'searchhl'.
 
 
  vim:tw=78:ts=8:ft=help:norl:
--- 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
--- a/src/eval.c
+++ b/src/eval.c
@@ -10927,6 +10927,8 @@ f_getchar(argvars, rettv)
 		|| n == K_X2MOUSE
 		|| n == K_X2DRAG
 		|| n == K_X2RELEASE
+		|| n == K_MOUSELEFT
+		|| n == K_MOUSERIGHT
 		|| n == K_MOUSEDOWN
 		|| n == K_MOUSEUP)
 	{
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -1334,6 +1334,8 @@ getcmdline(firstc, count, indent)
 	/* Mouse scroll wheel: ignored here */
 	case K_MOUSEDOWN:
 	case K_MOUSEUP:
+	case K_MOUSELEFT:
+	case K_MOUSERIGHT:
 	/* Alternate buttons ignored here */
 	case K_X1MOUSE:
 	case K_X1DRAG:
@@ -1361,7 +1363,7 @@ getcmdline(firstc, count, indent)
 	case K_HOR_SCROLLBAR:
 		if (msg_scrolled == 0)
 		{
-		    gui_do_horiz_scroll();
+		    gui_do_horiz_scroll(scrollbar_value, FALSE);
 		    redrawcmd();
 		}
 		goto cmdline_not_changed;
--- 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));
@@ -2759,7 +2760,8 @@ fill_mouse_coord(p, col, row)
  *  button	    --- may be any of MOUSE_LEFT, MOUSE_MIDDLE, MOUSE_RIGHT,
  *			MOUSE_X1, MOUSE_X2
  *			MOUSE_DRAG, or MOUSE_RELEASE.
- *			MOUSE_4 and MOUSE_5 are used for a scroll wheel.
+ *			MOUSE_4 and MOUSE_5 are used for vertical scroll wheel,
+ *			MOUSE_6 and MOUSE_7 for horizontal scroll wheel.
  *  x, y	    --- Coordinates of mouse in pixels.
  *  repeated_click  --- TRUE if this click comes only a short time after a
  *			previous click.
@@ -2803,6 +2805,12 @@ gui_send_mouse_event(button, x, y, repea
 	    goto button_set;
 	case MOUSE_5:
 	    button_char = KE_MOUSEUP;
+	    goto button_set;
+	case MOUSE_6:
+	    button_char = KE_MOUSELEFT;
+	    goto button_set;
+	case MOUSE_7:
+	    button_char = KE_MOUSERIGHT;
 button_set:
 	    {
 		/* Don't put events in the input queue now. */
@@ -3845,14 +3853,14 @@ gui_drag_scrollbar(sb, value, still_drag
 	scrollbar_value = value;
 
 	if (State & NORMAL)
-	    gui_do_horiz_scroll();
+	    gui_do_horiz_scroll(scrollbar_value, FALSE);
 	else if (State & INSERT)
 	    ins_horscroll();
 	else if (State & CMDLINE)
 	{
 	    if (msg_scrolled == 0)
 	    {
-		gui_do_horiz_scroll();
+		gui_do_horiz_scroll(scrollbar_value, FALSE);
 		redrawcmdline();
 	    }
 	}
@@ -4319,6 +4327,51 @@ scroll_line_len(lnum)
  * search for it when scrolling horizontally. */
 static linenr_T longest_lnum = 0;
 
+/*
+ * Find longest visible line number.  If this is not possible (or not desired,
+ * by setting 'h' in "guioptions") then the current line number is returned.
+ */
+    static linenr_T
+gui_find_longest_lnum()
+{
+    linenr_T ret = 0;
+
+    /* Calculate maximum for horizontal scrollbar.  Check for reasonable
+     * line numbers, topline and botline can be invalid when displaying is
+     * postponed. */
+    if (vim_strchr(p_go, GO_HORSCROLL) == NULL
+	    && curwin->w_topline <= curwin->w_cursor.lnum
+	    && curwin->w_botline > curwin->w_cursor.lnum
+	    && curwin->w_botline <= curbuf->b_ml.ml_line_count + 1)
+    {
+	linenr_T    lnum;
+	colnr_T	    n;
+	long	    max = 0;
+
+	/* Use maximum of all visible lines.  Remember the lnum of the
+	 * longest line, closest to the cursor line.  Used when scrolling
+	 * below. */
+	for (lnum = curwin->w_topline; lnum < curwin->w_botline; ++lnum)
+	{
+	    n = scroll_line_len(lnum);
+	    if (n > (colnr_T)max)
+	    {
+		max = n;
+		ret = lnum;
+	    }
+	    else if (n == (colnr_T)max
+		    && abs((int)(lnum - curwin->w_cursor.lnum))
+		       < abs((int)(ret - curwin->w_cursor.lnum)))
+		ret = lnum;
+	}
+    }
+    else
+	/* Use cursor line only. */
+	ret = curwin->w_cursor.lnum;
+
+    return ret;
+}
+
     static void
 gui_update_horiz_scrollbar(force)
     int		force;
@@ -4358,38 +4411,9 @@ gui_update_horiz_scrollbar(force)
     {
 	value = curwin->w_leftcol;
 
-	/* Calculate maximum for horizontal scrollbar.  Check for reasonable
-	 * line numbers, topline and botline can be invalid when displaying is
-	 * postponed. */
-	if (vim_strchr(p_go, GO_HORSCROLL) == NULL
-		&& curwin->w_topline <= curwin->w_cursor.lnum
-		&& curwin->w_botline > curwin->w_cursor.lnum
-		&& curwin->w_botline <= curbuf->b_ml.ml_line_count + 1)
-	{
-	    linenr_T	lnum;
-	    colnr_T	n;
-
-	    /* Use maximum of all visible lines.  Remember the lnum of the
-	     * longest line, clostest to the cursor line.  Used when scrolling
-	     * below. */
-	    max = 0;
-	    for (lnum = curwin->w_topline; lnum < curwin->w_botline; ++lnum)
-	    {
-		n = scroll_line_len(lnum);
-		if (n > (colnr_T)max)
-		{
-		    max = n;
-		    longest_lnum = lnum;
-		}
-		else if (n == (colnr_T)max
-			&& abs((int)(lnum - curwin->w_cursor.lnum))
-			   < abs((int)(longest_lnum - curwin->w_cursor.lnum)))
-		    longest_lnum = lnum;
-	    }
-	}
-	else
-	    /* Use cursor line only. */
-	    max = scroll_line_len(curwin->w_cursor.lnum);
+	longest_lnum = gui_find_longest_lnum();
+	max = scroll_line_len(longest_lnum);
+
 #ifdef FEAT_VIRTUALEDIT
 	if (virtual_active())
 	{
@@ -4442,26 +4466,33 @@ gui_update_horiz_scrollbar(force)
  * Do a horizontal scroll.  Return TRUE if the cursor moved, FALSE otherwise.
  */
     int
-gui_do_horiz_scroll()
+gui_do_horiz_scroll(leftcol, compute_longest_lnum)
+    colnr_T	leftcol;
+    int		compute_longest_lnum;
 {
     /* no wrapping, no scrolling */
     if (curwin->w_p_wrap)
 	return FALSE;
 
-    if ((long_u)curwin->w_leftcol == scrollbar_value)
+    if (curwin->w_leftcol == leftcol)
 	return FALSE;
 
-    curwin->w_leftcol = (colnr_T)scrollbar_value;
+    curwin->w_leftcol = leftcol;
 
     /* When the line of the cursor is too short, move the cursor to the
-     * longest visible line.  Do a sanity check on "longest_lnum", just in
-     * case. */
+     * longest visible line. */
     if (vim_strchr(p_go, GO_HORSCROLL) == NULL
-	    && longest_lnum >= curwin->w_topline
-	    && longest_lnum < curwin->w_botline
-	    && !virtual_active())
+	    && !virtual_active()
+	    && leftcol > scroll_line_len(curwin->w_cursor.lnum))
     {
-	if (scrollbar_value > (long_u)scroll_line_len(curwin->w_cursor.lnum))
+	if (compute_longest_lnum)
+	{
+	    curwin->w_cursor.lnum = gui_find_longest_lnum();
+	    curwin->w_cursor.col = 0;
+	}
+	/* Do a sanity check on "longest_lnum", just in case. */
+	else if (longest_lnum >= curwin->w_topline
+		&& longest_lnum < curwin->w_botline)
 	{
 	    curwin->w_cursor.lnum = longest_lnum;
 	    curwin->w_cursor.col = 0;
--- a/src/gui_gtk_x11.c
+++ b/src/gui_gtk_x11.c
@@ -1700,7 +1700,13 @@ scroll_event(GtkWidget *widget,
 	case GDK_SCROLL_DOWN:
 	    button = MOUSE_5;
 	    break;
-	default: /* We don't care about left and right...  Yet. */
+	case GDK_SCROLL_LEFT:
+	    button = MOUSE_7;
+	    break;
+	case GDK_SCROLL_RIGHT:
+	    button = MOUSE_6;
+	    break;
+	default: /* This shouldn't happen */
 	    return FALSE;
     }
 
--- a/src/keymap.h
+++ b/src/keymap.h
@@ -228,8 +228,13 @@ enum key_extra
     , KE_S_XF3
     , KE_S_XF4
 
+    /* NOTE: The scroll wheel events are inverted: i.e. UP is the same as
+     * moving the actual scroll wheel down, LEFT is the same as moving the
+     * scroll wheel right. */
     , KE_MOUSEDOWN	/* scroll wheel pseudo-button Down */
     , KE_MOUSEUP	/* scroll wheel pseudo-button Up */
+    , KE_MOUSELEFT	/* scroll wheel pseudo-button Left */
+    , KE_MOUSERIGHT	/* scroll wheel pseudo-button Right */
 
     , KE_KINS		/* keypad Insert key */
     , KE_KDEL		/* keypad Delete key */
@@ -440,6 +445,8 @@ enum key_extra
 
 #define K_MOUSEDOWN	TERMCAP2KEY(KS_EXTRA, KE_MOUSEDOWN)
 #define K_MOUSEUP	TERMCAP2KEY(KS_EXTRA, KE_MOUSEUP)
+#define K_MOUSELEFT	TERMCAP2KEY(KS_EXTRA, KE_MOUSELEFT)
+#define K_MOUSERIGHT	TERMCAP2KEY(KS_EXTRA, KE_MOUSERIGHT)
 
 #define K_CSI		TERMCAP2KEY(KS_EXTRA, KE_CSI)
 #define K_SNR		TERMCAP2KEY(KS_EXTRA, KE_SNR)
--- a/src/message.c
+++ b/src/message.c
@@ -987,6 +987,7 @@ wait_return(redraw)
 				|| c == K_LEFTDRAG   || c == K_LEFTRELEASE
 				|| c == K_MIDDLEDRAG || c == K_MIDDLERELEASE
 				|| c == K_RIGHTDRAG  || c == K_RIGHTRELEASE
+				|| c == K_MOUSELEFT  || c == K_MOUSERIGHT
 				|| c == K_MOUSEDOWN  || c == K_MOUSEUP
 				|| (!mouse_has(MOUSE_RETURN)
 				    && mouse_row < msg_row
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -3158,6 +3158,8 @@ get_keystroke()
 		    || n == K_RIGHTRELEASE
 		    || n == K_MOUSEDOWN
 		    || n == K_MOUSEUP
+		    || n == K_MOUSELEFT
+		    || n == K_MOUSERIGHT
 		    || n == K_X1MOUSE
 		    || n == K_X1DRAG
 		    || n == K_X1RELEASE
--- a/src/misc2.c
+++ b/src/misc2.c
@@ -2362,8 +2362,12 @@ static struct key_name_entry
     {K_RIGHTMOUSE,	(char_u *)"RightMouse"},
     {K_RIGHTDRAG,	(char_u *)"RightDrag"},
     {K_RIGHTRELEASE,	(char_u *)"RightRelease"},
-    {K_MOUSEDOWN,	(char_u *)"MouseDown"},
-    {K_MOUSEUP,		(char_u *)"MouseUp"},
+    {K_MOUSEDOWN,	(char_u *)"ScrollWheelUp"},
+    {K_MOUSEUP,		(char_u *)"ScrollWheelDown"},
+    {K_MOUSELEFT,	(char_u *)"ScrollWheelRight"},
+    {K_MOUSERIGHT,	(char_u *)"ScrollWheelLeft"},
+    {K_MOUSEDOWN,	(char_u *)"MouseDown"}, /* OBSOLETE: Use	  */
+    {K_MOUSEUP,		(char_u *)"MouseUp"},	/* ScrollWheelXXX instead */
     {K_X1MOUSE,		(char_u *)"X1Mouse"},
     {K_X1DRAG,		(char_u *)"X1Drag"},
     {K_X1RELEASE,		(char_u *)"X1Release"},
--- a/src/normal.c
+++ b/src/normal.c
@@ -368,8 +368,10 @@ static const struct nv_cmd
     /* pound sign */
     {POUND,	nv_ident,	0,			0},
 #ifdef FEAT_MOUSE
-    {K_MOUSEUP, nv_mousescroll,	0,			TRUE},
-    {K_MOUSEDOWN, nv_mousescroll, 0,			FALSE},
+    {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},
@@ -3861,7 +3863,7 @@ add_to_showcmd(c)
 	K_LEFTMOUSE, K_LEFTDRAG, K_LEFTRELEASE,
 	K_MIDDLEMOUSE, K_MIDDLEDRAG, K_MIDDLERELEASE,
 	K_RIGHTMOUSE, K_RIGHTDRAG, K_RIGHTRELEASE,
-	K_MOUSEDOWN, K_MOUSEUP,
+	K_MOUSEDOWN, K_MOUSEUP, K_MOUSELEFT, K_MOUSERIGHT,
 	K_X1MOUSE, K_X1DRAG, K_X1RELEASE, K_X2MOUSE, K_X2DRAG, K_X2RELEASE,
 	K_CURSORHOLD,
 	0
@@ -4536,7 +4538,8 @@ nv_screengo(oap, dir, dist)
 /*
  * Mouse scroll wheel: Default action is to scroll three lines, or one page
  * when Shift or Ctrl is used.
- * K_MOUSEUP (cap->arg == TRUE) or K_MOUSEDOWN (cap->arg == FALSE)
+ * K_MOUSEUP (cap->arg == 1) or K_MOUSEDOWN (cap->arg == 0) or
+ * K_MOUSELEFT (cap->arg == -1) or K_MOUSERIGHT (cap->arg == -2)
  */
     static void
 nv_mousescroll(cap)
@@ -4559,16 +4562,36 @@ nv_mousescroll(cap)
     }
 # endif
 
-    if (mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL))
-    {
-	(void)onepage(cap->arg ? FORWARD : BACKWARD, 1L);
-    }
+    if (cap->arg == MSCR_UP || cap->arg == MSCR_DOWN)
+    {
+	if (mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL))
+	{
+	    (void)onepage(cap->arg ? FORWARD : BACKWARD, 1L);
+	}
+	else
+	{
+	    cap->count1 = 3;
+	    cap->count0 = 3;
+	    nv_scroll_line(cap);
+	}
+    }
+# ifdef FEAT_GUI
     else
     {
-	cap->count1 = 3;
-	cap->count0 = 3;
-	nv_scroll_line(cap);
-    }
+	/* Horizontal scroll - only allowed when 'wrap' is disabled */
+	if (!curwin->w_p_wrap)
+	{
+	    int val, step = 6;
+	    if (mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL))
+		step = W_WIDTH(curwin);
+	    val = curwin->w_leftcol + (cap->arg == MSCR_RIGHT ? -step : +step);
+	    if (val < 0)
+		val = 0;
+
+	    gui_do_horiz_scroll(val, TRUE);
+	}
+    }
+# endif
 
 # if defined(FEAT_GUI) && defined(FEAT_WINDOWS)
     curwin->w_redr_status = TRUE;
@@ -5166,7 +5189,7 @@ nv_hor_scrollbar(cap)
 	clearopbeep(cap->oap);
 
     /* Even if an operator was pending, we still want to scroll */
-    gui_do_horiz_scroll();
+    gui_do_horiz_scroll(scrollbar_value, FALSE);
 }
 #endif
 
--- a/src/proto/gui.pro
+++ b/src/proto/gui.pro
@@ -46,7 +46,7 @@ void gui_drag_scrollbar __ARGS((scrollba
 void gui_may_update_scrollbars __ARGS((void));
 void gui_update_scrollbars __ARGS((int force));
 int gui_do_scroll __ARGS((void));
-int gui_do_horiz_scroll __ARGS((void));
+int gui_do_horiz_scroll __ARGS((colnr_T leftcol, int compute_longest_lnum));
 void gui_check_colors __ARGS((void));
 guicolor_T gui_get_color __ARGS((char_u *name));
 int gui_get_lightness __ARGS((guicolor_T pixel));
--- a/src/screen.c
+++ b/src/screen.c
@@ -2822,7 +2822,7 @@ win_line(wp, lnum, startrow, endrow, noc
     int		is_concealing	= FALSE;
     int		boguscols	= 0;	/* nonexistent columns added to force
 					   wrapping */
-    int		vcol_off        = 0;	/* offset for concealed characters */
+    int		vcol_off	= 0;	/* offset for concealed characters */
     int		did_wcol	= FALSE;
 # define VCOL_HLC (vcol - vcol_off)
 #else
--- a/src/term.c
+++ b/src/term.c
@@ -4167,6 +4167,8 @@ check_termcode(max_offset, buf, buflen)
 		&& key_name[0] == (int)KS_EXTRA
 		&& (key_name[1] == (int)KE_X1MOUSE
 		    || key_name[1] == (int)KE_X2MOUSE
+		    || key_name[1] == (int)KE_MOUSELEFT
+		    || key_name[1] == (int)KE_MOUSERIGHT
 		    || key_name[1] == (int)KE_MOUSEDOWN
 		    || key_name[1] == (int)KE_MOUSEUP))
 	{
@@ -5054,7 +5056,7 @@ replace_termcodes(from, bufp, from_part,
     {
 	/*
 	 * If 'cpoptions' does not contain '<', check for special key codes,
-	 * like "<C-S-MouseLeft>"
+	 * like "<C-S-LeftMouse>"
 	 */
 	if (do_special && (do_lt || STRNCMP(src, "<lt>", 4) != 0))
 	{
--- a/src/vim.h
+++ b/src/vim.h
@@ -1721,12 +1721,18 @@ typedef int proftime_T;	    /* dummy for
 # define MOUSE_CTRL	0x10
 
 /* mouse buttons that are handled like a key press (GUI only) */
+/* Note that the scroll wheel keys are inverted: MOUSE_5 scrolls lines up but
+ * the result of this is that the window moves down, similarly MOUSE_6 scrolls
+ * columns left but the window moves right. */
 # define MOUSE_4	0x100	/* scroll wheel down */
 # define MOUSE_5	0x200	/* scroll wheel up */
 
 # define MOUSE_X1	0x300 /* Mouse-button X1 (6th) */
 # define MOUSE_X2	0x400 /* Mouse-button X2 */
 
+# define MOUSE_6	0x500	/* scroll wheel left */
+# define MOUSE_7	0x600	/* scroll wheel right */
+
 /* 0x20 is reserved by xterm */
 # define MOUSE_DRAG_XTERM   0x40
 
@@ -2180,4 +2186,10 @@ typedef int VimClipboard;	/* This is req
 #define BFA_WIPE	2	/* buffer is going to be wiped out */
 #define BFA_KEEP_UNDO	4	/* do not free undo information */
 
+/* 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 */