Mercurial > vim
diff src/testdir/test_popupwin.vim @ 17219:5169811b3044 v8.1.1609
patch 8.1.1609: the user cannot easily close a popup window
commit https://github.com/vim/vim/commit/2e62b568e91c36adb16dbcc609665170f09f3845
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jun 30 18:07:00 2019 +0200
patch 8.1.1609: the user cannot easily close a popup window
Problem: The user cannot easily close a popup window.
Solution: Add the "close" property. (mostly by Masato Nishihata,
closes #4601)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 30 Jun 2019 18:15:04 +0200 |
parents | 11f3cf51d43b |
children | 09fa437d33d8 |
line wrap: on
line diff
--- a/src/testdir/test_popupwin.vim +++ b/src/testdir/test_popupwin.vim @@ -365,6 +365,63 @@ func Test_popup_drag() call delete('XtestPopupDrag') endfunc +func Test_popup_close_with_mouse() + if !CanRunVimInTerminal() + throw 'Skipped: cannot make screendumps' + endif + let lines =<< trim END + call setline(1, range(1, 20)) + " With border, can click on X + let winid = popup_create('foobar', { + \ 'close': 'button', + \ 'border': [], + \ 'line': 1, + \ 'col': 1, + \ }) + func CloseMsg(id, result) + echomsg 'Popup closed with ' .. a:result + endfunc + let winid = popup_create('notification', { + \ 'close': 'click', + \ 'line': 3, + \ 'col': 15, + \ 'callback': 'CloseMsg', + \ }) + let winid = popup_create('no border here', { + \ 'close': 'button', + \ 'line': 5, + \ 'col': 3, + \ }) + let winid = popup_create('only padding', { + \ 'close': 'button', + \ 'padding': [], + \ 'line': 5, + \ 'col': 23, + \ }) + func CloseWithX() + call feedkeys("\<F3>\<LeftMouse>\<LeftRelease>", "xt") + endfunc + map <silent> <F3> :call test_setmouse(1, len('foobar') + 2)<CR> + func CloseWithClick() + call feedkeys("\<F4>\<LeftMouse>\<LeftRelease>", "xt") + endfunc + map <silent> <F4> :call test_setmouse(3, 17)<CR> + END + call writefile(lines, 'XtestPopupClose') + let buf = RunVimInTerminal('-S XtestPopupClose', {'rows': 10}) + call VerifyScreenDump(buf, 'Test_popupwin_close_01', {}) + + call term_sendkeys(buf, ":call CloseWithX()\<CR>") + call VerifyScreenDump(buf, 'Test_popupwin_close_02', {}) + + call term_sendkeys(buf, ":call CloseWithClick()\<CR>") + call VerifyScreenDump(buf, 'Test_popupwin_close_03', {}) + + " clean up + call StopVimInTerminal(buf) + call delete('XtestPopupClose') +endfunction + func Test_popup_with_mask() if !CanRunVimInTerminal() throw 'Skipped: cannot make screendumps'