Mercurial > vim
comparison 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 |
comparison
equal
deleted
inserted
replaced
17218:210c4c5f783d | 17219:5169811b3044 |
---|---|
362 | 362 |
363 " clean up | 363 " clean up |
364 call StopVimInTerminal(buf) | 364 call StopVimInTerminal(buf) |
365 call delete('XtestPopupDrag') | 365 call delete('XtestPopupDrag') |
366 endfunc | 366 endfunc |
367 | |
368 func Test_popup_close_with_mouse() | |
369 if !CanRunVimInTerminal() | |
370 throw 'Skipped: cannot make screendumps' | |
371 endif | |
372 let lines =<< trim END | |
373 call setline(1, range(1, 20)) | |
374 " With border, can click on X | |
375 let winid = popup_create('foobar', { | |
376 \ 'close': 'button', | |
377 \ 'border': [], | |
378 \ 'line': 1, | |
379 \ 'col': 1, | |
380 \ }) | |
381 func CloseMsg(id, result) | |
382 echomsg 'Popup closed with ' .. a:result | |
383 endfunc | |
384 let winid = popup_create('notification', { | |
385 \ 'close': 'click', | |
386 \ 'line': 3, | |
387 \ 'col': 15, | |
388 \ 'callback': 'CloseMsg', | |
389 \ }) | |
390 let winid = popup_create('no border here', { | |
391 \ 'close': 'button', | |
392 \ 'line': 5, | |
393 \ 'col': 3, | |
394 \ }) | |
395 let winid = popup_create('only padding', { | |
396 \ 'close': 'button', | |
397 \ 'padding': [], | |
398 \ 'line': 5, | |
399 \ 'col': 23, | |
400 \ }) | |
401 func CloseWithX() | |
402 call feedkeys("\<F3>\<LeftMouse>\<LeftRelease>", "xt") | |
403 endfunc | |
404 map <silent> <F3> :call test_setmouse(1, len('foobar') + 2)<CR> | |
405 func CloseWithClick() | |
406 call feedkeys("\<F4>\<LeftMouse>\<LeftRelease>", "xt") | |
407 endfunc | |
408 map <silent> <F4> :call test_setmouse(3, 17)<CR> | |
409 END | |
410 call writefile(lines, 'XtestPopupClose') | |
411 let buf = RunVimInTerminal('-S XtestPopupClose', {'rows': 10}) | |
412 call VerifyScreenDump(buf, 'Test_popupwin_close_01', {}) | |
413 | |
414 call term_sendkeys(buf, ":call CloseWithX()\<CR>") | |
415 call VerifyScreenDump(buf, 'Test_popupwin_close_02', {}) | |
416 | |
417 call term_sendkeys(buf, ":call CloseWithClick()\<CR>") | |
418 call VerifyScreenDump(buf, 'Test_popupwin_close_03', {}) | |
419 | |
420 " clean up | |
421 call StopVimInTerminal(buf) | |
422 call delete('XtestPopupClose') | |
423 endfunction | |
367 | 424 |
368 func Test_popup_with_mask() | 425 func Test_popup_with_mask() |
369 if !CanRunVimInTerminal() | 426 if !CanRunVimInTerminal() |
370 throw 'Skipped: cannot make screendumps' | 427 throw 'Skipped: cannot make screendumps' |
371 endif | 428 endif |