summaryrefslogtreecommitdiff
path: root/data/vim/patches/8.1.1155
blob: 631083f042056c8a53bbd21e84309830e68b118c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
To: vim_dev@googlegroups.com
Subject: Patch 8.1.1155
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 8.1.1155
Problem:    Termcodes tests can be improved.
Solution:   Add helper functions to simplify tests.  Dragging statusline for
            xterm and sgr. (Dominique Pelle, closes #4237)
Files:	    src/testdir/test_termcodes.vim


*** ../vim-8.1.1154/src/testdir/test_termcodes.vim	2019-04-09 21:51:59.177300145 +0200
--- src/testdir/test_termcodes.vim	2019-04-11 23:53:26.777268934 +0200
***************
*** 5,43 ****
    finish
  endif
  
  func Test_xterm_mouse_click()
    new
    let save_mouse = &mouse
    let save_term = &term
    let save_ttymouse = &ttymouse
!   set mouse=a
!   set term=xterm
    call setline(1, ['line 1', 'line 2', 'line 3 is a bit longer'])
-   redraw
- 
-   " Xterm mouse click
-   set ttymouse=xterm
-   let button = 0x20  " left down
-   let row = 2 + 32
-   let col = 6 + 32
-   call feedkeys("\<Esc>[M" .. list2str([button, col, row]), 'Lx!')
- 
-   let button = 0x23  " release
-   call feedkeys("\<Esc>[M" .. list2str([button, col, row]), 'Lx!')
- 
-   call assert_equal([0, 2, 6, 0], getpos('.'))
- 
-   " SGR mouse click
-   set ttymouse=sgr
-   let button = 0  " left down
-   let row = 3
-   let col = 9
-   call feedkeys(printf("\<Esc>[<%d;%d;%dM", button, col, row), 'Lx!')
- 
-   let button = 3  " release
-   call feedkeys(printf("\<Esc>[<%d;%d;%dm", button, col, row), 'Lx!')
  
!   call assert_equal([0, 3, 9, 0], getpos('.'))
  
    let &mouse = save_mouse
    let &term = save_term
--- 5,65 ----
    finish
  endif
  
+ " Helper function to emit a terminal escape code.
+ func TerminalEscapeCode(code_xterm, code_sgr, row, col, m)
+   if &ttymouse ==# 'xterm'
+     " need to use byte encoding here.
+     let str = list2str([a:code_xterm, a:col + 0x20, a:row + 0x20])
+     if has('iconv')
+       let bytes = iconv(str, 'utf-8', 'latin1')
+     else
+       " Hopefully the numbers are not too big.
+       let bytes = str
+     endif
+     call feedkeys("\<Esc>[M" .. bytes, 'Lx!')
+   elseif &ttymouse ==# 'sgr'
+     call feedkeys(printf("\<Esc>[<%d;%d;%d%s", a:code_sgr, a:col, a:row, a:m), 'Lx!')
+   endif
+ endfunc
+ 
+ func MouseLeftClick(row, col)
+   call TerminalEscapeCode(0x20, 0, a:row, a:col, 'M')
+ endfunc
+ 
+ func MouseLeftRelease(row, col)
+   call TerminalEscapeCode(0x23, 3, a:row, a:col, 'm')
+ endfunc
+ 
+ func MouseLeftDrag(row, col)
+   call TerminalEscapeCode(0x43, 0x20, a:row, a:col, 'M')
+ endfunc
+ 
+ func MouseWheelUp(row, col)
+   call TerminalEscapeCode(0x40, 0x40, a:row, a:col, 'M')
+ endfunc
+ 
+ func MouseWheelDown(row, col)
+   call TerminalEscapeCode(0x41, 0x41, a:row, a:col, 'M')
+ endfunc
+ 
  func Test_xterm_mouse_click()
    new
    let save_mouse = &mouse
    let save_term = &term
    let save_ttymouse = &ttymouse
!   set mouse=a term=xterm
    call setline(1, ['line 1', 'line 2', 'line 3 is a bit longer'])
  
!   for ttymouse_val in ['xterm', 'sgr']
!     exe 'set ttymouse=' . ttymouse_val
!     go
!     call assert_equal([0, 1, 1, 0], getpos('.'))
!     let row = 2
!     let col = 6
!     call MouseLeftClick(row, col)
!     call MouseLeftRelease(row, col)
!     call assert_equal([0, 2, 6, 0], getpos('.'))
!   endfor
  
    let &mouse = save_mouse
    let &term = save_term
***************
*** 50,110 ****
    let save_mouse = &mouse
    let save_term = &term
    let save_ttymouse = &ttymouse
!   set mouse=a
!   set term=xterm
    call setline(1, range(1, 100))
  
!   " Test Xterm mouse wheel.
!   set ttymouse=xterm
!   let button = 0x41 " wheel down.
!   let row = 1 + 32  " cursor position for mouse wheel is not relevant.
!   let col = 1 + 32
! 
!   call assert_equal(1, line('w0'))
!   call assert_equal([0, 1, 1, 0], getpos('.'))
!   call feedkeys("\<Esc>[M" .. list2str([button, col, row]), 'Lx!')
!   call assert_equal(4, line('w0'))
!   call assert_equal([0, 4, 1, 0], getpos('.'))
!   call feedkeys("\<Esc>[M" .. list2str([button, col, row]), 'Lx!')
!   call assert_equal(7, line('w0'))
!   call assert_equal([0, 7, 1, 0], getpos('.'))
! 
!   let button = 0x40  " wheel up.
! 
!   call feedkeys("\<Esc>[M" .. list2str([button, col, row]), 'Lx!')
!   call assert_equal(4, line('w0'))
!   call assert_equal([0, 7, 1, 0], getpos('.'))
!   call feedkeys("\<Esc>[M" .. list2str([button, col, row]), 'Lx!')
!   call assert_equal(1, line('w0'))
!   call assert_equal([0, 7, 1, 0], getpos('.'))
! 
!   " Test SGR mouse wheel.
!   set ttymouse=sgr
!   go
!   let button = 0x41 " wheel down.
!   let row = 1       " cursor position for mouse wheel is not relevant.
!   let col = 1
! 
!   call assert_equal(1, line('w0'))
!   call assert_equal([0, 1, 1, 0], getpos('.'))
!   call feedkeys(printf("\<Esc>[<%d;%d;%dM", button, col, row), 'Lx!')
!   call assert_equal(4, line('w0'))
!   call assert_equal([0, 4, 1, 0], getpos('.'))
!   call feedkeys(printf("\<Esc>[<%d;%d;%dM", button, col, row), 'Lx!')
!   call assert_equal(7, line('w0'))
!   call assert_equal([0, 7, 1, 0], getpos('.'))
! 
!   let button = 0x40  " wheel up.
! 
!   call feedkeys(printf("\<Esc>[<%d;%d;%dM", button, col, row), 'Lx!')
!   call assert_equal(4, line('w0'))
!   call assert_equal([0, 7, 1, 0], getpos('.'))
!   call feedkeys(printf("\<Esc>[<%d;%d;%dM", button, col, row), 'Lx!')
!   call assert_equal(1, line('w0'))
!   call assert_equal([0, 7, 1, 0], getpos('.'))
!   call feedkeys(printf("\<Esc>[<%d;%d;%dM", button, col, row), 'Lx!')
!   call assert_equal(1, line('w0'))
!   call assert_equal([0, 7, 1, 0], getpos('.'))
  
    let &mouse = save_mouse
    let &term = save_term
--- 72,102 ----
    let save_mouse = &mouse
    let save_term = &term
    let save_ttymouse = &ttymouse
!   set mouse=a term=xterm
    call setline(1, range(1, 100))
  
!   for ttymouse_val in ['xterm', 'sgr']
!     exe 'set ttymouse=' . ttymouse_val
!     go
!     call assert_equal(1, line('w0'))
!     call assert_equal([0, 1, 1, 0], getpos('.'))
! 
!     call MouseWheelDown(1, 1)
!     call assert_equal(4, line('w0'))
!     call assert_equal([0, 4, 1, 0], getpos('.'))
! 
!     call MouseWheelDown(1, 1)
!     call assert_equal(7, line('w0'))
!     call assert_equal([0, 7, 1, 0], getpos('.'))
! 
!     call MouseWheelUp(1, 1)
!     call assert_equal(4, line('w0'))
!     call assert_equal([0, 7, 1, 0], getpos('.'))
! 
!     call MouseWheelUp(1, 1)
!     call assert_equal(1, line('w0'))
!     call assert_equal([0, 7, 1, 0], getpos('.'))
!   endfor
  
    let &mouse = save_mouse
    let &term = save_term
***************
*** 116,170 ****
    let save_mouse = &mouse
    let save_term = &term
    let save_ttymouse = &ttymouse
!   set mouse=a
!   set term=xterm
!   set ttymouse=sgr
! 
!   " Split horizontally and test dragging the horizontal window separator.
!   split
!   let rowseparator = winheight(0) + 1
! 
!   let button = 0  " left down.
!   let row = rowseparator
!   let col = 1
!   call feedkeys(printf("\<Esc>[<%d;%d;%dM", button, col, row), 'Lx!')
! 
!   let drag = 32
!   let row -= 1
!   call feedkeys(printf("\<Esc>[<%d;%d;%dM", drag, col, row), 'Lx!')
!   call assert_equal(rowseparator - 1, winheight(0) + 1)
!   let row += 1
!   call feedkeys(printf("\<Esc>[<%d;%d;%dM", drag, col, row), 'Lx!')
!   call assert_equal(rowseparator, winheight(0) + 1)
! 
!   let release = 3
!   call feedkeys(printf("\<Esc>[<%d;%d;%dm", release, col, row), 'Lx!')
!   call assert_equal(rowseparator, winheight(0) + 1)
  
!   bwipe!
  
!   " Split vertically and test dragging the vertical window separator.
!   vsplit
!   let colseparator = winwidth(0) + 1
! 
!   let button = 0
!   let row = 1
!   let col = colseparator
!   call feedkeys(printf("\<Esc>[<%d;%d;%dM", button, col, row), 'Lx!')
! 
!   let drag = 32
!   let col -= 1
!   call feedkeys(printf("\<Esc>[<%d;%d;%dM", drag, col, row), 'Lx!')
!   call assert_equal(colseparator - 1, winwidth(0) + 1)
!   let col += 1
!   call feedkeys(printf("\<Esc>[<%d;%d;%dM", drag, col, row), 'Lx!')
!   call assert_equal(colseparator, winwidth(0) + 1)
! 
!   let release = 3
!   call feedkeys(printf("\<Esc>[<%d;%d;%dm", release, col, row), 'Lx!')
!   call assert_equal(colseparator, winwidth(0) + 1)
  
-   bwipe!
    let &mouse = save_mouse
    let &term = save_term
    let &ttymouse = save_ttymouse
--- 108,187 ----
    let save_mouse = &mouse
    let save_term = &term
    let save_ttymouse = &ttymouse
!   set mouse=a term=xterm
  
!   for ttymouse_val in ['xterm', 'sgr']
!     exe 'set ttymouse=' . ttymouse_val
  
!     " Split horizontally and test dragging the horizontal window separator.
!     split
!     let rowseparator = winheight(0) + 1
!     let row = rowseparator
!     let col = 1
!     call MouseLeftClick(row, col)
! 
!     let row -= 1
!     call MouseLeftDrag(row, col)
!     call assert_equal(rowseparator - 1, winheight(0) + 1)
!     let row += 1
!     call MouseLeftDrag(row, col)
!     call assert_equal(rowseparator, winheight(0) + 1)
!     call MouseLeftRelease(row, col)
!     call assert_equal(rowseparator, winheight(0) + 1)
! 
!     bwipe!
! 
!     " Split vertically and test dragging the vertical window separator.
!     vsplit
!     let colseparator = winwidth(0) + 1
! 
!     let row = 1
!     let col = colseparator
!     call MouseLeftClick(row, col)
!     let col -= 1
!     call MouseLeftDrag(row, col)
!     call assert_equal(colseparator - 1, winwidth(0) + 1)
!     let col += 1
!     call MouseLeftDrag(row, col)
!     call assert_equal(colseparator, winwidth(0) + 1)
!     call MouseLeftRelease(row, col)
!     call assert_equal(colseparator, winwidth(0) + 1)
! 
!     bwipe!
!   endfor
! 
!   let &mouse = save_mouse
!   let &term = save_term
!   let &ttymouse = save_ttymouse
! endfunc
! 
! func Test_xterm_mouse_drag_statusline()
!   let save_mouse = &mouse
!   let save_term = &term
!   let save_ttymouse = &ttymouse
!   set mouse=a term=xterm
! 
!   for ttymouse_val in ['xterm', 'sgr']
!     exe 'set ttymouse=' . ttymouse_val
! 
!     call assert_equal(1, &cmdheight)
!     let rowstatusline = winheight(0) + 1
!     let row = rowstatusline
!     let col = 1
!     call MouseLeftClick(row, col)
!     let row -= 1
!     call MouseLeftDrag(row, col)
!     call assert_equal(2, &cmdheight)
!     call assert_equal(rowstatusline - 1, winheight(0) + 1)
!     let row += 1
!     call MouseLeftDrag(row, col)
!     call assert_equal(1, &cmdheight)
!     call assert_equal(rowstatusline, winheight(0) + 1)
!     call MouseLeftRelease(row, col)
!     call assert_equal(1, &cmdheight)
!     call assert_equal(rowstatusline, winheight(0) + 1)
!   endfor
  
    let &mouse = save_mouse
    let &term = save_term
    let &ttymouse = save_ttymouse
*** ../vim-8.1.1154/src/version.c	2019-04-11 20:14:52.448664389 +0200
--- src/version.c	2019-04-11 23:02:25.131500056 +0200
***************
*** 773,774 ****
--- 773,776 ----
  {   /* Add new patch number below this line */
+ /**/
+     1155,
  /**/

-- 
Did you hear about the new 3 million dollar West Virginia State Lottery?
The winner gets 3 dollars a year for a million years.

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///