Mercurial > vim
comparison src/testdir/test_popupwin.vim @ 17387:2558f90045e5 v8.1.1692
patch 8.1.1692: using *{} for literal dict is not backwards compatible
commit https://github.com/vim/vim/commit/b8be54dcc517c9d57b62409945b7d4b90b6c3071
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jul 14 18:22:59 2019 +0200
patch 8.1.1692: using *{} for literal dict is not backwards compatible
Problem: Using *{} for literal dict is not backwards compatible. (Yasuhiro
Matsumoto)
Solution: Use ~{} instead.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 14 Jul 2019 18:30:04 +0200 |
parents | 6604ecb7a615 |
children | 40417757dffd |
comparison
equal
deleted
inserted
replaced
17386:b46cfa993bcf | 17387:2558f90045e5 |
---|---|
12 let lines =<< trim END | 12 let lines =<< trim END |
13 call setline(1, range(1, 100)) | 13 call setline(1, range(1, 100)) |
14 hi PopupColor1 ctermbg=lightblue | 14 hi PopupColor1 ctermbg=lightblue |
15 hi PopupColor2 ctermbg=lightcyan | 15 hi PopupColor2 ctermbg=lightcyan |
16 hi Comment ctermfg=red | 16 hi Comment ctermfg=red |
17 call prop_type_add('comment', *{highlight: 'Comment'}) | 17 call prop_type_add('comment', ~{highlight: 'Comment'}) |
18 let winid = popup_create('hello there', *{line: 3, col: 11, minwidth: 20, highlight: 'PopupColor1'}) | 18 let winid = popup_create('hello there', ~{line: 3, col: 11, minwidth: 20, highlight: 'PopupColor1'}) |
19 let winid2 = popup_create(['another one', 'another two', 'another three'], *{line: 3, col: 25, minwidth: 20}) | 19 let winid2 = popup_create(['another one', 'another two', 'another three'], ~{line: 3, col: 25, minwidth: 20}) |
20 call setwinvar(winid2, '&wincolor', 'PopupColor2') | 20 call setwinvar(winid2, '&wincolor', 'PopupColor2') |
21 END | 21 END |
22 call writefile(lines, 'XtestPopup') | 22 call writefile(lines, 'XtestPopup') |
23 let buf = RunVimInTerminal('-S XtestPopup', *{rows: 10}) | 23 let buf = RunVimInTerminal('-S XtestPopup', ~{rows: 10}) |
24 call VerifyScreenDump(buf, 'Test_popupwin_01', {}) | 24 call VerifyScreenDump(buf, 'Test_popupwin_01', {}) |
25 | 25 |
26 " Add a tabpage | 26 " Add a tabpage |
27 call term_sendkeys(buf, ":tabnew\<CR>") | 27 call term_sendkeys(buf, ":tabnew\<CR>") |
28 call term_sendkeys(buf, ":let popupwin = popup_create([" | 28 call term_sendkeys(buf, ":let popupwin = popup_create([" |
29 \ .. "*{text: 'other tab'}," | 29 \ .. "~{text: 'other tab'}," |
30 \ .. "*{text: 'a comment line', props: [*{" | 30 \ .. "~{text: 'a comment line', props: [~{" |
31 \ .. "col: 3, length: 7, minwidth: 20, type: 'comment'" | 31 \ .. "col: 3, length: 7, minwidth: 20, type: 'comment'" |
32 \ .. "}]}," | 32 \ .. "}]}," |
33 \ .. "], *{line: 4, col: 9, minwidth: 20})\<CR>") | 33 \ .. "], ~{line: 4, col: 9, minwidth: 20})\<CR>") |
34 call VerifyScreenDump(buf, 'Test_popupwin_02', {}) | 34 call VerifyScreenDump(buf, 'Test_popupwin_02', {}) |
35 | 35 |
36 " switch back to first tabpage | 36 " switch back to first tabpage |
37 call term_sendkeys(buf, "gt") | 37 call term_sendkeys(buf, "gt") |
38 call VerifyScreenDump(buf, 'Test_popupwin_03', {}) | 38 call VerifyScreenDump(buf, 'Test_popupwin_03', {}) |
46 call term_sendkeys(buf, ":set columns=12\<CR>") | 46 call term_sendkeys(buf, ":set columns=12\<CR>") |
47 call VerifyScreenDump(buf, 'Test_popupwin_04a', {}) | 47 call VerifyScreenDump(buf, 'Test_popupwin_04a', {}) |
48 call term_sendkeys(buf, ":let &columns = cols\<CR>") | 48 call term_sendkeys(buf, ":let &columns = cols\<CR>") |
49 | 49 |
50 " resize popup, show empty line at bottom | 50 " resize popup, show empty line at bottom |
51 call term_sendkeys(buf, ":call popup_move(popupwin, *{minwidth: 15, maxwidth: 25, minheight: 3, maxheight: 5})\<CR>") | 51 call term_sendkeys(buf, ":call popup_move(popupwin, ~{minwidth: 15, maxwidth: 25, minheight: 3, maxheight: 5})\<CR>") |
52 call term_sendkeys(buf, ":redraw\<CR>") | 52 call term_sendkeys(buf, ":redraw\<CR>") |
53 call VerifyScreenDump(buf, 'Test_popupwin_05', {}) | 53 call VerifyScreenDump(buf, 'Test_popupwin_05', {}) |
54 | 54 |
55 " show not fitting line at bottom | 55 " show not fitting line at bottom |
56 call term_sendkeys(buf, ":call setbufline(winbufnr(popupwin), 3, 'this line will not fit here')\<CR>") | 56 call term_sendkeys(buf, ":call setbufline(winbufnr(popupwin), 3, 'this line will not fit here')\<CR>") |
57 call term_sendkeys(buf, ":redraw\<CR>") | 57 call term_sendkeys(buf, ":redraw\<CR>") |
58 call VerifyScreenDump(buf, 'Test_popupwin_06', {}) | 58 call VerifyScreenDump(buf, 'Test_popupwin_06', {}) |
59 | 59 |
60 " move popup over ruler | 60 " move popup over ruler |
61 call term_sendkeys(buf, ":set cmdheight=2\<CR>") | 61 call term_sendkeys(buf, ":set cmdheight=2\<CR>") |
62 call term_sendkeys(buf, ":call popup_move(popupwin, *{line: 7, col: 55})\<CR>") | 62 call term_sendkeys(buf, ":call popup_move(popupwin, ~{line: 7, col: 55})\<CR>") |
63 call term_sendkeys(buf, ":\<CR>") | |
63 call VerifyScreenDump(buf, 'Test_popupwin_07', {}) | 64 call VerifyScreenDump(buf, 'Test_popupwin_07', {}) |
64 | 65 |
65 " clear all popups after moving the cursor a bit, so that ruler is updated | 66 " clear all popups after moving the cursor a bit, so that ruler is updated |
66 call term_sendkeys(buf, "axxx\<Esc>") | 67 call term_sendkeys(buf, "axxx\<Esc>") |
67 call term_wait(buf) | 68 call term_wait(buf) |
81 endif | 82 endif |
82 | 83 |
83 for iter in range(0, 1) | 84 for iter in range(0, 1) |
84 let lines =<< trim END | 85 let lines =<< trim END |
85 call setline(1, range(1, 100)) | 86 call setline(1, range(1, 100)) |
86 call popup_create('hello border', *{line: 2, col: 3, border: []}) | 87 call popup_create('hello border', ~{line: 2, col: 3, border: []}) |
87 call popup_create('hello padding', *{line: 2, col: 23, padding: []}) | 88 call popup_create('hello padding', ~{line: 2, col: 23, padding: []}) |
88 call popup_create('hello both', *{line: 2, col: 43, border: [], padding: []}) | 89 call popup_create('hello both', ~{line: 2, col: 43, border: [], padding: []}) |
89 call popup_create('border TL', *{line: 6, col: 3, border: [1, 0, 0, 4]}) | 90 call popup_create('border TL', ~{line: 6, col: 3, border: [1, 0, 0, 4]}) |
90 call popup_create('paddings', *{line: 6, col: 23, padding: [1, 3, 2, 4]}) | 91 call popup_create('paddings', ~{line: 6, col: 23, padding: [1, 3, 2, 4]}) |
91 call popup_create('wrapped longer text', *{line: 8, col: 55, padding: [0, 3, 0, 3], border: [0, 1, 0, 1]}) | 92 call popup_create('wrapped longer text', ~{line: 8, col: 55, padding: [0, 3, 0, 3], border: [0, 1, 0, 1]}) |
92 call popup_create('right aligned text', *{line: 11, col: 56, wrap: 0, padding: [0, 3, 0, 3], border: [0, 1, 0, 1]}) | 93 call popup_create('right aligned text', ~{line: 11, col: 56, wrap: 0, padding: [0, 3, 0, 3], border: [0, 1, 0, 1]}) |
93 END | 94 END |
94 call insert(lines, iter == 1 ? '' : 'set enc=latin1') | 95 call insert(lines, iter == 1 ? '' : 'set enc=latin1') |
95 call writefile(lines, 'XtestPopupBorder') | 96 call writefile(lines, 'XtestPopupBorder') |
96 let buf = RunVimInTerminal('-S XtestPopupBorder', *{rows: 15}) | 97 let buf = RunVimInTerminal('-S XtestPopupBorder', ~{rows: 15}) |
97 call VerifyScreenDump(buf, 'Test_popupwin_2' .. iter, {}) | 98 call VerifyScreenDump(buf, 'Test_popupwin_2' .. iter, {}) |
98 | 99 |
99 call StopVimInTerminal(buf) | 100 call StopVimInTerminal(buf) |
100 call delete('XtestPopupBorder') | 101 call delete('XtestPopupBorder') |
101 endfor | 102 endfor |
105 hi BlueColor ctermbg=lightblue | 106 hi BlueColor ctermbg=lightblue |
106 hi TopColor ctermbg=253 | 107 hi TopColor ctermbg=253 |
107 hi RightColor ctermbg=245 | 108 hi RightColor ctermbg=245 |
108 hi BottomColor ctermbg=240 | 109 hi BottomColor ctermbg=240 |
109 hi LeftColor ctermbg=248 | 110 hi LeftColor ctermbg=248 |
110 call popup_create('hello border', *{line: 2, col: 3, border: [], borderhighlight: ['BlueColor']}) | 111 call popup_create('hello border', ~{line: 2, col: 3, border: [], borderhighlight: ['BlueColor']}) |
111 call popup_create(['hello border', 'and more'], *{line: 2, col: 23, border: [], borderhighlight: ['TopColor', 'RightColor', 'BottomColor', 'LeftColor']}) | 112 call popup_create(['hello border', 'and more'], ~{line: 2, col: 23, border: [], borderhighlight: ['TopColor', 'RightColor', 'BottomColor', 'LeftColor']}) |
112 call popup_create(['hello border', 'lines only'], *{line: 2, col: 43, border: [], borderhighlight: ['BlueColor'], borderchars: ['x']}) | 113 call popup_create(['hello border', 'lines only'], ~{line: 2, col: 43, border: [], borderhighlight: ['BlueColor'], borderchars: ['x']}) |
113 call popup_create(['hello border', 'with corners'], *{line: 2, col: 60, border: [], borderhighlight: ['BlueColor'], borderchars: ['x', '#']}) | 114 call popup_create(['hello border', 'with corners'], ~{line: 2, col: 60, border: [], borderhighlight: ['BlueColor'], borderchars: ['x', '#']}) |
114 let winid = popup_create(['hello border', 'with numbers'], *{line: 6, col: 3, border: [], borderhighlight: ['BlueColor'], borderchars: ['0', '1', '2', '3', '4', '5', '6', '7']}) | 115 let winid = popup_create(['hello border', 'with numbers'], ~{line: 6, col: 3, border: [], borderhighlight: ['BlueColor'], borderchars: ['0', '1', '2', '3', '4', '5', '6', '7']}) |
115 call popup_create(['hello border', 'just blanks'], *{line: 7, col: 23, border: [], borderhighlight: ['BlueColor'], borderchars: [' ']}) | 116 call popup_create(['hello border', 'just blanks'], ~{line: 7, col: 23, border: [], borderhighlight: ['BlueColor'], borderchars: [' ']}) |
116 func MultiByte() | 117 func MultiByte() |
117 call popup_create(['hello'], *{line: 8, col: 43, border: [], borderchars: ['─', '│', '─', '│', '┌', '┐', '┘', '└']}) | 118 call popup_create(['hello'], ~{line: 8, col: 43, border: [], borderchars: ['─', '│', '─', '│', '┌', '┐', '┘', '└']}) |
118 endfunc | 119 endfunc |
119 END | 120 END |
120 call writefile(lines, 'XtestPopupBorder') | 121 call writefile(lines, 'XtestPopupBorder') |
121 let buf = RunVimInTerminal('-S XtestPopupBorder', *{rows: 12}) | 122 let buf = RunVimInTerminal('-S XtestPopupBorder', ~{rows: 12}) |
122 call VerifyScreenDump(buf, 'Test_popupwin_22', {}) | 123 call VerifyScreenDump(buf, 'Test_popupwin_22', {}) |
123 | 124 |
124 " check that changing borderchars triggers a redraw | 125 " check that changing borderchars triggers a redraw |
125 call term_sendkeys(buf, ":call popup_setoptions(winid, *{borderchars: ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']})\<CR>") | 126 call term_sendkeys(buf, ":call popup_setoptions(winid, ~{borderchars: ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']})\<CR>") |
126 call VerifyScreenDump(buf, 'Test_popupwin_23', {}) | 127 call VerifyScreenDump(buf, 'Test_popupwin_23', {}) |
127 | 128 |
128 " check multi-byte border only with 'ambiwidth' single | 129 " check multi-byte border only with 'ambiwidth' single |
129 if &ambiwidth == 'single' | 130 if &ambiwidth == 'single' |
130 call term_sendkeys(buf, ":call MultiByte()\<CR>") | 131 call term_sendkeys(buf, ":call MultiByte()\<CR>") |
132 endif | 133 endif |
133 | 134 |
134 call StopVimInTerminal(buf) | 135 call StopVimInTerminal(buf) |
135 call delete('XtestPopupBorder') | 136 call delete('XtestPopupBorder') |
136 | 137 |
137 let with_border_or_padding = *{ | 138 let with_border_or_padding = ~{ |
138 \ line: 2, | 139 \ line: 2, |
139 \ core_line: 3, | 140 \ core_line: 3, |
140 \ col: 3, | 141 \ col: 3, |
141 \ core_col: 4, | 142 \ core_col: 4, |
142 \ width: 14, | 143 \ width: 14, |
144 \ height: 3, | 145 \ height: 3, |
145 \ core_height: 1, | 146 \ core_height: 1, |
146 \ firstline: 1, | 147 \ firstline: 1, |
147 \ scrollbar: 0, | 148 \ scrollbar: 0, |
148 \ visible: 1} | 149 \ visible: 1} |
149 let winid = popup_create('hello border', *{line: 2, col: 3, border: []})", | 150 let winid = popup_create('hello border', ~{line: 2, col: 3, border: []})", |
150 call assert_equal(with_border_or_padding, popup_getpos(winid)) | 151 call assert_equal(with_border_or_padding, popup_getpos(winid)) |
151 let options = popup_getoptions(winid) | 152 let options = popup_getoptions(winid) |
152 call assert_equal([], options.border) | 153 call assert_equal([], options.border) |
153 call assert_false(has_key(options, "padding")) | 154 call assert_false(has_key(options, "padding")) |
154 | 155 |
155 let winid = popup_create('hello padding', *{line: 2, col: 3, padding: []}) | 156 let winid = popup_create('hello padding', ~{line: 2, col: 3, padding: []}) |
156 let with_border_or_padding.width = 15 | 157 let with_border_or_padding.width = 15 |
157 let with_border_or_padding.core_width = 13 | 158 let with_border_or_padding.core_width = 13 |
158 call assert_equal(with_border_or_padding, popup_getpos(winid)) | 159 call assert_equal(with_border_or_padding, popup_getpos(winid)) |
159 let options = popup_getoptions(winid) | 160 let options = popup_getoptions(winid) |
160 call assert_false(has_key(options, "border")) | 161 call assert_false(has_key(options, "border")) |
161 call assert_equal([], options.padding) | 162 call assert_equal([], options.padding) |
162 | 163 |
163 call popup_setoptions(winid, *{ | 164 call popup_setoptions(winid, ~{ |
164 \ padding: [1, 2, 3, 4], | 165 \ padding: [1, 2, 3, 4], |
165 \ border: [4, 0, 7, 8], | 166 \ border: [4, 0, 7, 8], |
166 \ borderhighlight: ['Top', 'Right', 'Bottom', 'Left'], | 167 \ borderhighlight: ['Top', 'Right', 'Bottom', 'Left'], |
167 \ borderchars: ['1', '^', '2', '>', '3', 'v', '4', '<'], | 168 \ borderchars: ['1', '^', '2', '>', '3', 'v', '4', '<'], |
168 \ }) | 169 \ }) |
170 call assert_equal([1, 0, 1, 1], options.border) | 171 call assert_equal([1, 0, 1, 1], options.border) |
171 call assert_equal([1, 2, 3, 4], options.padding) | 172 call assert_equal([1, 2, 3, 4], options.padding) |
172 call assert_equal(['Top', 'Right', 'Bottom', 'Left'], options.borderhighlight) | 173 call assert_equal(['Top', 'Right', 'Bottom', 'Left'], options.borderhighlight) |
173 call assert_equal(['1', '^', '2', '>', '3', 'v', '4', '<'], options.borderchars) | 174 call assert_equal(['1', '^', '2', '>', '3', 'v', '4', '<'], options.borderchars) |
174 | 175 |
175 let winid = popup_create('hello both', *{line: 3, col: 8, border: [], padding: []}) | 176 let winid = popup_create('hello both', ~{line: 3, col: 8, border: [], padding: []}) |
176 call assert_equal(*{ | 177 call assert_equal(~{ |
177 \ line: 3, | 178 \ line: 3, |
178 \ core_line: 5, | 179 \ core_line: 5, |
179 \ col: 8, | 180 \ col: 8, |
180 \ core_col: 10, | 181 \ core_col: 10, |
181 \ width: 14, | 182 \ width: 14, |
200 \ '#include <stdio.h>', | 201 \ '#include <stdio.h>', |
201 \ 'int main(void)', | 202 \ 'int main(void)', |
202 \ '{', | 203 \ '{', |
203 \ ' printf(123);', | 204 \ ' printf(123);', |
204 \ '}', | 205 \ '}', |
205 \], *{line: 3, col: 25, highlight: 'PopupColor'}) | 206 \], ~{line: 3, col: 25, highlight: 'PopupColor'}) |
206 call win_execute(winid, 'set syntax=cpp') | 207 call win_execute(winid, 'set syntax=cpp') |
207 END | 208 END |
208 call writefile(lines, 'XtestPopup') | 209 call writefile(lines, 'XtestPopup') |
209 let buf = RunVimInTerminal('-S XtestPopup', *{rows: 10}) | 210 let buf = RunVimInTerminal('-S XtestPopup', ~{rows: 10}) |
210 call VerifyScreenDump(buf, 'Test_popupwin_10', {}) | 211 call VerifyScreenDump(buf, 'Test_popupwin_10', {}) |
211 | 212 |
212 " clean up | 213 " clean up |
213 call StopVimInTerminal(buf) | 214 call StopVimInTerminal(buf) |
214 call delete('XtestPopup') | 215 call delete('XtestPopup') |
225 \ '#include <stdio.h>', | 226 \ '#include <stdio.h>', |
226 \ 'int main(void)', | 227 \ 'int main(void)', |
227 \ '{', | 228 \ '{', |
228 \ "\tprintf(567);", | 229 \ "\tprintf(567);", |
229 \ '}', | 230 \ '}', |
230 \], *{line: 3, col: 21, highlight: 'PopupColor'}) | 231 \], ~{line: 3, col: 21, highlight: 'PopupColor'}) |
231 call setbufvar(winbufnr(winid), '&syntax', 'cpp') | 232 call setbufvar(winbufnr(winid), '&syntax', 'cpp') |
232 END | 233 END |
233 call writefile(lines, 'XtestPopup') | 234 call writefile(lines, 'XtestPopup') |
234 let buf = RunVimInTerminal('-S XtestPopup', *{rows: 10}) | 235 let buf = RunVimInTerminal('-S XtestPopup', ~{rows: 10}) |
235 call VerifyScreenDump(buf, 'Test_popupwin_11', {}) | 236 call VerifyScreenDump(buf, 'Test_popupwin_11', {}) |
236 | 237 |
237 " clean up | 238 " clean up |
238 call StopVimInTerminal(buf) | 239 call StopVimInTerminal(buf) |
239 call delete('XtestPopup') | 240 call delete('XtestPopup') |
246 let lines =<< trim END | 247 let lines =<< trim END |
247 call setline(1, ['111 222 333', '444 555 666']) | 248 call setline(1, ['111 222 333', '444 555 666']) |
248 let winid = popup_create([ | 249 let winid = popup_create([ |
249 \ '111 222 333', | 250 \ '111 222 333', |
250 \ '444 555 666', | 251 \ '444 555 666', |
251 \], *{line: 3, col: 10, border: []}) | 252 \], ~{line: 3, col: 10, border: []}) |
252 set hlsearch | 253 set hlsearch |
253 /666 | 254 /666 |
254 call matchadd('ErrorMsg', '111') | 255 call matchadd('ErrorMsg', '111') |
255 call matchadd('ErrorMsg', '444') | 256 call matchadd('ErrorMsg', '444') |
256 call win_execute(winid, "call matchadd('ErrorMsg', '111')") | 257 call win_execute(winid, "call matchadd('ErrorMsg', '111')") |
257 call win_execute(winid, "call matchadd('ErrorMsg', '555')") | 258 call win_execute(winid, "call matchadd('ErrorMsg', '555')") |
258 END | 259 END |
259 call writefile(lines, 'XtestPopupMatches') | 260 call writefile(lines, 'XtestPopupMatches') |
260 let buf = RunVimInTerminal('-S XtestPopupMatches', *{rows: 10}) | 261 let buf = RunVimInTerminal('-S XtestPopupMatches', ~{rows: 10}) |
261 call VerifyScreenDump(buf, 'Test_popupwin_matches', {}) | 262 call VerifyScreenDump(buf, 'Test_popupwin_matches', {}) |
262 | 263 |
263 " clean up | 264 " clean up |
264 call StopVimInTerminal(buf) | 265 call StopVimInTerminal(buf) |
265 call delete('XtestPopupMatches') | 266 call delete('XtestPopupMatches') |
271 endif | 272 endif |
272 let lines =<< trim END | 273 let lines =<< trim END |
273 call setline(1, repeat([repeat('-', 60)], 15)) | 274 call setline(1, repeat([repeat('-', 60)], 15)) |
274 set so=0 | 275 set so=0 |
275 normal 2G3|r# | 276 normal 2G3|r# |
276 let winid1 = popup_create(['first', 'second'], *{ | 277 let winid1 = popup_create(['first', 'second'], ~{ |
277 \ line: 'cursor+1', | 278 \ line: 'cursor+1', |
278 \ col: 'cursor', | 279 \ col: 'cursor', |
279 \ pos: 'topleft', | 280 \ pos: 'topleft', |
280 \ border: [], | 281 \ border: [], |
281 \ padding: [], | 282 \ padding: [], |
282 \ }) | 283 \ }) |
283 normal 25|r@ | 284 normal 25|r@ |
284 let winid1 = popup_create(['First', 'SeconD'], *{ | 285 let winid1 = popup_create(['First', 'SeconD'], ~{ |
285 \ line: 'cursor+1', | 286 \ line: 'cursor+1', |
286 \ col: 'cursor', | 287 \ col: 'cursor', |
287 \ pos: 'topright', | 288 \ pos: 'topright', |
288 \ border: [], | 289 \ border: [], |
289 \ padding: [], | 290 \ padding: [], |
290 \ }) | 291 \ }) |
291 normal 9G29|r% | 292 normal 9G29|r% |
292 let winid1 = popup_create(['fiRSt', 'seCOnd'], *{ | 293 let winid1 = popup_create(['fiRSt', 'seCOnd'], ~{ |
293 \ line: 'cursor-1', | 294 \ line: 'cursor-1', |
294 \ col: 'cursor', | 295 \ col: 'cursor', |
295 \ pos: 'botleft', | 296 \ pos: 'botleft', |
296 \ border: [], | 297 \ border: [], |
297 \ padding: [], | 298 \ padding: [], |
298 \ }) | 299 \ }) |
299 normal 51|r& | 300 normal 51|r& |
300 let winid1 = popup_create(['FIrsT', 'SEcoND'], *{ | 301 let winid1 = popup_create(['FIrsT', 'SEcoND'], ~{ |
301 \ line: 'cursor-1', | 302 \ line: 'cursor-1', |
302 \ col: 'cursor', | 303 \ col: 'cursor', |
303 \ pos: 'botright', | 304 \ pos: 'botright', |
304 \ border: [], | 305 \ border: [], |
305 \ padding: [], | 306 \ padding: [], |
306 \ }) | 307 \ }) |
307 END | 308 END |
308 call writefile(lines, 'XtestPopupCorners') | 309 call writefile(lines, 'XtestPopupCorners') |
309 let buf = RunVimInTerminal('-S XtestPopupCorners', *{rows: 12}) | 310 let buf = RunVimInTerminal('-S XtestPopupCorners', ~{rows: 12}) |
310 call VerifyScreenDump(buf, 'Test_popupwin_corners', {}) | 311 call VerifyScreenDump(buf, 'Test_popupwin_corners', {}) |
311 | 312 |
312 " clean up | 313 " clean up |
313 call StopVimInTerminal(buf) | 314 call StopVimInTerminal(buf) |
314 call delete('XtestPopupCorners') | 315 call delete('XtestPopupCorners') |
318 if !CanRunVimInTerminal() | 319 if !CanRunVimInTerminal() |
319 throw 'Skipped: cannot make screendumps' | 320 throw 'Skipped: cannot make screendumps' |
320 endif | 321 endif |
321 let lines =<< trim END | 322 let lines =<< trim END |
322 call setline(1, range(1, 20)) | 323 call setline(1, range(1, 20)) |
323 call popup_create(['1111', '222222', '33333', '44', '5', '666666', '77777', '888', '9999999999999999'], *{ | 324 call popup_create(['1111', '222222', '33333', '44', '5', '666666', '77777', '888', '9999999999999999'], ~{ |
324 \ maxheight: 4, | 325 \ maxheight: 4, |
325 \ firstline: 3, | 326 \ firstline: 3, |
326 \ }) | 327 \ }) |
327 END | 328 END |
328 call writefile(lines, 'XtestPopupFirstline') | 329 call writefile(lines, 'XtestPopupFirstline') |
329 let buf = RunVimInTerminal('-S XtestPopupFirstline', *{rows: 10}) | 330 let buf = RunVimInTerminal('-S XtestPopupFirstline', ~{rows: 10}) |
330 call VerifyScreenDump(buf, 'Test_popupwin_firstline', {}) | 331 call VerifyScreenDump(buf, 'Test_popupwin_firstline', {}) |
331 | 332 |
332 " clean up | 333 " clean up |
333 call StopVimInTerminal(buf) | 334 call StopVimInTerminal(buf) |
334 call delete('XtestPopupFirstline') | 335 call delete('XtestPopupFirstline') |
335 | 336 |
336 let winid = popup_create(['1111', '222222', '33333', '44444'], *{ | 337 let winid = popup_create(['1111', '222222', '33333', '44444'], ~{ |
337 \ maxheight: 2, | 338 \ maxheight: 2, |
338 \ firstline: 3, | 339 \ firstline: 3, |
339 \ }) | 340 \ }) |
340 call assert_equal(3, popup_getoptions(winid).firstline) | 341 call assert_equal(3, popup_getoptions(winid).firstline) |
341 call popup_setoptions(winid, *{firstline: 1}) | 342 call popup_setoptions(winid, ~{firstline: 1}) |
342 call assert_equal(1, popup_getoptions(winid).firstline) | 343 call assert_equal(1, popup_getoptions(winid).firstline) |
343 | 344 |
344 call popup_close(winid) | 345 call popup_close(winid) |
345 endfunc | 346 endfunc |
346 | 347 |
349 throw 'Skipped: cannot make screendumps' | 350 throw 'Skipped: cannot make screendumps' |
350 endif | 351 endif |
351 " create a popup that covers the command line | 352 " create a popup that covers the command line |
352 let lines =<< trim END | 353 let lines =<< trim END |
353 call setline(1, range(1, 20)) | 354 call setline(1, range(1, 20)) |
354 let winid = popup_create(['1111', '222222', '33333'], *{ | 355 let winid = popup_create(['1111', '222222', '33333'], ~{ |
355 \ drag: 1, | 356 \ drag: 1, |
356 \ border: [], | 357 \ border: [], |
357 \ line: &lines - 4, | 358 \ line: &lines - 4, |
358 \ }) | 359 \ }) |
359 func Dragit() | 360 func Dragit() |
361 endfunc | 362 endfunc |
362 map <silent> <F3> :call test_setmouse(&lines - 4, &columns / 2)<CR> | 363 map <silent> <F3> :call test_setmouse(&lines - 4, &columns / 2)<CR> |
363 map <silent> <F4> :call test_setmouse(&lines - 8, &columns / 2)<CR> | 364 map <silent> <F4> :call test_setmouse(&lines - 8, &columns / 2)<CR> |
364 END | 365 END |
365 call writefile(lines, 'XtestPopupDrag') | 366 call writefile(lines, 'XtestPopupDrag') |
366 let buf = RunVimInTerminal('-S XtestPopupDrag', *{rows: 10}) | 367 let buf = RunVimInTerminal('-S XtestPopupDrag', ~{rows: 10}) |
367 call VerifyScreenDump(buf, 'Test_popupwin_drag_01', {}) | 368 call VerifyScreenDump(buf, 'Test_popupwin_drag_01', {}) |
368 | 369 |
369 call term_sendkeys(buf, ":call Dragit()\<CR>") | 370 call term_sendkeys(buf, ":call Dragit()\<CR>") |
370 call VerifyScreenDump(buf, 'Test_popupwin_drag_02', {}) | 371 call VerifyScreenDump(buf, 'Test_popupwin_drag_02', {}) |
371 | 372 |
379 throw 'Skipped: cannot make screendumps' | 380 throw 'Skipped: cannot make screendumps' |
380 endif | 381 endif |
381 let lines =<< trim END | 382 let lines =<< trim END |
382 call setline(1, range(1, 20)) | 383 call setline(1, range(1, 20)) |
383 " With border, can click on X | 384 " With border, can click on X |
384 let winid = popup_create('foobar', *{ | 385 let winid = popup_create('foobar', ~{ |
385 \ close: 'button', | 386 \ close: 'button', |
386 \ border: [], | 387 \ border: [], |
387 \ line: 1, | 388 \ line: 1, |
388 \ col: 1, | 389 \ col: 1, |
389 \ }) | 390 \ }) |
390 func CloseMsg(id, result) | 391 func CloseMsg(id, result) |
391 echomsg 'Popup closed with ' .. a:result | 392 echomsg 'Popup closed with ' .. a:result |
392 endfunc | 393 endfunc |
393 let winid = popup_create('notification', *{ | 394 let winid = popup_create('notification', ~{ |
394 \ close: 'click', | 395 \ close: 'click', |
395 \ line: 3, | 396 \ line: 3, |
396 \ col: 15, | 397 \ col: 15, |
397 \ callback: 'CloseMsg', | 398 \ callback: 'CloseMsg', |
398 \ }) | 399 \ }) |
399 let winid = popup_create('no border here', *{ | 400 let winid = popup_create('no border here', ~{ |
400 \ close: 'button', | 401 \ close: 'button', |
401 \ line: 5, | 402 \ line: 5, |
402 \ col: 3, | 403 \ col: 3, |
403 \ }) | 404 \ }) |
404 let winid = popup_create('only padding', *{ | 405 let winid = popup_create('only padding', ~{ |
405 \ close: 'button', | 406 \ close: 'button', |
406 \ padding: [], | 407 \ padding: [], |
407 \ line: 5, | 408 \ line: 5, |
408 \ col: 23, | 409 \ col: 23, |
409 \ }) | 410 \ }) |
415 call feedkeys("\<F4>\<LeftMouse>\<LeftRelease>", "xt") | 416 call feedkeys("\<F4>\<LeftMouse>\<LeftRelease>", "xt") |
416 endfunc | 417 endfunc |
417 map <silent> <F4> :call test_setmouse(3, 17)<CR> | 418 map <silent> <F4> :call test_setmouse(3, 17)<CR> |
418 END | 419 END |
419 call writefile(lines, 'XtestPopupClose') | 420 call writefile(lines, 'XtestPopupClose') |
420 let buf = RunVimInTerminal('-S XtestPopupClose', *{rows: 10}) | 421 let buf = RunVimInTerminal('-S XtestPopupClose', ~{rows: 10}) |
421 call VerifyScreenDump(buf, 'Test_popupwin_close_01', {}) | 422 call VerifyScreenDump(buf, 'Test_popupwin_close_01', {}) |
422 | 423 |
423 call term_sendkeys(buf, ":call CloseWithX()\<CR>") | 424 call term_sendkeys(buf, ":call CloseWithX()\<CR>") |
424 call VerifyScreenDump(buf, 'Test_popupwin_close_02', {}) | 425 call VerifyScreenDump(buf, 'Test_popupwin_close_02', {}) |
425 | 426 |
439 call setline(1, repeat([join(range(1, 42), '')], 13)) | 440 call setline(1, repeat([join(range(1, 42), '')], 13)) |
440 hi PopupColor ctermbg=lightgrey | 441 hi PopupColor ctermbg=lightgrey |
441 let winid = popup_create([ | 442 let winid = popup_create([ |
442 \ 'some text', | 443 \ 'some text', |
443 \ 'another line', | 444 \ 'another line', |
444 \], *{ | 445 \], ~{ |
445 \ line: 1, | 446 \ line: 1, |
446 \ col: 10, | 447 \ col: 10, |
447 \ wrap: 0, | 448 \ wrap: 0, |
448 \ fixed: 1, | 449 \ fixed: 1, |
449 \ zindex: 90, | 450 \ zindex: 90, |
451 \ highlight: 'PopupColor', | 452 \ highlight: 'PopupColor', |
452 \ mask: [[1,1,1,1], [-5,-1,4,4], [7,9,2,3], [2,4,3,3]]}) | 453 \ mask: [[1,1,1,1], [-5,-1,4,4], [7,9,2,3], [2,4,3,3]]}) |
453 call popup_create([ | 454 call popup_create([ |
454 \ 'xxxxxxxxx', | 455 \ 'xxxxxxxxx', |
455 \ 'yyyyyyyyy', | 456 \ 'yyyyyyyyy', |
456 \], *{ | 457 \], ~{ |
457 \ line: 3, | 458 \ line: 3, |
458 \ col: 18, | 459 \ col: 18, |
459 \ zindex: 20}) | 460 \ zindex: 20}) |
460 let winidb = popup_create([ | 461 let winidb = popup_create([ |
461 \ 'just one line', | 462 \ 'just one line', |
462 \], *{ | 463 \], ~{ |
463 \ line: 7, | 464 \ line: 7, |
464 \ col: 10, | 465 \ col: 10, |
465 \ wrap: 0, | 466 \ wrap: 0, |
466 \ fixed: 1, | 467 \ fixed: 1, |
467 \ close: 'button', | 468 \ close: 'button', |
469 \ padding: [], | 470 \ padding: [], |
470 \ border: [], | 471 \ border: [], |
471 \ mask: [[1,2,1,1], [-5,-1,4,4], [7,9,2,3], [3,5,5,5],[-7,-4,5,5]]}) | 472 \ mask: [[1,2,1,1], [-5,-1,4,4], [7,9,2,3], [3,5,5,5],[-7,-4,5,5]]}) |
472 END | 473 END |
473 call writefile(lines, 'XtestPopupMask') | 474 call writefile(lines, 'XtestPopupMask') |
474 let buf = RunVimInTerminal('-S XtestPopupMask', *{rows: 13}) | 475 let buf = RunVimInTerminal('-S XtestPopupMask', ~{rows: 13}) |
475 call VerifyScreenDump(buf, 'Test_popupwin_mask_1', {}) | 476 call VerifyScreenDump(buf, 'Test_popupwin_mask_1', {}) |
476 | 477 |
477 call term_sendkeys(buf, ":call popup_move(winid, *{col: 11, line: 2})\<CR>") | 478 call term_sendkeys(buf, ":call popup_move(winid, ~{col: 11, line: 2})\<CR>") |
478 call term_sendkeys(buf, ":call popup_move(winidb, *{col: 12})\<CR>") | 479 call term_sendkeys(buf, ":call popup_move(winidb, ~{col: 12})\<CR>") |
480 call term_sendkeys(buf, ":\<CR>") | |
479 call VerifyScreenDump(buf, 'Test_popupwin_mask_2', {}) | 481 call VerifyScreenDump(buf, 'Test_popupwin_mask_2', {}) |
480 | 482 |
481 call term_sendkeys(buf, ":call popup_move(winid, *{col: 65, line: 2})\<CR>") | 483 call term_sendkeys(buf, ":call popup_move(winid, ~{col: 65, line: 2})\<CR>") |
482 call term_sendkeys(buf, ":call popup_move(winidb, *{col: 63})\<CR>") | 484 call term_sendkeys(buf, ":call popup_move(winidb, ~{col: 63})\<CR>") |
485 call term_sendkeys(buf, ":\<CR>") | |
483 call VerifyScreenDump(buf, 'Test_popupwin_mask_3', {}) | 486 call VerifyScreenDump(buf, 'Test_popupwin_mask_3', {}) |
484 | 487 |
485 call term_sendkeys(buf, ":call popup_move(winid, *{pos: 'topright', col: 12, line: 2})\<CR>") | 488 call term_sendkeys(buf, ":call popup_move(winid, ~{pos: 'topright', col: 12, line: 2})\<CR>") |
486 call term_sendkeys(buf, ":call popup_move(winidb, *{pos: 'topright', col: 12})\<CR>") | 489 call term_sendkeys(buf, ":call popup_move(winidb, ~{pos: 'topright', col: 12})\<CR>") |
490 call term_sendkeys(buf, ":\<CR>") | |
487 call VerifyScreenDump(buf, 'Test_popupwin_mask_4', {}) | 491 call VerifyScreenDump(buf, 'Test_popupwin_mask_4', {}) |
488 | 492 |
489 call term_sendkeys(buf, ":call popup_move(winid, *{pos: 'topright', col: 12, line: 11})\<CR>") | 493 call term_sendkeys(buf, ":call popup_move(winid, ~{pos: 'topright', col: 12, line: 11})\<CR>") |
490 call term_sendkeys(buf, ":call popup_move(winidb, *{pos: 'topleft', col: 42, line: 11})\<CR>") | 494 call term_sendkeys(buf, ":call popup_move(winidb, ~{pos: 'topleft', col: 42, line: 11})\<CR>") |
495 call term_sendkeys(buf, ":\<CR>") | |
491 call VerifyScreenDump(buf, 'Test_popupwin_mask_5', {}) | 496 call VerifyScreenDump(buf, 'Test_popupwin_mask_5', {}) |
492 | 497 |
493 " clean up | 498 " clean up |
494 call StopVimInTerminal(buf) | 499 call StopVimInTerminal(buf) |
495 call delete('XtestPopupMask') | 500 call delete('XtestPopupMask') |
504 endif | 509 endif |
505 " create a popup with some text to be selected | 510 " create a popup with some text to be selected |
506 let lines =<< trim END | 511 let lines =<< trim END |
507 set clipboard=autoselect | 512 set clipboard=autoselect |
508 call setline(1, range(1, 20)) | 513 call setline(1, range(1, 20)) |
509 let winid = popup_create(['the word', 'some more', 'several words here'], *{ | 514 let winid = popup_create(['the word', 'some more', 'several words here'], ~{ |
510 \ drag: 1, | 515 \ drag: 1, |
511 \ border: [], | 516 \ border: [], |
512 \ line: 3, | 517 \ line: 3, |
513 \ col: 10, | 518 \ col: 10, |
514 \ }) | 519 \ }) |
517 endfunc | 522 endfunc |
518 map <silent> <F3> :call test_setmouse(4, 15)<CR> | 523 map <silent> <F3> :call test_setmouse(4, 15)<CR> |
519 map <silent> <F4> :call test_setmouse(6, 23)<CR> | 524 map <silent> <F4> :call test_setmouse(6, 23)<CR> |
520 END | 525 END |
521 call writefile(lines, 'XtestPopupSelect') | 526 call writefile(lines, 'XtestPopupSelect') |
522 let buf = RunVimInTerminal('-S XtestPopupSelect', *{rows: 10}) | 527 let buf = RunVimInTerminal('-S XtestPopupSelect', ~{rows: 10}) |
523 call term_sendkeys(buf, ":call Select1()\<CR>") | 528 call term_sendkeys(buf, ":call Select1()\<CR>") |
524 call VerifyScreenDump(buf, 'Test_popupwin_select_01', {}) | 529 call VerifyScreenDump(buf, 'Test_popupwin_select_01', {}) |
525 | 530 |
526 call term_sendkeys(buf, ":call popup_close(winid)\<CR>") | 531 call term_sendkeys(buf, ":call popup_close(winid)\<CR>") |
527 call term_sendkeys(buf, "\"*p") | 532 call term_sendkeys(buf, "\"*p") |
551 call popup_clear() | 556 call popup_clear() |
552 " buffer is gone now | 557 " buffer is gone now |
553 call assert_equal(0, bufexists(bufnr)) | 558 call assert_equal(0, bufexists(bufnr)) |
554 | 559 |
555 " global popup is visible in any tab | 560 " global popup is visible in any tab |
556 let winid = popup_create("text", *{tabpage: -1}) | 561 let winid = popup_create("text", ~{tabpage: -1}) |
557 call assert_equal(1, popup_getpos(winid).visible) | 562 call assert_equal(1, popup_getpos(winid).visible) |
558 call assert_equal(-1, popup_getoptions(winid).tabpage) | 563 call assert_equal(-1, popup_getoptions(winid).tabpage) |
559 tabnew | 564 tabnew |
560 call assert_equal(1, popup_getpos(winid).visible) | 565 call assert_equal(1, popup_getpos(winid).visible) |
561 call assert_equal(-1, popup_getoptions(winid).tabpage) | 566 call assert_equal(-1, popup_getoptions(winid).tabpage) |
563 call assert_equal(1, popup_getpos(winid).visible) | 568 call assert_equal(1, popup_getpos(winid).visible) |
564 call popup_clear() | 569 call popup_clear() |
565 | 570 |
566 " create popup in other tab | 571 " create popup in other tab |
567 tabnew | 572 tabnew |
568 let winid = popup_create("text", *{tabpage: 1}) | 573 let winid = popup_create("text", ~{tabpage: 1}) |
569 call assert_equal(0, popup_getpos(winid).visible) | 574 call assert_equal(0, popup_getpos(winid).visible) |
570 call assert_equal(1, popup_getoptions(winid).tabpage) | 575 call assert_equal(1, popup_getoptions(winid).tabpage) |
571 quit | 576 quit |
572 call assert_equal(1, popup_getpos(winid).visible) | 577 call assert_equal(1, popup_getpos(winid).visible) |
573 call assert_equal(0, popup_getoptions(winid).tabpage) | 578 call assert_equal(0, popup_getoptions(winid).tabpage) |
574 call popup_clear() | 579 call popup_clear() |
575 endfunc | 580 endfunc |
576 | 581 |
577 func Test_popup_valid_arguments() | 582 func Test_popup_valid_arguments() |
578 " Zero value is like the property wasn't there | 583 " Zero value is like the property wasn't there |
579 let winid = popup_create("text", *{col: 0}) | 584 let winid = popup_create("text", ~{col: 0}) |
580 let pos = popup_getpos(winid) | 585 let pos = popup_getpos(winid) |
581 call assert_inrange(&columns / 2 - 1, &columns / 2 + 1, pos.col) | 586 call assert_inrange(&columns / 2 - 1, &columns / 2 + 1, pos.col) |
582 call popup_clear() | 587 call popup_clear() |
583 | 588 |
584 " using cursor column has minimum value of 1 | 589 " using cursor column has minimum value of 1 |
585 let winid = popup_create("text", *{col: 'cursor-100'}) | 590 let winid = popup_create("text", ~{col: 'cursor-100'}) |
586 let pos = popup_getpos(winid) | 591 let pos = popup_getpos(winid) |
587 call assert_equal(1, pos.col) | 592 call assert_equal(1, pos.col) |
588 call popup_clear() | 593 call popup_clear() |
589 | 594 |
590 " center | 595 " center |
591 let winid = popup_create("text", *{pos: 'center'}) | 596 let winid = popup_create("text", ~{pos: 'center'}) |
592 let pos = popup_getpos(winid) | 597 let pos = popup_getpos(winid) |
593 let around = (&columns - pos.width) / 2 | 598 let around = (&columns - pos.width) / 2 |
594 call assert_inrange(around - 1, around + 1, pos.col) | 599 call assert_inrange(around - 1, around + 1, pos.col) |
595 let around = (&lines - pos.height) / 2 | 600 let around = (&lines - pos.height) / 2 |
596 call assert_inrange(around - 1, around + 1, pos.line) | 601 call assert_inrange(around - 1, around + 1, pos.line) |
601 call assert_fails('call popup_create(666, {})', 'E86:') | 606 call assert_fails('call popup_create(666, {})', 'E86:') |
602 call popup_clear() | 607 call popup_clear() |
603 call assert_fails('call popup_create("text", "none")', 'E715:') | 608 call assert_fails('call popup_create("text", "none")', 'E715:') |
604 call popup_clear() | 609 call popup_clear() |
605 | 610 |
606 call assert_fails('call popup_create("text", *{col: "xxx"})', 'E475:') | 611 call assert_fails('call popup_create("text", ~{col: "xxx"})', 'E475:') |
607 call popup_clear() | 612 call popup_clear() |
608 call assert_fails('call popup_create("text", *{col: "cursor8"})', 'E15:') | 613 call assert_fails('call popup_create("text", ~{col: "cursor8"})', 'E15:') |
609 call popup_clear() | 614 call popup_clear() |
610 call assert_fails('call popup_create("text", *{col: "cursor+x"})', 'E15:') | 615 call assert_fails('call popup_create("text", ~{col: "cursor+x"})', 'E15:') |
611 call popup_clear() | 616 call popup_clear() |
612 call assert_fails('call popup_create("text", *{col: "cursor+8x"})', 'E15:') | 617 call assert_fails('call popup_create("text", ~{col: "cursor+8x"})', 'E15:') |
613 call popup_clear() | 618 call popup_clear() |
614 | 619 |
615 call assert_fails('call popup_create("text", *{line: "xxx"})', 'E475:') | 620 call assert_fails('call popup_create("text", ~{line: "xxx"})', 'E475:') |
616 call popup_clear() | 621 call popup_clear() |
617 call assert_fails('call popup_create("text", *{line: "cursor8"})', 'E15:') | 622 call assert_fails('call popup_create("text", ~{line: "cursor8"})', 'E15:') |
618 call popup_clear() | 623 call popup_clear() |
619 call assert_fails('call popup_create("text", *{line: "cursor+x"})', 'E15:') | 624 call assert_fails('call popup_create("text", ~{line: "cursor+x"})', 'E15:') |
620 call popup_clear() | 625 call popup_clear() |
621 call assert_fails('call popup_create("text", *{line: "cursor+8x"})', 'E15:') | 626 call assert_fails('call popup_create("text", ~{line: "cursor+8x"})', 'E15:') |
622 call popup_clear() | 627 call popup_clear() |
623 | 628 |
624 call assert_fails('call popup_create("text", *{pos: "there"})', 'E475:') | 629 call assert_fails('call popup_create("text", ~{pos: "there"})', 'E475:') |
625 call popup_clear() | 630 call popup_clear() |
626 call assert_fails('call popup_create("text", *{padding: "none"})', 'E714:') | 631 call assert_fails('call popup_create("text", ~{padding: "none"})', 'E714:') |
627 call popup_clear() | 632 call popup_clear() |
628 call assert_fails('call popup_create("text", *{border: "none"})', 'E714:') | 633 call assert_fails('call popup_create("text", ~{border: "none"})', 'E714:') |
629 call popup_clear() | 634 call popup_clear() |
630 call assert_fails('call popup_create("text", *{borderhighlight: "none"})', 'E714:') | 635 call assert_fails('call popup_create("text", ~{borderhighlight: "none"})', 'E714:') |
631 call popup_clear() | 636 call popup_clear() |
632 call assert_fails('call popup_create("text", *{borderchars: "none"})', 'E714:') | 637 call assert_fails('call popup_create("text", ~{borderchars: "none"})', 'E714:') |
633 call popup_clear() | 638 call popup_clear() |
634 | 639 |
635 call assert_fails('call popup_create([*{text: "text"}, 666], {})', 'E715:') | 640 call assert_fails('call popup_create([~{text: "text"}, 666], {})', 'E715:') |
636 call popup_clear() | 641 call popup_clear() |
637 call assert_fails('call popup_create([*{text: "text", props: "none"}], {})', 'E714:') | 642 call assert_fails('call popup_create([~{text: "text", props: "none"}], {})', 'E714:') |
638 call popup_clear() | 643 call popup_clear() |
639 call assert_fails('call popup_create([*{text: "text", props: ["none"]}], {})', 'E715:') | 644 call assert_fails('call popup_create([~{text: "text", props: ["none"]}], {})', 'E715:') |
640 call popup_clear() | 645 call popup_clear() |
641 endfunc | 646 endfunc |
642 | 647 |
643 func Test_win_execute_closing_curwin() | 648 func Test_win_execute_closing_curwin() |
644 split | 649 split |
674 endif | 679 endif |
675 let lines =<< trim END | 680 let lines =<< trim END |
676 call setline(1, range(1, 100)) | 681 call setline(1, range(1, 100)) |
677 let winid = popup_create( | 682 let winid = popup_create( |
678 \ 'a long line that wont fit', | 683 \ 'a long line that wont fit', |
679 \ *{line: 3, col: 20, maxwidth: 10, wrap: 1}) | 684 \ ~{line: 3, col: 20, maxwidth: 10, wrap: 1}) |
680 END | 685 END |
681 call writefile(lines, 'XtestPopup') | 686 call writefile(lines, 'XtestPopup') |
682 let buf = RunVimInTerminal('-S XtestPopup', *{rows: 10}) | 687 let buf = RunVimInTerminal('-S XtestPopup', ~{rows: 10}) |
683 call VerifyScreenDump(buf, 'Test_popupwin_wrap', {}) | 688 call VerifyScreenDump(buf, 'Test_popupwin_wrap', {}) |
684 | 689 |
685 " clean up | 690 " clean up |
686 call StopVimInTerminal(buf) | 691 call StopVimInTerminal(buf) |
687 call delete('XtestPopup') | 692 call delete('XtestPopup') |
693 endif | 698 endif |
694 let lines =<< trim END | 699 let lines =<< trim END |
695 call setline(1, range(1, 100)) | 700 call setline(1, range(1, 100)) |
696 let winid = popup_create( | 701 let winid = popup_create( |
697 \ 'a long line that wont fit', | 702 \ 'a long line that wont fit', |
698 \ *{line: 3, col: 20, maxwidth: 10, wrap: 0}) | 703 \ ~{line: 3, col: 20, maxwidth: 10, wrap: 0}) |
699 END | 704 END |
700 call writefile(lines, 'XtestPopup') | 705 call writefile(lines, 'XtestPopup') |
701 let buf = RunVimInTerminal('-S XtestPopup', *{rows: 10}) | 706 let buf = RunVimInTerminal('-S XtestPopup', ~{rows: 10}) |
702 call VerifyScreenDump(buf, 'Test_popupwin_nowrap', {}) | 707 call VerifyScreenDump(buf, 'Test_popupwin_nowrap', {}) |
703 | 708 |
704 " clean up | 709 " clean up |
705 call StopVimInTerminal(buf) | 710 call StopVimInTerminal(buf) |
706 call delete('XtestPopup') | 711 call delete('XtestPopup') |
711 throw 'Skipped: timer feature not supported' | 716 throw 'Skipped: timer feature not supported' |
712 endif | 717 endif |
713 topleft vnew | 718 topleft vnew |
714 call setline(1, 'hello') | 719 call setline(1, 'hello') |
715 | 720 |
716 let winid = popup_create('world', *{ | 721 let winid = popup_create('world', ~{ |
717 \ line: 1, | 722 \ line: 1, |
718 \ col: 1, | 723 \ col: 1, |
719 \ minwidth: 20, | 724 \ minwidth: 20, |
720 \ time: 500, | 725 \ time: 500, |
721 \}) | 726 \}) |
731 sleep 700m | 736 sleep 700m |
732 redraw | 737 redraw |
733 let line = join(map(range(1, 5), 'screenstring(1, v:val)'), '') | 738 let line = join(map(range(1, 5), 'screenstring(1, v:val)'), '') |
734 call assert_equal('hello', line) | 739 call assert_equal('hello', line) |
735 | 740 |
736 call popup_create('on the command line', *{ | 741 call popup_create('on the command line', ~{ |
737 \ line: &lines, | 742 \ line: &lines, |
738 \ col: 10, | 743 \ col: 10, |
739 \ minwidth: 20, | 744 \ minwidth: 20, |
740 \ time: 500, | 745 \ time: 500, |
741 \}) | 746 \}) |
753 | 758 |
754 func Test_popup_hide() | 759 func Test_popup_hide() |
755 topleft vnew | 760 topleft vnew |
756 call setline(1, 'hello') | 761 call setline(1, 'hello') |
757 | 762 |
758 let winid = popup_create('world', *{ | 763 let winid = popup_create('world', ~{ |
759 \ line: 1, | 764 \ line: 1, |
760 \ col: 1, | 765 \ col: 1, |
761 \ minwidth: 20, | 766 \ minwidth: 20, |
762 \}) | 767 \}) |
763 redraw | 768 redraw |
799 | 804 |
800 func Test_popup_move() | 805 func Test_popup_move() |
801 topleft vnew | 806 topleft vnew |
802 call setline(1, 'hello') | 807 call setline(1, 'hello') |
803 | 808 |
804 let winid = popup_create('world', *{ | 809 let winid = popup_create('world', ~{ |
805 \ line: 1, | 810 \ line: 1, |
806 \ col: 1, | 811 \ col: 1, |
807 \ minwidth: 20, | 812 \ minwidth: 20, |
808 \}) | 813 \}) |
809 redraw | 814 redraw |
810 let line = join(map(range(1, 6), 'screenstring(1, v:val)'), '') | 815 let line = join(map(range(1, 6), 'screenstring(1, v:val)'), '') |
811 call assert_equal('world ', line) | 816 call assert_equal('world ', line) |
812 | 817 |
813 call popup_move(winid, *{line: 2, col: 2}) | 818 call popup_move(winid, ~{line: 2, col: 2}) |
814 redraw | 819 redraw |
815 let line = join(map(range(1, 6), 'screenstring(1, v:val)'), '') | 820 let line = join(map(range(1, 6), 'screenstring(1, v:val)'), '') |
816 call assert_equal('hello ', line) | 821 call assert_equal('hello ', line) |
817 let line = join(map(range(1, 6), 'screenstring(2, v:val)'), '') | 822 let line = join(map(range(1, 6), 'screenstring(2, v:val)'), '') |
818 call assert_equal('~world', line) | 823 call assert_equal('~world', line) |
819 | 824 |
820 call popup_move(winid, *{line: 1}) | 825 call popup_move(winid, ~{line: 1}) |
821 redraw | 826 redraw |
822 let line = join(map(range(1, 6), 'screenstring(1, v:val)'), '') | 827 let line = join(map(range(1, 6), 'screenstring(1, v:val)'), '') |
823 call assert_equal('hworld', line) | 828 call assert_equal('hworld', line) |
824 | 829 |
825 call popup_close(winid) | 830 call popup_close(winid) |
826 | 831 |
827 bwipe! | 832 bwipe! |
828 endfunc | 833 endfunc |
829 | 834 |
830 func Test_popup_getpos() | 835 func Test_popup_getpos() |
831 let winid = popup_create('hello', *{ | 836 let winid = popup_create('hello', ~{ |
832 \ line: 2, | 837 \ line: 2, |
833 \ col: 3, | 838 \ col: 3, |
834 \ minwidth: 10, | 839 \ minwidth: 10, |
835 \ minheight: 11, | 840 \ minheight: 11, |
836 \}) | 841 \}) |
853 \ [['hello', 'all of its text', 'this', 'window', 'displays'], 15], | 858 \ [['hello', 'all of its text', 'this', 'window', 'displays'], 15], |
854 \ [['all of its text', 'hello', 'this', 'window', 'displays'], 15], | 859 \ [['all of its text', 'hello', 'this', 'window', 'displays'], 15], |
855 \ ] | 860 \ ] |
856 | 861 |
857 for test in tests | 862 for test in tests |
858 let winid = popup_create(test[0], *{line: 2, col: 3}) | 863 let winid = popup_create(test[0], ~{line: 2, col: 3}) |
859 redraw | 864 redraw |
860 let position = popup_getpos(winid) | 865 let position = popup_getpos(winid) |
861 call assert_equal(test[1], position.width) | 866 call assert_equal(test[1], position.width) |
862 call popup_close(winid) | 867 call popup_close(winid) |
863 endfor | 868 endfor |
869 \ ['a line that wraps once', 12, 2], | 874 \ ['a line that wraps once', 12, 2], |
870 \ ['a line that wraps two times', 12, 3], | 875 \ ['a line that wraps two times', 12, 3], |
871 \ ] | 876 \ ] |
872 for test in tests | 877 for test in tests |
873 let winid = popup_create(test[0], | 878 let winid = popup_create(test[0], |
874 \ *{line: 2, col: 3, maxwidth: 12}) | 879 \ ~{line: 2, col: 3, maxwidth: 12}) |
875 redraw | 880 redraw |
876 let position = popup_getpos(winid) | 881 let position = popup_getpos(winid) |
877 call assert_equal(test[1], position.width) | 882 call assert_equal(test[1], position.width) |
878 call assert_equal(test[2], position.height) | 883 call assert_equal(test[2], position.height) |
879 | 884 |
881 call assert_equal({}, popup_getpos(winid)) | 886 call assert_equal({}, popup_getpos(winid)) |
882 endfor | 887 endfor |
883 endfunc | 888 endfunc |
884 | 889 |
885 func Test_popup_getoptions() | 890 func Test_popup_getoptions() |
886 let winid = popup_create('hello', *{ | 891 let winid = popup_create('hello', ~{ |
887 \ line: 2, | 892 \ line: 2, |
888 \ col: 3, | 893 \ col: 3, |
889 \ minwidth: 10, | 894 \ minwidth: 10, |
890 \ minheight: 11, | 895 \ minheight: 11, |
891 \ maxwidth: 20, | 896 \ maxwidth: 20, |
974 call assert_equal('xxxvimxxxxxxxxxxx', line) | 979 call assert_equal('xxxvimxxxxxxxxxxx', line) |
975 call popup_close(winid) | 980 call popup_close(winid) |
976 | 981 |
977 call cursor(1, 1) | 982 call cursor(1, 1) |
978 redraw | 983 redraw |
979 let winid = popup_create('vim', *{ | 984 let winid = popup_create('vim', ~{ |
980 \ line: 'cursor+2', | 985 \ line: 'cursor+2', |
981 \ col: 'cursor+1', | 986 \ col: 'cursor+1', |
982 \}) | 987 \}) |
983 redraw | 988 redraw |
984 let line = join(map(range(1, 17), 'screenstring(3, v:val)'), '') | 989 let line = join(map(range(1, 17), 'screenstring(3, v:val)'), '') |
985 call assert_equal('xvimxxxxxxxxxxxxx', line) | 990 call assert_equal('xvimxxxxxxxxxxxxx', line) |
986 call popup_close(winid) | 991 call popup_close(winid) |
987 | 992 |
988 call cursor(3, 3) | 993 call cursor(3, 3) |
989 redraw | 994 redraw |
990 let winid = popup_create('vim', *{ | 995 let winid = popup_create('vim', ~{ |
991 \ line: 'cursor-2', | 996 \ line: 'cursor-2', |
992 \ col: 'cursor-1', | 997 \ col: 'cursor-1', |
993 \}) | 998 \}) |
994 redraw | 999 redraw |
995 let line = join(map(range(1, 17), 'screenstring(1, v:val)'), '') | 1000 let line = join(map(range(1, 17), 'screenstring(1, v:val)'), '') |
1054 call test_setmouse(5, 13) | 1059 call test_setmouse(5, 13) |
1055 call feedkeys("\<F5>\<MouseMove>\<Ignore>", "xt") | 1060 call feedkeys("\<F5>\<MouseMove>\<Ignore>", "xt") |
1056 endfunc | 1061 endfunc |
1057 END | 1062 END |
1058 call writefile(lines, 'XtestPopupBeval') | 1063 call writefile(lines, 'XtestPopupBeval') |
1059 let buf = RunVimInTerminal('-S XtestPopupBeval', *{rows: 10}) | 1064 let buf = RunVimInTerminal('-S XtestPopupBeval', ~{rows: 10}) |
1060 call term_wait(buf, 100) | 1065 call term_wait(buf, 100) |
1061 call term_sendkeys(buf, 'j') | 1066 call term_sendkeys(buf, 'j') |
1062 call term_sendkeys(buf, ":call Hover()\<CR>") | 1067 call term_sendkeys(buf, ":call Hover()\<CR>") |
1063 call VerifyScreenDump(buf, 'Test_popupwin_beval_1', {}) | 1068 call VerifyScreenDump(buf, 'Test_popupwin_beval_1', {}) |
1064 | 1069 |
1091 return 1 | 1096 return 1 |
1092 endif | 1097 endif |
1093 return 0 | 1098 return 0 |
1094 endfunc | 1099 endfunc |
1095 | 1100 |
1096 let winid = popup_create('something', *{filter: 'MyPopupFilter'}) | 1101 let winid = popup_create('something', ~{filter: 'MyPopupFilter'}) |
1097 redraw | 1102 redraw |
1098 | 1103 |
1099 " e is consumed by the filter | 1104 " e is consumed by the filter |
1100 call feedkeys('e', 'xt') | 1105 call feedkeys('e', 'xt') |
1101 call assert_equal('e', g:eaten) | 1106 call assert_equal('e', g:eaten) |
1116 call popup_clear() | 1121 call popup_clear() |
1117 endfunc | 1122 endfunc |
1118 | 1123 |
1119 func ShowDialog(key, result) | 1124 func ShowDialog(key, result) |
1120 let s:cb_res = 999 | 1125 let s:cb_res = 999 |
1121 let winid = popup_dialog('do you want to quit (Yes/no)?', *{ | 1126 let winid = popup_dialog('do you want to quit (Yes/no)?', ~{ |
1122 \ filter: 'popup_filter_yesno', | 1127 \ filter: 'popup_filter_yesno', |
1123 \ callback: 'QuitCallback', | 1128 \ callback: 'QuitCallback', |
1124 \ }) | 1129 \ }) |
1125 redraw | 1130 redraw |
1126 call feedkeys(a:key, "xt") | 1131 call feedkeys(a:key, "xt") |
1146 delfunc QuitCallback | 1151 delfunc QuitCallback |
1147 endfunc | 1152 endfunc |
1148 | 1153 |
1149 func ShowMenu(key, result) | 1154 func ShowMenu(key, result) |
1150 let s:cb_res = 999 | 1155 let s:cb_res = 999 |
1151 let winid = popup_menu(['one', 'two', 'something else'], *{ | 1156 let winid = popup_menu(['one', 'two', 'something else'], ~{ |
1152 \ callback: 'QuitCallback', | 1157 \ callback: 'QuitCallback', |
1153 \ }) | 1158 \ }) |
1154 redraw | 1159 redraw |
1155 call feedkeys(a:key, "xt") | 1160 call feedkeys(a:key, "xt") |
1156 call assert_equal(winid, s:cb_winid) | 1161 call assert_equal(winid, s:cb_winid) |
1182 endif | 1187 endif |
1183 | 1188 |
1184 let lines =<< trim END | 1189 let lines =<< trim END |
1185 call setline(1, range(1, 20)) | 1190 call setline(1, range(1, 20)) |
1186 hi PopupSelected ctermbg=lightblue | 1191 hi PopupSelected ctermbg=lightblue |
1187 call popup_menu(['one', 'two', 'another'], *{callback: 'MenuDone', title: ' make a choice from the list '}) | 1192 call popup_menu(['one', 'two', 'another'], ~{callback: 'MenuDone', title: ' make a choice from the list '}) |
1188 func MenuDone(id, res) | 1193 func MenuDone(id, res) |
1189 echomsg "selected " .. a:res | 1194 echomsg "selected " .. a:res |
1190 endfunc | 1195 endfunc |
1191 END | 1196 END |
1192 call writefile(lines, 'XtestPopupMenu') | 1197 call writefile(lines, 'XtestPopupMenu') |
1193 let buf = RunVimInTerminal('-S XtestPopupMenu', *{rows: 10}) | 1198 let buf = RunVimInTerminal('-S XtestPopupMenu', ~{rows: 10}) |
1194 call VerifyScreenDump(buf, 'Test_popupwin_menu_01', {}) | 1199 call VerifyScreenDump(buf, 'Test_popupwin_menu_01', {}) |
1195 | 1200 |
1196 call term_sendkeys(buf, "jj") | 1201 call term_sendkeys(buf, "jj") |
1197 call VerifyScreenDump(buf, 'Test_popupwin_menu_02', {}) | 1202 call VerifyScreenDump(buf, 'Test_popupwin_menu_02', {}) |
1198 | 1203 |
1211 | 1216 |
1212 " Create a popup without title or border, a line of padding will be added to | 1217 " Create a popup without title or border, a line of padding will be added to |
1213 " put the title on. | 1218 " put the title on. |
1214 let lines =<< trim END | 1219 let lines =<< trim END |
1215 call setline(1, range(1, 20)) | 1220 call setline(1, range(1, 20)) |
1216 call popup_create(['one', 'two', 'another'], *{title: 'Title String'}) | 1221 call popup_create(['one', 'two', 'another'], ~{title: 'Title String'}) |
1217 END | 1222 END |
1218 call writefile(lines, 'XtestPopupTitle') | 1223 call writefile(lines, 'XtestPopupTitle') |
1219 let buf = RunVimInTerminal('-S XtestPopupTitle', *{rows: 10}) | 1224 let buf = RunVimInTerminal('-S XtestPopupTitle', ~{rows: 10}) |
1220 call VerifyScreenDump(buf, 'Test_popupwin_title', {}) | 1225 call VerifyScreenDump(buf, 'Test_popupwin_title', {}) |
1221 | 1226 |
1222 " clean up | 1227 " clean up |
1223 call StopVimInTerminal(buf) | 1228 call StopVimInTerminal(buf) |
1224 call delete('XtestPopupTitle') | 1229 call delete('XtestPopupTitle') |
1225 | 1230 |
1226 let winid = popup_create('something', *{title: 'Some Title'}) | 1231 let winid = popup_create('something', ~{title: 'Some Title'}) |
1227 call assert_equal('Some Title', popup_getoptions(winid).title) | 1232 call assert_equal('Some Title', popup_getoptions(winid).title) |
1228 call popup_setoptions(winid, *{title: 'Another Title'}) | 1233 call popup_setoptions(winid, ~{title: 'Another Title'}) |
1229 call assert_equal('Another Title', popup_getoptions(winid).title) | 1234 call assert_equal('Another Title', popup_getoptions(winid).title) |
1230 | 1235 |
1231 call popup_clear() | 1236 call popup_clear() |
1232 endfunc | 1237 endfunc |
1233 | 1238 |
1234 func Test_popup_close_callback() | 1239 func Test_popup_close_callback() |
1235 func PopupDone(id, result) | 1240 func PopupDone(id, result) |
1236 let g:result = a:result | 1241 let g:result = a:result |
1237 endfunc | 1242 endfunc |
1238 let winid = popup_create('something', *{callback: 'PopupDone'}) | 1243 let winid = popup_create('something', ~{callback: 'PopupDone'}) |
1239 redraw | 1244 redraw |
1240 call popup_close(winid, 'done') | 1245 call popup_close(winid, 'done') |
1241 call assert_equal('done', g:result) | 1246 call assert_equal('done', g:result) |
1242 endfunc | 1247 endfunc |
1243 | 1248 |
1244 func Test_popup_empty() | 1249 func Test_popup_empty() |
1245 let winid = popup_create('', *{padding: [2,2,2,2]}) | 1250 let winid = popup_create('', ~{padding: [2,2,2,2]}) |
1246 redraw | 1251 redraw |
1247 let pos = popup_getpos(winid) | 1252 let pos = popup_getpos(winid) |
1248 call assert_equal(5, pos.width) | 1253 call assert_equal(5, pos.width) |
1249 call assert_equal(5, pos.height) | 1254 call assert_equal(5, pos.height) |
1250 | 1255 |
1251 let winid = popup_create([], *{border: []}) | 1256 let winid = popup_create([], ~{border: []}) |
1252 redraw | 1257 redraw |
1253 let pos = popup_getpos(winid) | 1258 let pos = popup_getpos(winid) |
1254 call assert_equal(3, pos.width) | 1259 call assert_equal(3, pos.width) |
1255 call assert_equal(3, pos.height) | 1260 call assert_equal(3, pos.height) |
1256 endfunc | 1261 endfunc |
1275 split | 1280 split |
1276 vsplit | 1281 vsplit |
1277 let info_window1 = getwininfo()[0] | 1282 let info_window1 = getwininfo()[0] |
1278 let line = info_window1['height'] | 1283 let line = info_window1['height'] |
1279 let col = info_window1['width'] | 1284 let col = info_window1['width'] |
1280 call popup_create(['line1', 'line2', 'line3', 'line4'], *{ | 1285 call popup_create(['line1', 'line2', 'line3', 'line4'], ~{ |
1281 \ line : line, | 1286 \ line : line, |
1282 \ col : col, | 1287 \ col : col, |
1283 \ }) | 1288 \ }) |
1284 END | 1289 END |
1285 call writefile(lines, 'XtestPopupBehind') | 1290 call writefile(lines, 'XtestPopupBehind') |
1286 let buf = RunVimInTerminal('-S XtestPopupBehind', *{rows: 10}) | 1291 let buf = RunVimInTerminal('-S XtestPopupBehind', ~{rows: 10}) |
1287 call term_sendkeys(buf, "\<C-W>w") | 1292 call term_sendkeys(buf, "\<C-W>w") |
1288 call VerifyScreenDump(buf, 'Test_popupwin_behind', {}) | 1293 call VerifyScreenDump(buf, 'Test_popupwin_behind', {}) |
1289 | 1294 |
1290 " clean up | 1295 " clean up |
1291 call StopVimInTerminal(buf) | 1296 call StopVimInTerminal(buf) |
1338 " - expected row | 1343 " - expected row |
1339 " - expected col | 1344 " - expected col |
1340 " - expected width | 1345 " - expected width |
1341 " - expected height | 1346 " - expected height |
1342 let tests = [ | 1347 let tests = [ |
1343 \ *{ | 1348 \ ~{ |
1344 \ comment: 'left-aligned with wrapping', | 1349 \ comment: 'left-aligned with wrapping', |
1345 \ options: *{ | 1350 \ options: ~{ |
1346 \ wrap: 1, | 1351 \ wrap: 1, |
1347 \ pos: 'botleft', | 1352 \ pos: 'botleft', |
1348 \ }, | 1353 \ }, |
1349 \ tests: both_wrap_tests + [ | 1354 \ tests: both_wrap_tests + [ |
1350 \ [ 'aaaa', 5, &columns, 4, &columns - 2, 3, 2 ], | 1355 \ [ 'aaaa', 5, &columns, 4, &columns - 2, 3, 2 ], |
1352 \ [ 'cccc', 5, &columns - 1, 4, &columns - 2, 3, 2 ], | 1357 \ [ 'cccc', 5, &columns - 1, 4, &columns - 2, 3, 2 ], |
1353 \ [ 'dddd', 5, &columns - 2, 4, &columns - 2, 3, 2 ], | 1358 \ [ 'dddd', 5, &columns - 2, 4, &columns - 2, 3, 2 ], |
1354 \ [ 'eeee', 5, &columns - 3, 5, &columns - 3, 4, 1 ], | 1359 \ [ 'eeee', 5, &columns - 3, 5, &columns - 3, 4, 1 ], |
1355 \ ], | 1360 \ ], |
1356 \ }, | 1361 \ }, |
1357 \ *{ | 1362 \ ~{ |
1358 \ comment: 'left aligned without wrapping', | 1363 \ comment: 'left aligned without wrapping', |
1359 \ options: *{ | 1364 \ options: ~{ |
1360 \ wrap: 0, | 1365 \ wrap: 0, |
1361 \ pos: 'botleft', | 1366 \ pos: 'botleft', |
1362 \ }, | 1367 \ }, |
1363 \ tests: both_wrap_tests + [ | 1368 \ tests: both_wrap_tests + [ |
1364 \ [ 'aaaa', 5, &columns, 5, &columns - 3, 4, 1 ], | 1369 \ [ 'aaaa', 5, &columns, 5, &columns - 3, 4, 1 ], |
1366 \ [ 'cccc', 5, &columns - 1, 5, &columns - 3, 4, 1 ], | 1371 \ [ 'cccc', 5, &columns - 1, 5, &columns - 3, 4, 1 ], |
1367 \ [ 'dddd', 5, &columns - 2, 5, &columns - 3, 4, 1 ], | 1372 \ [ 'dddd', 5, &columns - 2, 5, &columns - 3, 4, 1 ], |
1368 \ [ 'eeee', 5, &columns - 3, 5, &columns - 3, 4, 1 ], | 1373 \ [ 'eeee', 5, &columns - 3, 5, &columns - 3, 4, 1 ], |
1369 \ ], | 1374 \ ], |
1370 \ }, | 1375 \ }, |
1371 \ *{ | 1376 \ ~{ |
1372 \ comment: 'left aligned with fixed position', | 1377 \ comment: 'left aligned with fixed position', |
1373 \ options: *{ | 1378 \ options: ~{ |
1374 \ wrap: 0, | 1379 \ wrap: 0, |
1375 \ fixed: 1, | 1380 \ fixed: 1, |
1376 \ pos: 'botleft', | 1381 \ pos: 'botleft', |
1377 \ }, | 1382 \ }, |
1378 \ tests: both_wrap_tests + [ | 1383 \ tests: both_wrap_tests + [ |
1386 \ ] | 1391 \ ] |
1387 | 1392 |
1388 for test_group in tests | 1393 for test_group in tests |
1389 for test in test_group.tests | 1394 for test in test_group.tests |
1390 let [ text, line, col, e_line, e_col, e_width, e_height ] = test | 1395 let [ text, line, col, e_line, e_col, e_width, e_height ] = test |
1391 let options = *{ | 1396 let options = ~{ |
1392 \ line: line, | 1397 \ line: line, |
1393 \ col: col, | 1398 \ col: col, |
1394 \ } | 1399 \ } |
1395 call extend( options, test_group.options ) | 1400 call extend( options, test_group.options ) |
1396 | 1401 |
1397 let p = popup_create( text, options ) | 1402 let p = popup_create( text, options ) |
1398 | 1403 |
1399 let msg = string(extend(options, *{text: text})) | 1404 let msg = string(extend(options, ~{text: text})) |
1400 call s:VerifyPosition(p, msg, e_line, e_col, e_width, e_height) | 1405 call s:VerifyPosition(p, msg, e_line, e_col, e_width, e_height) |
1401 call popup_close(p) | 1406 call popup_close(p) |
1402 endfor | 1407 endfor |
1403 endfor | 1408 endfor |
1404 | 1409 |
1408 | 1413 |
1409 func Test_adjust_left_past_screen_width() | 1414 func Test_adjust_left_past_screen_width() |
1410 " width of screen | 1415 " width of screen |
1411 let X = join(map(range(&columns), {->'X'}), '') | 1416 let X = join(map(range(&columns), {->'X'}), '') |
1412 | 1417 |
1413 let p = popup_create( X, *{line: 1, col: 1, wrap: 0}) | 1418 let p = popup_create( X, ~{line: 1, col: 1, wrap: 0}) |
1414 call s:VerifyPosition( p, 'full width topleft', 1, 1, &columns, 1 ) | 1419 call s:VerifyPosition( p, 'full width topleft', 1, 1, &columns, 1 ) |
1415 | 1420 |
1416 redraw | 1421 redraw |
1417 let line = join(map(range(1, &columns + 1), 'screenstring(1, v:val)'), '') | 1422 let line = join(map(range(1, &columns + 1), 'screenstring(1, v:val)'), '') |
1418 call assert_equal(X, line) | 1423 call assert_equal(X, line) |
1419 | 1424 |
1420 call popup_close( p ) | 1425 call popup_close( p ) |
1421 redraw | 1426 redraw |
1422 | 1427 |
1423 " Same if placed on the right hand side | 1428 " Same if placed on the right hand side |
1424 let p = popup_create( X, *{line: 1, col: &columns, wrap: 0}) | 1429 let p = popup_create( X, ~{line: 1, col: &columns, wrap: 0}) |
1425 call s:VerifyPosition( p, 'full width topright', 1, 1, &columns, 1 ) | 1430 call s:VerifyPosition( p, 'full width topright', 1, 1, &columns, 1 ) |
1426 | 1431 |
1427 redraw | 1432 redraw |
1428 let line = join(map(range(1, &columns + 1), 'screenstring(1, v:val)'), '') | 1433 let line = join(map(range(1, &columns + 1), 'screenstring(1, v:val)'), '') |
1429 call assert_equal(X, line) | 1434 call assert_equal(X, line) |
1432 redraw | 1437 redraw |
1433 | 1438 |
1434 " Extend so > window width | 1439 " Extend so > window width |
1435 let X .= 'x' | 1440 let X .= 'x' |
1436 | 1441 |
1437 let p = popup_create( X, *{line: 1, col: 1, wrap: 0}) | 1442 let p = popup_create( X, ~{line: 1, col: 1, wrap: 0}) |
1438 call s:VerifyPosition( p, 'full width + 1 topleft', 1, 1, &columns, 1 ) | 1443 call s:VerifyPosition( p, 'full width + 1 topleft', 1, 1, &columns, 1 ) |
1439 | 1444 |
1440 redraw | 1445 redraw |
1441 let line = join(map(range(1, &columns + 1), 'screenstring(1, v:val)'), '') | 1446 let line = join(map(range(1, &columns + 1), 'screenstring(1, v:val)'), '') |
1442 call assert_equal(X[ : -2 ], line) | 1447 call assert_equal(X[ : -2 ], line) |
1443 | 1448 |
1444 call popup_close( p ) | 1449 call popup_close( p ) |
1445 redraw | 1450 redraw |
1446 | 1451 |
1447 " Shifted then truncated (the x is not visible) | 1452 " Shifted then truncated (the x is not visible) |
1448 let p = popup_create( X, *{line: 1, col: &columns - 3, wrap: 0}) | 1453 let p = popup_create( X, ~{line: 1, col: &columns - 3, wrap: 0}) |
1449 call s:VerifyPosition( p, 'full width + 1 topright', 1, 1, &columns, 1 ) | 1454 call s:VerifyPosition( p, 'full width + 1 topright', 1, 1, &columns, 1 ) |
1450 | 1455 |
1451 redraw | 1456 redraw |
1452 let line = join(map(range(1, &columns + 1), 'screenstring(1, v:val)'), '') | 1457 let line = join(map(range(1, &columns + 1), 'screenstring(1, v:val)'), '') |
1453 call assert_equal(X[ : -2 ], line) | 1458 call assert_equal(X[ : -2 ], line) |
1455 call popup_close( p ) | 1460 call popup_close( p ) |
1456 redraw | 1461 redraw |
1457 | 1462 |
1458 " Not shifted, just truncated | 1463 " Not shifted, just truncated |
1459 let p = popup_create( X, | 1464 let p = popup_create( X, |
1460 \ *{line: 1, col: 2, wrap: 0, fixed: 1}) | 1465 \ ~{line: 1, col: 2, wrap: 0, fixed: 1}) |
1461 call s:VerifyPosition( p, 'full width + 1 fixed', 1, 2, &columns - 1, 1) | 1466 call s:VerifyPosition( p, 'full width + 1 fixed', 1, 2, &columns - 1, 1) |
1462 | 1467 |
1463 redraw | 1468 redraw |
1464 let line = join(map(range(1, &columns + 1), 'screenstring(1, v:val)'), '') | 1469 let line = join(map(range(1, &columns + 1), 'screenstring(1, v:val)'), '') |
1465 let e_line = ' ' . X[ 1 : -2 ] | 1470 let e_line = ' ' . X[ 1 : -2 ] |
1476 new | 1481 new |
1477 call test_override('char_avail', 1) | 1482 call test_override('char_avail', 1) |
1478 call setline(1, ['one word to move around', 'a WORD.and->some thing']) | 1483 call setline(1, ['one word to move around', 'a WORD.and->some thing']) |
1479 | 1484 |
1480 exe "normal gg0/word\<CR>" | 1485 exe "normal gg0/word\<CR>" |
1481 let winid = popup_atcursor('text', *{moved: 'any'}) | 1486 let winid = popup_atcursor('text', ~{moved: 'any'}) |
1482 redraw | 1487 redraw |
1483 call assert_equal(1, popup_getpos(winid).visible) | 1488 call assert_equal(1, popup_getpos(winid).visible) |
1484 call assert_equal([1, 4, 4], popup_getoptions(winid).moved) | 1489 call assert_equal([1, 4, 4], popup_getoptions(winid).moved) |
1485 " trigger the check for last_cursormoved by going into insert mode | 1490 " trigger the check for last_cursormoved by going into insert mode |
1486 call feedkeys("li\<Esc>", 'xt') | 1491 call feedkeys("li\<Esc>", 'xt') |
1487 call assert_equal({}, popup_getpos(winid)) | 1492 call assert_equal({}, popup_getpos(winid)) |
1488 call popup_clear() | 1493 call popup_clear() |
1489 | 1494 |
1490 exe "normal gg0/word\<CR>" | 1495 exe "normal gg0/word\<CR>" |
1491 let winid = popup_atcursor('text', *{moved: 'word'}) | 1496 let winid = popup_atcursor('text', ~{moved: 'word'}) |
1492 redraw | 1497 redraw |
1493 call assert_equal(1, popup_getpos(winid).visible) | 1498 call assert_equal(1, popup_getpos(winid).visible) |
1494 call assert_equal([1, 4, 7], popup_getoptions(winid).moved) | 1499 call assert_equal([1, 4, 7], popup_getoptions(winid).moved) |
1495 call feedkeys("hi\<Esc>", 'xt') | 1500 call feedkeys("hi\<Esc>", 'xt') |
1496 call assert_equal({}, popup_getpos(winid)) | 1501 call assert_equal({}, popup_getpos(winid)) |
1497 call popup_clear() | 1502 call popup_clear() |
1498 | 1503 |
1499 exe "normal gg0/word\<CR>" | 1504 exe "normal gg0/word\<CR>" |
1500 let winid = popup_atcursor('text', *{moved: 'word'}) | 1505 let winid = popup_atcursor('text', ~{moved: 'word'}) |
1501 redraw | 1506 redraw |
1502 call assert_equal(1, popup_getpos(winid).visible) | 1507 call assert_equal(1, popup_getpos(winid).visible) |
1503 call assert_equal([1, 4, 7], popup_getoptions(winid).moved) | 1508 call assert_equal([1, 4, 7], popup_getoptions(winid).moved) |
1504 call feedkeys("li\<Esc>", 'xt') | 1509 call feedkeys("li\<Esc>", 'xt') |
1505 call assert_equal(1, popup_getpos(winid).visible) | 1510 call assert_equal(1, popup_getpos(winid).visible) |
1522 call feedkeys("Eli\<Esc>", 'xt') | 1527 call feedkeys("Eli\<Esc>", 'xt') |
1523 call assert_equal({}, popup_getpos(winid)) | 1528 call assert_equal({}, popup_getpos(winid)) |
1524 call popup_clear() | 1529 call popup_clear() |
1525 | 1530 |
1526 exe "normal gg0/word\<CR>" | 1531 exe "normal gg0/word\<CR>" |
1527 let winid = popup_atcursor('text', *{moved: [5, 10]}) | 1532 let winid = popup_atcursor('text', ~{moved: [5, 10]}) |
1528 redraw | 1533 redraw |
1529 call assert_equal(1, popup_getpos(winid).visible) | 1534 call assert_equal(1, popup_getpos(winid).visible) |
1530 call feedkeys("eli\<Esc>", 'xt') | 1535 call feedkeys("eli\<Esc>", 'xt') |
1531 call feedkeys("ei\<Esc>", 'xt') | 1536 call feedkeys("ei\<Esc>", 'xt') |
1532 call assert_equal(1, popup_getpos(winid).visible) | 1537 call assert_equal(1, popup_getpos(winid).visible) |
1549 call writefile([ | 1554 call writefile([ |
1550 \ "call setline(1, range(1, 20))", | 1555 \ "call setline(1, range(1, 20))", |
1551 \ "hi Notification ctermbg=lightblue", | 1556 \ "hi Notification ctermbg=lightblue", |
1552 \ "call popup_notification('first notification', {})", | 1557 \ "call popup_notification('first notification', {})", |
1553 \], 'XtestNotifications') | 1558 \], 'XtestNotifications') |
1554 let buf = RunVimInTerminal('-S XtestNotifications', *{rows: 10}) | 1559 let buf = RunVimInTerminal('-S XtestNotifications', ~{rows: 10}) |
1555 call VerifyScreenDump(buf, 'Test_popupwin_notify_01', {}) | 1560 call VerifyScreenDump(buf, 'Test_popupwin_notify_01', {}) |
1556 | 1561 |
1557 " second one goes below the first one | 1562 " second one goes below the first one |
1558 call term_sendkeys(buf, ":hi link PopupNotification Notification\<CR>") | 1563 call term_sendkeys(buf, ":hi link PopupNotification Notification\<CR>") |
1559 call term_sendkeys(buf, ":call popup_notification('another important notification', {})\<CR>") | 1564 call term_sendkeys(buf, ":call popup_notification('another important notification', {})\<CR>") |
1572 let lines =<< trim END | 1577 let lines =<< trim END |
1573 call setline(1, range(1, 20)) | 1578 call setline(1, range(1, 20)) |
1574 hi ScrollThumb ctermbg=blue | 1579 hi ScrollThumb ctermbg=blue |
1575 hi ScrollBar ctermbg=red | 1580 hi ScrollBar ctermbg=red |
1576 let winid = popup_create(['one', 'two', 'three', 'four', 'five', | 1581 let winid = popup_create(['one', 'two', 'three', 'four', 'five', |
1577 \ 'six', 'seven', 'eight', 'nine'], *{ | 1582 \ 'six', 'seven', 'eight', 'nine'], ~{ |
1578 \ minwidth: 8, | 1583 \ minwidth: 8, |
1579 \ maxheight: 4, | 1584 \ maxheight: 4, |
1580 \ }) | 1585 \ }) |
1581 func ScrollUp() | 1586 func ScrollUp() |
1582 call feedkeys("\<F3>\<ScrollWheelUp>", "xt") | 1587 call feedkeys("\<F3>\<ScrollWheelUp>", "xt") |
1586 endfunc | 1591 endfunc |
1587 func ClickTop() | 1592 func ClickTop() |
1588 call feedkeys("\<F4>\<LeftMouse>", "xt") | 1593 call feedkeys("\<F4>\<LeftMouse>", "xt") |
1589 endfunc | 1594 endfunc |
1590 func ClickBot() | 1595 func ClickBot() |
1591 call popup_setoptions(g:winid, *{border: [], close: 'button'}) | 1596 call popup_setoptions(g:winid, ~{border: [], close: 'button'}) |
1592 call feedkeys("\<F5>\<LeftMouse>", "xt") | 1597 call feedkeys("\<F5>\<LeftMouse>", "xt") |
1593 endfunc | 1598 endfunc |
1594 map <silent> <F3> :call test_setmouse(5, 36)<CR> | 1599 map <silent> <F3> :call test_setmouse(5, 36)<CR> |
1595 map <silent> <F4> :call test_setmouse(4, 42)<CR> | 1600 map <silent> <F4> :call test_setmouse(4, 42)<CR> |
1596 map <silent> <F5> :call test_setmouse(7, 42)<CR> | 1601 map <silent> <F5> :call test_setmouse(7, 42)<CR> |
1597 END | 1602 END |
1598 call writefile(lines, 'XtestPopupScroll') | 1603 call writefile(lines, 'XtestPopupScroll') |
1599 let buf = RunVimInTerminal('-S XtestPopupScroll', *{rows: 10}) | 1604 let buf = RunVimInTerminal('-S XtestPopupScroll', ~{rows: 10}) |
1600 call VerifyScreenDump(buf, 'Test_popupwin_scroll_1', {}) | 1605 call VerifyScreenDump(buf, 'Test_popupwin_scroll_1', {}) |
1601 | 1606 |
1602 call term_sendkeys(buf, ":call popup_setoptions(winid, *{firstline: 2})\<CR>") | 1607 call term_sendkeys(buf, ":call popup_setoptions(winid, ~{firstline: 2})\<CR>") |
1608 call term_sendkeys(buf, ":\<CR>") | |
1603 call VerifyScreenDump(buf, 'Test_popupwin_scroll_2', {}) | 1609 call VerifyScreenDump(buf, 'Test_popupwin_scroll_2', {}) |
1604 | 1610 |
1605 call term_sendkeys(buf, ":call popup_setoptions(winid, *{firstline: 6})\<CR>") | 1611 call term_sendkeys(buf, ":call popup_setoptions(winid, ~{firstline: 6})\<CR>") |
1612 call term_sendkeys(buf, ":\<CR>") | |
1606 call VerifyScreenDump(buf, 'Test_popupwin_scroll_3', {}) | 1613 call VerifyScreenDump(buf, 'Test_popupwin_scroll_3', {}) |
1607 | 1614 |
1608 call term_sendkeys(buf, ":call popup_setoptions(winid, *{firstline: 9})\<CR>") | 1615 call term_sendkeys(buf, ":call popup_setoptions(winid, ~{firstline: 9})\<CR>") |
1616 call term_sendkeys(buf, ":\<CR>") | |
1609 call VerifyScreenDump(buf, 'Test_popupwin_scroll_4', {}) | 1617 call VerifyScreenDump(buf, 'Test_popupwin_scroll_4', {}) |
1610 | 1618 |
1611 call term_sendkeys(buf, ":call popup_setoptions(winid, *{scrollbarhighlight: 'ScrollBar', thumbhighlight: 'ScrollThumb'})\<CR>") | 1619 call term_sendkeys(buf, ":call popup_setoptions(winid, ~{scrollbarhighlight: 'ScrollBar', thumbhighlight: 'ScrollThumb'})\<CR>") |
1612 call term_sendkeys(buf, ":call ScrollUp()\<CR>") | 1620 call term_sendkeys(buf, ":call ScrollUp()\<CR>") |
1613 call VerifyScreenDump(buf, 'Test_popupwin_scroll_5', {}) | 1621 call VerifyScreenDump(buf, 'Test_popupwin_scroll_5', {}) |
1614 | 1622 |
1615 call term_sendkeys(buf, ":call ScrollDown()\<CR>") | 1623 call term_sendkeys(buf, ":call ScrollDown()\<CR>") |
1616 call VerifyScreenDump(buf, 'Test_popupwin_scroll_6', {}) | 1624 call VerifyScreenDump(buf, 'Test_popupwin_scroll_6', {}) |
1635 endfunc | 1643 endfunc |
1636 | 1644 |
1637 func Test_popup_fitting_scrollbar() | 1645 func Test_popup_fitting_scrollbar() |
1638 " this was causing a crash, divide by zero | 1646 " this was causing a crash, divide by zero |
1639 let winid = popup_create([ | 1647 let winid = popup_create([ |
1640 \ 'one', 'two', 'longer line that wraps', 'four', 'five'], *{ | 1648 \ 'one', 'two', 'longer line that wraps', 'four', 'five'], ~{ |
1641 \ scrollbar: 1, | 1649 \ scrollbar: 1, |
1642 \ maxwidth: 10, | 1650 \ maxwidth: 10, |
1643 \ maxheight: 5, | 1651 \ maxheight: 5, |
1644 \ firstline: 2}) | 1652 \ firstline: 2}) |
1645 redraw | 1653 redraw |
1650 if !CanRunVimInTerminal() | 1658 if !CanRunVimInTerminal() |
1651 throw 'Skipped: cannot make screendumps' | 1659 throw 'Skipped: cannot make screendumps' |
1652 endif | 1660 endif |
1653 | 1661 |
1654 let lines =<< trim END | 1662 let lines =<< trim END |
1655 let opts = *{wrap: 0} | 1663 let opts = ~{wrap: 0} |
1656 let p = popup_create('test', opts) | 1664 let p = popup_create('test', opts) |
1657 call popup_settext(p, 'this is a text') | 1665 call popup_settext(p, 'this is a text') |
1658 END | 1666 END |
1659 | 1667 |
1660 call writefile( lines, 'XtestPopupSetText' ) | 1668 call writefile( lines, 'XtestPopupSetText' ) |
1661 let buf = RunVimInTerminal('-S XtestPopupSetText', *{rows: 10}) | 1669 let buf = RunVimInTerminal('-S XtestPopupSetText', ~{rows: 10}) |
1662 call VerifyScreenDump(buf, 'Test_popup_settext_01', {}) | 1670 call VerifyScreenDump(buf, 'Test_popup_settext_01', {}) |
1663 | 1671 |
1664 " Setting to empty string clears it | 1672 " Setting to empty string clears it |
1665 call term_sendkeys(buf, ":call popup_settext(p, '')\<CR>") | 1673 call term_sendkeys(buf, ":call popup_settext(p, '')\<CR>") |
1666 call VerifyScreenDump(buf, 'Test_popup_settext_02', {}) | 1674 call VerifyScreenDump(buf, 'Test_popup_settext_02', {}) |
1680 " Empty list clears | 1688 " Empty list clears |
1681 call term_sendkeys(buf, ":call popup_settext(p, [])\<CR>") | 1689 call term_sendkeys(buf, ":call popup_settext(p, [])\<CR>") |
1682 call VerifyScreenDump(buf, 'Test_popup_settext_05', {}) | 1690 call VerifyScreenDump(buf, 'Test_popup_settext_05', {}) |
1683 | 1691 |
1684 " Dicts | 1692 " Dicts |
1685 call term_sendkeys(buf, ":call popup_settext(p, [*{text: 'aaaa'}, *{text: 'bbbb'}, *{text: 'cccc'}])\<CR>") | 1693 call term_sendkeys(buf, ":call popup_settext(p, [~{text: 'aaaa'}, ~{text: 'bbbb'}, ~{text: 'cccc'}])\<CR>") |
1686 call VerifyScreenDump(buf, 'Test_popup_settext_06', {}) | 1694 call VerifyScreenDump(buf, 'Test_popup_settext_06', {}) |
1687 | 1695 |
1688 " clean up | 1696 " clean up |
1689 call StopVimInTerminal(buf) | 1697 call StopVimInTerminal(buf) |
1690 call delete('XtestPopupSetText') | 1698 call delete('XtestPopupSetText') |
1691 endfunc | 1699 endfunc |
1692 | 1700 |
1693 func Test_popup_hidden() | 1701 func Test_popup_hidden() |
1694 new | 1702 new |
1695 | 1703 |
1696 let winid = popup_atcursor('text', *{hidden: 1}) | 1704 let winid = popup_atcursor('text', ~{hidden: 1}) |
1697 redraw | 1705 redraw |
1698 call assert_equal(0, popup_getpos(winid).visible) | 1706 call assert_equal(0, popup_getpos(winid).visible) |
1699 call popup_close(winid) | 1707 call popup_close(winid) |
1700 | 1708 |
1701 let winid = popup_create('text', *{hidden: 1}) | 1709 let winid = popup_create('text', ~{hidden: 1}) |
1702 redraw | 1710 redraw |
1703 call assert_equal(0, popup_getpos(winid).visible) | 1711 call assert_equal(0, popup_getpos(winid).visible) |
1704 call popup_close(winid) | 1712 call popup_close(winid) |
1705 | 1713 |
1706 func QuitCallback(id, res) | 1714 func QuitCallback(id, res) |
1707 let s:cb_winid = a:id | 1715 let s:cb_winid = a:id |
1708 let s:cb_res = a:res | 1716 let s:cb_res = a:res |
1709 endfunc | 1717 endfunc |
1710 let winid = popup_dialog('make a choice', *{hidden: 1, | 1718 let winid = popup_dialog('make a choice', ~{hidden: 1, |
1711 \ filter: 'popup_filter_yesno', | 1719 \ filter: 'popup_filter_yesno', |
1712 \ callback: 'QuitCallback', | 1720 \ callback: 'QuitCallback', |
1713 \ }) | 1721 \ }) |
1714 redraw | 1722 redraw |
1715 call assert_equal(0, popup_getpos(winid).visible) | 1723 call assert_equal(0, popup_getpos(winid).visible) |
1726 delfunc QuitCallback | 1734 delfunc QuitCallback |
1727 endfunc | 1735 endfunc |
1728 | 1736 |
1729 " Test options not checked elsewhere | 1737 " Test options not checked elsewhere |
1730 func Test_set_get_options() | 1738 func Test_set_get_options() |
1731 let winid = popup_create('some text', *{highlight: 'Beautiful'}) | 1739 let winid = popup_create('some text', ~{highlight: 'Beautiful'}) |
1732 let options = popup_getoptions(winid) | 1740 let options = popup_getoptions(winid) |
1733 call assert_equal(1, options.wrap) | 1741 call assert_equal(1, options.wrap) |
1734 call assert_equal(0, options.drag) | 1742 call assert_equal(0, options.drag) |
1735 call assert_equal('Beautiful', options.highlight) | 1743 call assert_equal('Beautiful', options.highlight) |
1736 | 1744 |
1737 call popup_setoptions(winid, *{wrap: 0, drag: 1, highlight: 'Another'}) | 1745 call popup_setoptions(winid, ~{wrap: 0, drag: 1, highlight: 'Another'}) |
1738 let options = popup_getoptions(winid) | 1746 let options = popup_getoptions(winid) |
1739 call assert_equal(0, options.wrap) | 1747 call assert_equal(0, options.wrap) |
1740 call assert_equal(1, options.drag) | 1748 call assert_equal(1, options.drag) |
1741 call assert_equal('Another', options.highlight) | 1749 call assert_equal('Another', options.highlight) |
1742 | 1750 |
1746 func Test_popupwin_garbage_collect() | 1754 func Test_popupwin_garbage_collect() |
1747 func MyPopupFilter(x, winid, c) | 1755 func MyPopupFilter(x, winid, c) |
1748 " NOP | 1756 " NOP |
1749 endfunc | 1757 endfunc |
1750 | 1758 |
1751 let winid = popup_create('something', *{filter: function('MyPopupFilter', [{}])}) | 1759 let winid = popup_create('something', ~{filter: function('MyPopupFilter', [{}])}) |
1752 call test_garbagecollect_now() | 1760 call test_garbagecollect_now() |
1753 redraw | 1761 redraw |
1754 " Must not crach caused by invalid memory access | 1762 " Must not crach caused by invalid memory access |
1755 call feedkeys('j', 'xt') | 1763 call feedkeys('j', 'xt') |
1756 call assert_true(v:true) | 1764 call assert_true(v:true) |
1779 call popup_close(winid) | 1787 call popup_close(winid) |
1780 call delete('XsomeFile') | 1788 call delete('XsomeFile') |
1781 endfunc | 1789 endfunc |
1782 | 1790 |
1783 func Test_popupwin_width() | 1791 func Test_popupwin_width() |
1784 let winid = popup_create(repeat(['short', 'long long long line', 'medium width'], 50), *{ | 1792 let winid = popup_create(repeat(['short', 'long long long line', 'medium width'], 50), ~{ |
1785 \ maxwidth: 40, | 1793 \ maxwidth: 40, |
1786 \ maxheight: 10, | 1794 \ maxheight: 10, |
1787 \ }) | 1795 \ }) |
1788 for top in range(1, 20) | 1796 for top in range(1, 20) |
1789 call popup_setoptions(winid, *{firstline: top}) | 1797 call popup_setoptions(winid, ~{firstline: top}) |
1790 redraw | 1798 redraw |
1791 call assert_equal(19, popup_getpos(winid).width) | 1799 call assert_equal(19, popup_getpos(winid).width) |
1792 endfor | 1800 endfor |
1793 call popup_clear() | 1801 call popup_clear() |
1794 endfunc | 1802 endfunc |
1828 let lines =<< trim END | 1836 let lines =<< trim END |
1829 call setline(1, range(1, 10)) | 1837 call setline(1, range(1, 10)) |
1830 hi ScrollThumb ctermbg=blue | 1838 hi ScrollThumb ctermbg=blue |
1831 hi ScrollBar ctermbg=red | 1839 hi ScrollBar ctermbg=red |
1832 func PopupMenu(lines, line, col, scrollbar = 0) | 1840 func PopupMenu(lines, line, col, scrollbar = 0) |
1833 return popup_menu(a:lines, *{ | 1841 return popup_menu(a:lines, ~{ |
1834 \ maxwidth: 10, | 1842 \ maxwidth: 10, |
1835 \ maxheight: 3, | 1843 \ maxheight: 3, |
1836 \ pos : 'topleft', | 1844 \ pos : 'topleft', |
1837 \ col : a:col, | 1845 \ col : a:col, |
1838 \ line : a:line, | 1846 \ line : a:line, |
1844 call PopupMenu(['123456789|' .. ' '], 7, 1) | 1852 call PopupMenu(['123456789|' .. ' '], 7, 1) |
1845 call PopupMenu([repeat('123456789|', 100)], 7, 16) | 1853 call PopupMenu([repeat('123456789|', 100)], 7, 16) |
1846 call PopupMenu(repeat(['123456789|' .. ' '], 5), 1, 33, 1) | 1854 call PopupMenu(repeat(['123456789|' .. ' '], 5), 1, 33, 1) |
1847 END | 1855 END |
1848 call writefile(lines, 'XtestPopupMenuMaxWidth') | 1856 call writefile(lines, 'XtestPopupMenuMaxWidth') |
1849 let buf = RunVimInTerminal('-S XtestPopupMenuMaxWidth', *{rows: 13}) | 1857 let buf = RunVimInTerminal('-S XtestPopupMenuMaxWidth', ~{rows: 13}) |
1850 call VerifyScreenDump(buf, 'Test_popupwin_menu_maxwidth_1', {}) | 1858 call VerifyScreenDump(buf, 'Test_popupwin_menu_maxwidth_1', {}) |
1851 | 1859 |
1852 " close the menu popupwin. | 1860 " close the menu popupwin. |
1853 call term_sendkeys(buf, " ") | 1861 call term_sendkeys(buf, " ") |
1854 call term_sendkeys(buf, " ") | 1862 call term_sendkeys(buf, " ") |
1869 let lines =<< trim END | 1877 let lines =<< trim END |
1870 call setline(1, range(1, 20)) | 1878 call setline(1, range(1, 20)) |
1871 hi ScrollThumb ctermbg=blue | 1879 hi ScrollThumb ctermbg=blue |
1872 hi ScrollBar ctermbg=red | 1880 hi ScrollBar ctermbg=red |
1873 call popup_menu(['one', 'two', 'three', 'four', 'five', | 1881 call popup_menu(['one', 'two', 'three', 'four', 'five', |
1874 \ 'six', 'seven', 'eight', 'nine'], *{ | 1882 \ 'six', 'seven', 'eight', 'nine'], ~{ |
1875 \ minwidth: 8, | 1883 \ minwidth: 8, |
1876 \ maxheight: 3, | 1884 \ maxheight: 3, |
1877 \ }) | 1885 \ }) |
1878 END | 1886 END |
1879 call writefile(lines, 'XtestPopupMenuScroll') | 1887 call writefile(lines, 'XtestPopupMenuScroll') |
1880 let buf = RunVimInTerminal('-S XtestPopupMenuScroll', *{rows: 10}) | 1888 let buf = RunVimInTerminal('-S XtestPopupMenuScroll', ~{rows: 10}) |
1881 | 1889 |
1882 call term_sendkeys(buf, "j") | 1890 call term_sendkeys(buf, "j") |
1883 call VerifyScreenDump(buf, 'Test_popupwin_menu_scroll_1', {}) | 1891 call VerifyScreenDump(buf, 'Test_popupwin_menu_scroll_1', {}) |
1884 | 1892 |
1885 call term_sendkeys(buf, "jjj") | 1893 call term_sendkeys(buf, "jjj") |