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