On Sat, 21 Oct 2006 at 11:19am, Hari Krishna Dara wrote:

>
> On Sat, 21 Oct 2006 at 1:59pm, Bram Moolenaar wrote:
>
> >
> > Hari Krishna Dara wrote:
> >
> > > When maps for mouse clicks are executed, can we have the location (in
> > > the form of line and column number) made available through v: variables?
> > > I just observed that getchar() works even with mouse clicks, but this is
> > > almost useless without knowing where the user clicked. Capturing mouse
> > > clicks along with <expr> maps or getchar() can do wonders if the mouse
> > > click position is also available.
> >
> > Good point, getchar() should somehow make the position of the click
> > available.
> >
> > It's not that easy, since the click could be in any of the windows.  I
> > suppose we need:
> >     v:mouse_window
> >     v:mouse_column
> >     v:mouse_line
> >
> > The position could be in screen columns and lines, or in text column and
> > line.  I suppose text position is more useful.  You wouldn't need the
> > position of a click halfway a tab, right?
>
> For most purposes the window and text position is all that matters, but
> there can be some interesting possibilities if clicks outside any buffer
> (such as at the command-line the way inputlist() works) can also be
> made available (using something like v:mouse_region that can have
> "window", "tab", "cmdline").

Also want to propose that these v: variables should be settable by the
scripts in case the RHS of a map is a <Mouse> key. E.g., the following
should work (note: it is just indented to show the usage, not
particularly a useful example):

" Make <F12> always <RightMouse> at the center of the current window.
imap <expr> <F12> CenterRightMouse()
function! CenterRightMouse()
  let v:mouse_window = winnr()
  let v:mouse_line = winheight('.')/2
  let v:mouse_col = winwidth('.')/2
  return "\<RightMouse>\<RightRelease>"
endfunction

-- 
Thanks,
Hari

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Reply via email to