comparison src/testdir/test_popupwin.vim @ 16817:069ee8dc8c8d v8.1.1410

patch 8.1.1410: popup_move() is not implemented yet commit https://github.com/vim/vim/commit/60cdb3004abe683e5e8851fa6c5d67b337df4443 Author: Bram Moolenaar <Bram@vim.org> Date: Mon May 27 21:54:10 2019 +0200 patch 8.1.1410: popup_move() is not implemented yet Problem: Popup_move() is not implemented yet. Solution: Implement it. (Yasuhiro Matsumoto, closes https://github.com/vim/vim/issues/4441) Improve the positioning and resizing.
author Bram Moolenaar <Bram@vim.org>
date Mon, 27 May 2019 22:00:07 +0200
parents 0457d49eb2d9
children 5cebaecad422
comparison
equal deleted inserted replaced
16816:b951a6ebd627 16817:069ee8dc8c8d
14 \ "call setline(1, range(1, 100))", 14 \ "call setline(1, range(1, 100))",
15 \ "hi PopupColor1 ctermbg=lightblue", 15 \ "hi PopupColor1 ctermbg=lightblue",
16 \ "hi PopupColor2 ctermbg=lightcyan", 16 \ "hi PopupColor2 ctermbg=lightcyan",
17 \ "hi Comment ctermfg=red", 17 \ "hi Comment ctermfg=red",
18 \ "call prop_type_add('comment', {'highlight': 'Comment'})", 18 \ "call prop_type_add('comment', {'highlight': 'Comment'})",
19 \ "let winid = popup_create('hello there', {'line': 3, 'col': 11, 'highlight': 'PopupColor1'})", 19 \ "let winid = popup_create('hello there', {'line': 3, 'col': 11, 'minwidth': 20, 'highlight': 'PopupColor1'})",
20 \ "let winid2 = popup_create(['another one', 'another two', 'another three'], {'line': 3, 'col': 25})", 20 \ "let winid2 = popup_create(['another one', 'another two', 'another three'], {'line': 3, 'col': 25, 'minwidth': 20})",
21 \ "call setwinvar(winid2, '&wincolor', 'PopupColor2')", 21 \ "call setwinvar(winid2, '&wincolor', 'PopupColor2')",
22 \], 'XtestPopup') 22 \], '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, ":call 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, 'type': 'comment'" 31 \ .. "'col': 3, 'length': 7, 'minwidth': 20, 'type': 'comment'"
32 \ .. "}]}," 32 \ .. "}]},"
33 \ .. "], {'line': 4, 'col': 9})\<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', {})
39 39
40 " close that tabpage 40 " close that tabpage
41 call term_sendkeys(buf, ":quit!\<CR>") 41 call term_sendkeys(buf, ":quit!\<CR>")
42 call VerifyScreenDump(buf, 'Test_popupwin_04', {}) 42 call VerifyScreenDump(buf, 'Test_popupwin_04', {})
43
44 " resize popup
45 call term_sendkeys(buf, ":call popup_move(popupwin, {'minwidth': 15, 'maxwidth': 25, 'minheight': 3, 'maxheight': 5})\<CR>")
46 call term_sendkeys(buf, ":redraw\<CR>")
47 call VerifyScreenDump(buf, 'Test_popupwin_05', {})
43 48
44 " clean up 49 " clean up
45 call StopVimInTerminal(buf) 50 call StopVimInTerminal(buf)
46 call delete('XtestPopup') 51 call delete('XtestPopup')
47 endfunc 52 endfunc
54 call setline(1, 'hello') 59 call setline(1, 'hello')
55 60
56 call popup_create('world', { 61 call popup_create('world', {
57 \ 'line': 1, 62 \ 'line': 1,
58 \ 'col': 1, 63 \ 'col': 1,
64 \ 'minwidth': 20,
59 \ 'time': 500, 65 \ 'time': 500,
60 \}) 66 \})
61 redraw 67 redraw
62 let line = join(map(range(1, 5), 'screenstring(1, v:val)'), '') 68 let line = join(map(range(1, 5), 'screenstring(1, v:val)'), '')
63 call assert_equal('world', line) 69 call assert_equal('world', line)
68 call assert_equal('hello', line) 74 call assert_equal('hello', line)
69 75
70 call popup_create('on the command line', { 76 call popup_create('on the command line', {
71 \ 'line': &lines, 77 \ 'line': &lines,
72 \ 'col': 10, 78 \ 'col': 10,
79 \ 'minwidth': 20,
73 \ 'time': 500, 80 \ 'time': 500,
74 \}) 81 \})
75 redraw 82 redraw
76 let line = join(map(range(1, 30), 'screenstring(&lines, v:val)'), '') 83 let line = join(map(range(1, 30), 'screenstring(&lines, v:val)'), '')
77 call assert_match('.*on the command line.*', line) 84 call assert_match('.*on the command line.*', line)
89 call setline(1, 'hello') 96 call setline(1, 'hello')
90 97
91 let winid = popup_create('world', { 98 let winid = popup_create('world', {
92 \ 'line': 1, 99 \ 'line': 1,
93 \ 'col': 1, 100 \ 'col': 1,
101 \ 'minwidth': 20,
94 \}) 102 \})
95 redraw 103 redraw
96 let line = join(map(range(1, 5), 'screenstring(1, v:val)'), '') 104 let line = join(map(range(1, 5), 'screenstring(1, v:val)'), '')
97 call assert_equal('world', line) 105 call assert_equal('world', line)
98 106
119 call popup_hide(1234234) 127 call popup_hide(1234234)
120 call popup_show(41234234) 128 call popup_show(41234234)
121 129
122 bwipe! 130 bwipe!
123 endfunc 131 endfunc
132
133 func Test_popup_move()
134 topleft vnew
135 call setline(1, 'hello')
136
137 let winid = popup_create('world', {
138 \ 'line': 1,
139 \ 'col': 1,
140 \ 'minwidth': 20,
141 \})
142 redraw
143 let line = join(map(range(1, 6), 'screenstring(1, v:val)'), '')
144 call assert_equal('world ', line)
145
146 call popup_move(winid, {'line': 2, 'col': 2})
147 redraw
148 let line = join(map(range(1, 6), 'screenstring(1, v:val)'), '')
149 call assert_equal('hello ', line)
150 let line = join(map(range(1, 6), 'screenstring(2, v:val)'), '')
151 call assert_equal('~world', line)
152
153 call popup_move(winid, {'line': 1})
154 redraw
155 let line = join(map(range(1, 6), 'screenstring(1, v:val)'), '')
156 call assert_equal('hworld', line)
157
158 call popup_close(winid)
159
160 bwipe!
161 endfunc