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