|
Karsten Hopp |
c535e2 |
To: vim-dev@vim.org
|
|
Karsten Hopp |
c535e2 |
Subject: Patch 7.0.155
|
|
Karsten Hopp |
c535e2 |
Fcc: outbox
|
|
Karsten Hopp |
c535e2 |
From: Bram Moolenaar <Bram@moolenaar.net>
|
|
Karsten Hopp |
c535e2 |
Mime-Version: 1.0
|
|
Karsten Hopp |
c535e2 |
Content-Type: text/plain; charset=ISO-8859-1
|
|
Karsten Hopp |
c535e2 |
Content-Transfer-Encoding: 8bit
|
|
Karsten Hopp |
c535e2 |
------------
|
|
Karsten Hopp |
c535e2 |
|
|
Karsten Hopp |
c535e2 |
Patch 7.0.155
|
|
Karsten Hopp |
c535e2 |
Problem: When getchar() returns a mouse button click there is no way to get
|
|
Karsten Hopp |
c535e2 |
the mouse coordinates.
|
|
Karsten Hopp |
c535e2 |
Solution: Add v:mouse_win, v:mouse_lnum and v:mouse_col.
|
|
Karsten Hopp |
c535e2 |
Files: runtime/doc/eval.txt, src/eval.c, src/vim.h
|
|
Karsten Hopp |
c535e2 |
|
|
Karsten Hopp |
c535e2 |
|
|
Karsten Hopp |
c535e2 |
*** ../vim-7.0.154/runtime/doc/eval.txt Tue Oct 3 14:43:31 2006
|
|
Karsten Hopp |
c535e2 |
--- runtime/doc/eval.txt Wed Nov 1 15:20:42 2006
|
|
Karsten Hopp |
c535e2 |
***************
|
|
Karsten Hopp |
c535e2 |
*** 1,4 ****
|
|
Karsten Hopp |
c535e2 |
! *eval.txt* For Vim version 7.0. Last change: 2006 Sep 22
|
|
Karsten Hopp |
c535e2 |
|
|
Karsten Hopp |
c535e2 |
|
|
Karsten Hopp |
c535e2 |
VIM REFERENCE MANUAL by Bram Moolenaar
|
|
Karsten Hopp |
c535e2 |
--- 1,4 ----
|
|
Karsten Hopp |
c535e2 |
! *eval.txt* For Vim version 7.0. Last change: 2006 Nov 01
|
|
Karsten Hopp |
c535e2 |
|
|
Karsten Hopp |
c535e2 |
|
|
Karsten Hopp |
c535e2 |
VIM REFERENCE MANUAL by Bram Moolenaar
|
|
Karsten Hopp |
c535e2 |
***************
|
|
Karsten Hopp |
c535e2 |
*** 1374,1379 ****
|
|
Karsten Hopp |
c535e2 |
--- 1380,1400 ----
|
|
Karsten Hopp |
c535e2 |
'guitabtooltip'. Only valid while one of these expressions is
|
|
Karsten Hopp |
c535e2 |
being evaluated. Read-only when in the |sandbox|.
|
|
Karsten Hopp |
c535e2 |
|
|
Karsten Hopp |
c535e2 |
+ *v:mouse_win* *mouse_win-variable*
|
|
Karsten Hopp |
c535e2 |
+ v:mouse_win Window number for a mouse click obtained with |getchar()|.
|
|
Karsten Hopp |
c535e2 |
+ First window has number 1, like with |winnr()|. The value is
|
|
Karsten Hopp |
c535e2 |
+ zero when there was no mouse button click.
|
|
Karsten Hopp |
c535e2 |
+
|
|
Karsten Hopp |
c535e2 |
+ *v:mouse_lnum* *mouse_lnum-variable*
|
|
Karsten Hopp |
c535e2 |
+ v:mouse_lnum Line number for a mouse click obtained with |getchar()|.
|
|
Karsten Hopp |
c535e2 |
+ This is the text line number, not the screen line number. The
|
|
Karsten Hopp |
c535e2 |
+ value is zero when there was no mouse button click.
|
|
Karsten Hopp |
c535e2 |
+
|
|
Karsten Hopp |
c535e2 |
+ *v:mouse_col* *mouse_col-variable*
|
|
Karsten Hopp |
c535e2 |
+ v:mouse_col Column number for a mouse click obtained with |getchar()|.
|
|
Karsten Hopp |
c535e2 |
+ This is the screen column number, like with |virtcol()|. The
|
|
Karsten Hopp |
c535e2 |
+ value is zero when there was no mouse button click.
|
|
Karsten Hopp |
c535e2 |
+
|
|
Karsten Hopp |
c535e2 |
*v:prevcount* *prevcount-variable*
|
|
Karsten Hopp |
c535e2 |
v:prevcount The count given for the last but one Normal mode command.
|
|
Karsten Hopp |
c535e2 |
This is the v:count value of the previous command. Useful if
|
|
Karsten Hopp |
c535e2 |
***************
|
|
Karsten Hopp |
c535e2 |
*** 2702,2707 ****
|
|
Karsten Hopp |
c535e2 |
--- 2728,2744 ----
|
|
Karsten Hopp |
c535e2 |
one-byte character it is the character itself as a number.
|
|
Karsten Hopp |
c535e2 |
Use nr2char() to convert it to a String.
|
|
Karsten Hopp |
c535e2 |
|
|
Karsten Hopp |
c535e2 |
+ When the user clicks a mouse button, the mouse event will be
|
|
Karsten Hopp |
c535e2 |
+ returned. The position can then be found in |v:mouse_col|,
|
|
Karsten Hopp |
c535e2 |
+ |v:mouse_lnum| and |v:mouse_win|. This example positions the
|
|
Karsten Hopp |
c535e2 |
+ mouse as it would normally happen: >
|
|
Karsten Hopp |
c535e2 |
+ let c = getchar()
|
|
Karsten Hopp |
c535e2 |
+ if c == "\<LeftMouse>" && v:mouse_win > 0
|
|
Karsten Hopp |
c535e2 |
+ exe v:mouse_win . "wincmd w"
|
|
Karsten Hopp |
c535e2 |
+ exe v:mouse_lnum
|
|
Karsten Hopp |
c535e2 |
+ exe "normal " . v:mouse_col . "|"
|
|
Karsten Hopp |
c535e2 |
+ endif
|
|
Karsten Hopp |
c535e2 |
+ <
|
|
Karsten Hopp |
c535e2 |
There is no prompt, you will somehow have to make clear to the
|
|
Karsten Hopp |
c535e2 |
user that a character has to be typed.
|
|
Karsten Hopp |
c535e2 |
There is no mapping for the character.
|
|
Karsten Hopp |
c535e2 |
*** ../vim-7.0.154/src/eval.c Tue Oct 24 13:51:47 2006
|
|
Karsten Hopp |
c535e2 |
--- src/eval.c Wed Nov 1 13:39:52 2006
|
|
Karsten Hopp |
c535e2 |
***************
|
|
Karsten Hopp |
c535e2 |
*** 343,348 ****
|
|
Karsten Hopp |
c535e2 |
--- 342,350 ----
|
|
Karsten Hopp |
c535e2 |
{VV_NAME("swapchoice", VAR_STRING), 0},
|
|
Karsten Hopp |
c535e2 |
{VV_NAME("swapcommand", VAR_STRING), VV_RO},
|
|
Karsten Hopp |
c535e2 |
{VV_NAME("char", VAR_STRING), VV_RO},
|
|
Karsten Hopp |
c535e2 |
+ {VV_NAME("mouse_win", VAR_NUMBER), 0},
|
|
Karsten Hopp |
c535e2 |
+ {VV_NAME("mouse_lnum", VAR_NUMBER), 0},
|
|
Karsten Hopp |
c535e2 |
+ {VV_NAME("mouse_col", VAR_NUMBER), 0},
|
|
Karsten Hopp |
c535e2 |
};
|
|
Karsten Hopp |
c535e2 |
|
|
Karsten Hopp |
c535e2 |
/* shorthand */
|
|
Karsten Hopp |
c535e2 |
***************
|
|
Karsten Hopp |
c535e2 |
*** 9855,9860 ****
|
|
Karsten Hopp |
c535e2 |
--- 9857,9866 ----
|
|
Karsten Hopp |
c535e2 |
--no_mapping;
|
|
Karsten Hopp |
c535e2 |
--allow_keys;
|
|
Karsten Hopp |
c535e2 |
|
|
Karsten Hopp |
c535e2 |
+ vimvars[VV_MOUSE_WIN].vv_nr = 0;
|
|
Karsten Hopp |
c535e2 |
+ vimvars[VV_MOUSE_LNUM].vv_nr = 0;
|
|
Karsten Hopp |
c535e2 |
+ vimvars[VV_MOUSE_COL].vv_nr = 0;
|
|
Karsten Hopp |
c535e2 |
+
|
|
Karsten Hopp |
c535e2 |
rettv->vval.v_number = n;
|
|
Karsten Hopp |
c535e2 |
if (IS_SPECIAL(n) || mod_mask != 0)
|
|
Karsten Hopp |
c535e2 |
{
|
|
Karsten Hopp |
c535e2 |
***************
|
|
Karsten Hopp |
c535e2 |
*** 9883,9888 ****
|
|
Karsten Hopp |
c535e2 |
--- 9889,9941 ----
|
|
Karsten Hopp |
c535e2 |
temp[i++] = NUL;
|
|
Karsten Hopp |
c535e2 |
rettv->v_type = VAR_STRING;
|
|
Karsten Hopp |
c535e2 |
rettv->vval.v_string = vim_strsave(temp);
|
|
Karsten Hopp |
c535e2 |
+
|
|
Karsten Hopp |
c535e2 |
+ #ifdef FEAT_MOUSE
|
|
Karsten Hopp |
c535e2 |
+ if (n == K_LEFTMOUSE
|
|
Karsten Hopp |
c535e2 |
+ || n == K_LEFTMOUSE_NM
|
|
Karsten Hopp |
c535e2 |
+ || n == K_LEFTDRAG
|
|
Karsten Hopp |
c535e2 |
+ || n == K_LEFTRELEASE
|
|
Karsten Hopp |
c535e2 |
+ || n == K_LEFTRELEASE_NM
|
|
Karsten Hopp |
c535e2 |
+ || n == K_MIDDLEMOUSE
|
|
Karsten Hopp |
c535e2 |
+ || n == K_MIDDLEDRAG
|
|
Karsten Hopp |
c535e2 |
+ || n == K_MIDDLERELEASE
|
|
Karsten Hopp |
c535e2 |
+ || n == K_RIGHTMOUSE
|
|
Karsten Hopp |
c535e2 |
+ || n == K_RIGHTDRAG
|
|
Karsten Hopp |
c535e2 |
+ || n == K_RIGHTRELEASE
|
|
Karsten Hopp |
c535e2 |
+ || n == K_X1MOUSE
|
|
Karsten Hopp |
c535e2 |
+ || n == K_X1DRAG
|
|
Karsten Hopp |
c535e2 |
+ || n == K_X1RELEASE
|
|
Karsten Hopp |
c535e2 |
+ || n == K_X2MOUSE
|
|
Karsten Hopp |
c535e2 |
+ || n == K_X2DRAG
|
|
Karsten Hopp |
c535e2 |
+ || n == K_X2RELEASE
|
|
Karsten Hopp |
c535e2 |
+ || n == K_MOUSEDOWN
|
|
Karsten Hopp |
c535e2 |
+ || n == K_MOUSEUP)
|
|
Karsten Hopp |
c535e2 |
+ {
|
|
Karsten Hopp |
c535e2 |
+ int row = mouse_row;
|
|
Karsten Hopp |
c535e2 |
+ int col = mouse_col;
|
|
Karsten Hopp |
c535e2 |
+ win_T *win;
|
|
Karsten Hopp |
c535e2 |
+ linenr_T lnum;
|
|
Karsten Hopp |
c535e2 |
+ # ifdef FEAT_WINDOWS
|
|
Karsten Hopp |
c535e2 |
+ win_T *wp;
|
|
Karsten Hopp |
c535e2 |
+ # endif
|
|
Karsten Hopp |
c535e2 |
+ int n = 1;
|
|
Karsten Hopp |
c535e2 |
+
|
|
Karsten Hopp |
c535e2 |
+ if (row >= 0 && col >= 0)
|
|
Karsten Hopp |
c535e2 |
+ {
|
|
Karsten Hopp |
c535e2 |
+ /* Find the window at the mouse coordinates and compute the
|
|
Karsten Hopp |
c535e2 |
+ * text position. */
|
|
Karsten Hopp |
c535e2 |
+ win = mouse_find_win(&row, &col);
|
|
Karsten Hopp |
c535e2 |
+ (void)mouse_comp_pos(win, &row, &col, &lnum);
|
|
Karsten Hopp |
c535e2 |
+ # ifdef FEAT_WINDOWS
|
|
Karsten Hopp |
c535e2 |
+ for (wp = firstwin; wp != win; wp = wp->w_next)
|
|
Karsten Hopp |
c535e2 |
+ ++n;
|
|
Karsten Hopp |
c535e2 |
+ # endif
|
|
Karsten Hopp |
c535e2 |
+ vimvars[VV_MOUSE_WIN].vv_nr = n;
|
|
Karsten Hopp |
c535e2 |
+ vimvars[VV_MOUSE_LNUM].vv_nr = lnum;
|
|
Karsten Hopp |
c535e2 |
+ vimvars[VV_MOUSE_COL].vv_nr = col + 1;
|
|
Karsten Hopp |
c535e2 |
+ }
|
|
Karsten Hopp |
c535e2 |
+ }
|
|
Karsten Hopp |
c535e2 |
+ #endif
|
|
Karsten Hopp |
c535e2 |
}
|
|
Karsten Hopp |
c535e2 |
}
|
|
Karsten Hopp |
c535e2 |
|
|
Karsten Hopp |
c535e2 |
*** ../vim-7.0.154/src/vim.h Tue Aug 29 18:16:37 2006
|
|
Karsten Hopp |
c535e2 |
--- src/vim.h Wed Nov 1 13:11:16 2006
|
|
Karsten Hopp |
c535e2 |
***************
|
|
Karsten Hopp |
c535e2 |
*** 1669,1675 ****
|
|
Karsten Hopp |
c535e2 |
#define VV_SWAPCHOICE 46
|
|
Karsten Hopp |
c535e2 |
#define VV_SWAPCOMMAND 47
|
|
Karsten Hopp |
c535e2 |
#define VV_CHAR 48
|
|
Karsten Hopp |
c535e2 |
! #define VV_LEN 49 /* number of v: vars */
|
|
Karsten Hopp |
c535e2 |
|
|
Karsten Hopp |
c535e2 |
#ifdef FEAT_CLIPBOARD
|
|
Karsten Hopp |
c535e2 |
|
|
Karsten Hopp |
c535e2 |
--- 1669,1678 ----
|
|
Karsten Hopp |
c535e2 |
#define VV_SWAPCHOICE 46
|
|
Karsten Hopp |
c535e2 |
#define VV_SWAPCOMMAND 47
|
|
Karsten Hopp |
c535e2 |
#define VV_CHAR 48
|
|
Karsten Hopp |
c535e2 |
! #define VV_MOUSE_WIN 49
|
|
Karsten Hopp |
c535e2 |
! #define VV_MOUSE_LNUM 50
|
|
Karsten Hopp |
c535e2 |
! #define VV_MOUSE_COL 51
|
|
Karsten Hopp |
c535e2 |
! #define VV_LEN 52 /* number of v: vars */
|
|
Karsten Hopp |
c535e2 |
|
|
Karsten Hopp |
c535e2 |
#ifdef FEAT_CLIPBOARD
|
|
Karsten Hopp |
c535e2 |
|
|
Karsten Hopp |
c535e2 |
*** ../vim-7.0.154/src/version.c Wed Nov 1 12:43:07 2006
|
|
Karsten Hopp |
c535e2 |
--- src/version.c Wed Nov 1 15:22:33 2006
|
|
Karsten Hopp |
c535e2 |
***************
|
|
Karsten Hopp |
c535e2 |
*** 668,669 ****
|
|
Karsten Hopp |
c535e2 |
--- 668,671 ----
|
|
Karsten Hopp |
c535e2 |
{ /* Add new patch number below this line */
|
|
Karsten Hopp |
c535e2 |
+ /**/
|
|
Karsten Hopp |
c535e2 |
+ 155,
|
|
Karsten Hopp |
c535e2 |
/**/
|
|
Karsten Hopp |
c535e2 |
|
|
Karsten Hopp |
c535e2 |
--
|
|
Karsten Hopp |
c535e2 |
hundred-and-one symptoms of being an internet addict:
|
|
Karsten Hopp |
c535e2 |
138. You develop a liking for cold coffee.
|
|
Karsten Hopp |
c535e2 |
|
|
Karsten Hopp |
c535e2 |
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
|
|
Karsten Hopp |
c535e2 |
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
|
|
Karsten Hopp |
c535e2 |
\\\ download, build and distribute -- http://www.A-A-P.org ///
|
|
Karsten Hopp |
c535e2 |
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|