comparison src/testdir/test_popupwin.vim @ 17368:6604ecb7a615 v8.1.1683

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