]> git.pld-linux.org Git - packages/vim.git/blob - 7.0.155
- mark shell ${ble#...}, ${ble%...} substitutions
[packages/vim.git] / 7.0.155
1 To: vim-dev@vim.org
2 Subject: Patch 7.0.155
3 Fcc: outbox
4 From: Bram Moolenaar <Bram@moolenaar.net>
5 Mime-Version: 1.0
6 Content-Type: text/plain; charset=ISO-8859-1
7 Content-Transfer-Encoding: 8bit
8 ------------
9
10 Patch 7.0.155
11 Problem:    When getchar() returns a mouse button click there is no way to get
12             the mouse coordinates.
13 Solution:   Add v:mouse_win, v:mouse_lnum and v:mouse_col.
14 Files:      runtime/doc/eval.txt, src/eval.c, src/vim.h
15
16
17 *** ../vim-7.0.154/runtime/doc/eval.txt Tue Oct  3 14:43:31 2006
18 --- runtime/doc/eval.txt        Wed Nov  1 15:20:42 2006
19 ***************
20 *** 1,4 ****
21 ! *eval.txt*      For Vim version 7.0.  Last change: 2006 Sep 22
22   
23   
24                   VIM REFERENCE MANUAL    by Bram Moolenaar
25 --- 1,4 ----
26 ! *eval.txt*      For Vim version 7.0.  Last change: 2006 Nov 01
27   
28   
29                   VIM REFERENCE MANUAL    by Bram Moolenaar
30 ***************
31 *** 1374,1379 ****
32 --- 1380,1400 ----
33                 'guitabtooltip'.  Only valid while one of these expressions is
34                 being evaluated.  Read-only when in the |sandbox|.
35   
36 +                                       *v:mouse_win* *mouse_win-variable*
37 + v:mouse_win   Window number for a mouse click obtained with |getchar()|.
38 +               First window has number 1, like with |winnr()|.  The value is
39 +               zero when there was no mouse button click.
40
41 +                                       *v:mouse_lnum* *mouse_lnum-variable*
42 + v:mouse_lnum  Line number for a mouse click obtained with |getchar()|.
43 +               This is the text line number, not the screen line number.  The
44 +               value is zero when there was no mouse button click.
45
46 +                                       *v:mouse_col* *mouse_col-variable*
47 + v:mouse_col   Column number for a mouse click obtained with |getchar()|.
48 +               This is the screen column number, like with |virtcol()|.  The
49 +               value is zero when there was no mouse button click.
50
51                                         *v:prevcount* *prevcount-variable*
52   v:prevcount   The count given for the last but one Normal mode command.
53                 This is the v:count value of the previous command.  Useful if
54 ***************
55 *** 2702,2707 ****
56 --- 2728,2744 ----
57                 one-byte character it is the character itself as a number.
58                 Use nr2char() to convert it to a String.
59   
60 +               When the user clicks a mouse button, the mouse event will be
61 +               returned.  The position can then be found in |v:mouse_col|,
62 +               |v:mouse_lnum| and |v:mouse_win|.  This example positions the
63 +               mouse as it would normally happen: >
64 +                       let c = getchar()
65 +                       if c == "\<LeftMouse>" && v:mouse_win > 0
66 +                         exe v:mouse_win . "wincmd w"
67 +                         exe v:mouse_lnum
68 +                         exe "normal " . v:mouse_col . "|"
69 +                       endif
70 + <
71                 There is no prompt, you will somehow have to make clear to the
72                 user that a character has to be typed.
73                 There is no mapping for the character.
74 *** ../vim-7.0.154/src/eval.c   Tue Oct 24 13:51:47 2006
75 --- src/eval.c  Wed Nov  1 13:39:52 2006
76 ***************
77 *** 343,348 ****
78 --- 342,350 ----
79       {VV_NAME("swapchoice",     VAR_STRING), 0},
80       {VV_NAME("swapcommand",    VAR_STRING), VV_RO},
81       {VV_NAME("char",           VAR_STRING), VV_RO},
82 +     {VV_NAME("mouse_win",      VAR_NUMBER), 0},
83 +     {VV_NAME("mouse_lnum",     VAR_NUMBER), 0},
84 +     {VV_NAME("mouse_col",      VAR_NUMBER), 0},
85   };
86   
87   /* shorthand */
88 ***************
89 *** 9855,9860 ****
90 --- 9857,9866 ----
91       --no_mapping;
92       --allow_keys;
93   
94 +     vimvars[VV_MOUSE_WIN].vv_nr = 0;
95 +     vimvars[VV_MOUSE_LNUM].vv_nr = 0;
96 +     vimvars[VV_MOUSE_COL].vv_nr = 0;
97
98       rettv->vval.v_number = n;
99       if (IS_SPECIAL(n) || mod_mask != 0)
100       {
101 ***************
102 *** 9883,9888 ****
103 --- 9889,9941 ----
104         temp[i++] = NUL;
105         rettv->v_type = VAR_STRING;
106         rettv->vval.v_string = vim_strsave(temp);
107
108 + #ifdef FEAT_MOUSE
109 +       if (n == K_LEFTMOUSE
110 +               || n == K_LEFTMOUSE_NM
111 +               || n == K_LEFTDRAG
112 +               || n == K_LEFTRELEASE
113 +               || n == K_LEFTRELEASE_NM
114 +               || n == K_MIDDLEMOUSE
115 +               || n == K_MIDDLEDRAG
116 +               || n == K_MIDDLERELEASE
117 +               || n == K_RIGHTMOUSE
118 +               || n == K_RIGHTDRAG
119 +               || n == K_RIGHTRELEASE
120 +               || n == K_X1MOUSE
121 +               || n == K_X1DRAG
122 +               || n == K_X1RELEASE
123 +               || n == K_X2MOUSE
124 +               || n == K_X2DRAG
125 +               || n == K_X2RELEASE
126 +               || n == K_MOUSEDOWN
127 +               || n == K_MOUSEUP)
128 +       {
129 +           int         row = mouse_row;
130 +           int         col = mouse_col;
131 +           win_T       *win;
132 +           linenr_T    lnum;
133 + # ifdef FEAT_WINDOWS
134 +           win_T       *wp;
135 + # endif
136 +           int         n = 1;
137
138 +           if (row >= 0 && col >= 0)
139 +           {
140 +               /* Find the window at the mouse coordinates and compute the
141 +                * text position. */
142 +               win = mouse_find_win(&row, &col);
143 +               (void)mouse_comp_pos(win, &row, &col, &lnum);
144 + # ifdef FEAT_WINDOWS
145 +               for (wp = firstwin; wp != win; wp = wp->w_next)
146 +                   ++n;
147 + # endif
148 +               vimvars[VV_MOUSE_WIN].vv_nr = n;
149 +               vimvars[VV_MOUSE_LNUM].vv_nr = lnum;
150 +               vimvars[VV_MOUSE_COL].vv_nr = col + 1;
151 +           }
152 +       }
153 + #endif
154       }
155   }
156   
157 *** ../vim-7.0.154/src/vim.h    Tue Aug 29 18:16:37 2006
158 --- src/vim.h   Wed Nov  1 13:11:16 2006
159 ***************
160 *** 1669,1675 ****
161   #define VV_SWAPCHOICE 46
162   #define VV_SWAPCOMMAND        47
163   #define VV_CHAR               48
164 ! #define VV_LEN                49      /* number of v: vars */
165   
166   #ifdef FEAT_CLIPBOARD
167   
168 --- 1669,1678 ----
169   #define VV_SWAPCHOICE 46
170   #define VV_SWAPCOMMAND        47
171   #define VV_CHAR               48
172 ! #define VV_MOUSE_WIN  49
173 ! #define VV_MOUSE_LNUM   50
174 ! #define VV_MOUSE_COL  51
175 ! #define VV_LEN                52      /* number of v: vars */
176   
177   #ifdef FEAT_CLIPBOARD
178   
179 *** ../vim-7.0.154/src/version.c        Wed Nov  1 12:43:07 2006
180 --- src/version.c       Wed Nov  1 15:22:33 2006
181 ***************
182 *** 668,669 ****
183 --- 668,671 ----
184   {   /* Add new patch number below this line */
185 + /**/
186 +     155,
187   /**/
188
189 -- 
190 hundred-and-one symptoms of being an internet addict:
191 138. You develop a liking for cold coffee.
192
193  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
194 ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
195 \\\        download, build and distribute -- http://www.A-A-P.org        ///
196  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
This page took 0.039263 seconds and 3 git commands to generate.