I've uploaded a new version to the sourceforge script area. It now
can read and react to the text in the statusline and tabline as it
appears on the screen.
On 5/12/06, Eric Arnold <[EMAIL PROTECTED]> wrote:
Here is my first working version of a mouse function option, i.e.
:set mousefunc=MyFunc
It delivers all the info I could think of. It comes with a test
script which uses the mouse to move tabs, and recognize text hotspots
by mouse-over.
Here is the doc.
*'mousefunction'* *'mfn'*
'mousefunc' 'mfn' string (default empty)
global
{not in Vi}
When nonempty, this option calls the given function when mouse events
(click, drag, move, etc.) are detected. The function should accept
these arguments:
>
MouseFunc( mouse_key,
\ buf_row, buf_col, buf_vcol,
\ mouse_row, mouse_col,
\ x, y, area )
<
"mouse_key" is a string containing up to 6 chars. It will match
against a string like: a:mouse_key == "\<LeftMouse>".
"mouse_key" can be empty, particularly when cursor-move-only events
are delivered.
"buf_row/col/vcol" should match line(".") and col(".") if you were
to click in a buffer at that point.
"mouse_row/col" are independent of windows and buffers.
The "x" and "y" are in pixels, and can be negative, when that
information isn't available (see also |mousefocus| to have "x" and
"y" track the mouse cursor).
"area" is Vim's idea of where the mouse is. Values can be:
"IN_BUFFER", "IN_UNKNOWN", "IN_SEP_LINE", "IN_STATUS_LINE".
The function should return 0 to consume the mouse click, or 1 to
pass it on transparently.
The |mousefunc| option is set empty for the duration of the call to
prevent recursion. Setting it again during the call could have
unexpected problems.
It intercepts the mouse events at a low level, which has its good
and bad points. The good is that you get the mouse events before
other restrictions like statusline, tabline, empty regions, etc.,
and receive mouse events while in any mode. The bad is that you
have to watch out for things like recursion errors (i.e. calling
getchar() from a script function while |mousefunc| is set).
This function is called often when the mouse is moving, so attention
should be given to returning early out of as many cycles as
possible.
At the moment, drag and release events are approximated based on the
last primary event (i.e. <leftmouse> or <rightmouse> ).