annotate src/testdir/test_popupwin.vim @ 18544:a6dbbedddce1 v8.1.2266

patch 8.1.2266: position unknown for a mouse click in a popup window Commit: https://github.com/vim/vim/commit/f8b036bcae27014e4cbbdceec262b0a4c6dc2d9c Author: Bram Moolenaar <Bram@vim.org> Date: Wed Nov 6 21:09:17 2019 +0100 patch 8.1.2266: position unknown for a mouse click in a popup window Problem: Position unknown for a mouse click in a popup window. Solution: Set v:mouse_col and v:mouse_lnum. (closes https://github.com/vim/vim/issues/5171)
author Bram Moolenaar <Bram@vim.org>
date Wed, 06 Nov 2019 21:15:03 +0100
parents 244b336b94ce
children e5ef5d820b5b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16778
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1 " Tests for popup windows
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2
17089
8e9e9124c7a2 patch 8.1.1544: some balloon tests don't run when they can
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
3 source check.vim
8e9e9124c7a2 patch 8.1.1544: some balloon tests don't run when they can
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
4 CheckFeature textprop
16778
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
6 source screendump.vim
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
7
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
8 func Test_simple_popup()
17680
55704f587945 patch 8.1.1837: popup test fails if clipboard is supported but not working
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
9 CheckScreendump
55704f587945 patch 8.1.1837: popup test fails if clipboard is supported but not working
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
10
17172
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
11 let lines =<< trim END
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
12 call setline(1, range(1, 100))
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
13 hi PopupColor1 ctermbg=lightblue
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
14 hi PopupColor2 ctermbg=lightcyan
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
15 hi Comment ctermfg=red
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
16 call prop_type_add('comment', #{highlight: 'Comment'})
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
17 let winid = popup_create('hello there', #{line: 3, col: 11, minwidth: 20, highlight: 'PopupColor1'})
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
18 let winid2 = popup_create(['another one', 'another two', 'another three'], #{line: 3, col: 25, minwidth: 20})
17172
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
19 call setwinvar(winid2, '&wincolor', 'PopupColor2')
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
20 END
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
21 call writefile(lines, 'XtestPopup')
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
22 let buf = RunVimInTerminal('-S XtestPopup', #{rows: 10})
16778
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
23 call VerifyScreenDump(buf, 'Test_popupwin_01', {})
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
24
16794
ddfa924df50d patch 8.1.1399: popup windows not adjusted when switching tabs
Bram Moolenaar <Bram@vim.org>
parents: 16778
diff changeset
25 " Add a tabpage
ddfa924df50d patch 8.1.1399: popup windows not adjusted when switching tabs
Bram Moolenaar <Bram@vim.org>
parents: 16778
diff changeset
26 call term_sendkeys(buf, ":tabnew\<CR>")
16817
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16811
diff changeset
27 call term_sendkeys(buf, ":let popupwin = popup_create(["
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
28 \ .. "#{text: 'other tab'},"
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
29 \ .. "#{text: 'a comment line', props: [#{"
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
30 \ .. "col: 3, length: 7, minwidth: 20, type: 'comment'"
16811
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
31 \ .. "}]},"
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
32 \ .. "], #{line: 4, col: 9, minwidth: 20})\<CR>")
16794
ddfa924df50d patch 8.1.1399: popup windows not adjusted when switching tabs
Bram Moolenaar <Bram@vim.org>
parents: 16778
diff changeset
33 call VerifyScreenDump(buf, 'Test_popupwin_02', {})
ddfa924df50d patch 8.1.1399: popup windows not adjusted when switching tabs
Bram Moolenaar <Bram@vim.org>
parents: 16778
diff changeset
34
ddfa924df50d patch 8.1.1399: popup windows not adjusted when switching tabs
Bram Moolenaar <Bram@vim.org>
parents: 16778
diff changeset
35 " switch back to first tabpage
ddfa924df50d patch 8.1.1399: popup windows not adjusted when switching tabs
Bram Moolenaar <Bram@vim.org>
parents: 16778
diff changeset
36 call term_sendkeys(buf, "gt")
ddfa924df50d patch 8.1.1399: popup windows not adjusted when switching tabs
Bram Moolenaar <Bram@vim.org>
parents: 16778
diff changeset
37 call VerifyScreenDump(buf, 'Test_popupwin_03', {})
ddfa924df50d patch 8.1.1399: popup windows not adjusted when switching tabs
Bram Moolenaar <Bram@vim.org>
parents: 16778
diff changeset
38
ddfa924df50d patch 8.1.1399: popup windows not adjusted when switching tabs
Bram Moolenaar <Bram@vim.org>
parents: 16778
diff changeset
39 " close that tabpage
ddfa924df50d patch 8.1.1399: popup windows not adjusted when switching tabs
Bram Moolenaar <Bram@vim.org>
parents: 16778
diff changeset
40 call term_sendkeys(buf, ":quit!\<CR>")
ddfa924df50d patch 8.1.1399: popup windows not adjusted when switching tabs
Bram Moolenaar <Bram@vim.org>
parents: 16778
diff changeset
41 call VerifyScreenDump(buf, 'Test_popupwin_04', {})
ddfa924df50d patch 8.1.1399: popup windows not adjusted when switching tabs
Bram Moolenaar <Bram@vim.org>
parents: 16778
diff changeset
42
17037
9297877074a3 patch 8.1.1518: crash when setting 'columns' while a popup is visible
Bram Moolenaar <Bram@vim.org>
parents: 17026
diff changeset
43 " set 'columns' to a small value, size must be recomputed
9297877074a3 patch 8.1.1518: crash when setting 'columns' while a popup is visible
Bram Moolenaar <Bram@vim.org>
parents: 17026
diff changeset
44 call term_sendkeys(buf, ":let cols = &columns\<CR>")
9297877074a3 patch 8.1.1518: crash when setting 'columns' while a popup is visible
Bram Moolenaar <Bram@vim.org>
parents: 17026
diff changeset
45 call term_sendkeys(buf, ":set columns=12\<CR>")
9297877074a3 patch 8.1.1518: crash when setting 'columns' while a popup is visible
Bram Moolenaar <Bram@vim.org>
parents: 17026
diff changeset
46 call VerifyScreenDump(buf, 'Test_popupwin_04a', {})
9297877074a3 patch 8.1.1518: crash when setting 'columns' while a popup is visible
Bram Moolenaar <Bram@vim.org>
parents: 17026
diff changeset
47 call term_sendkeys(buf, ":let &columns = cols\<CR>")
9297877074a3 patch 8.1.1518: crash when setting 'columns' while a popup is visible
Bram Moolenaar <Bram@vim.org>
parents: 17026
diff changeset
48
16839
032d5335987e patch 8.1.1421: drawing "~" line in popup window
Bram Moolenaar <Bram@vim.org>
parents: 16837
diff changeset
49 " resize popup, show empty line at bottom
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
50 call term_sendkeys(buf, ":call popup_move(popupwin, #{minwidth: 15, maxwidth: 25, minheight: 3, maxheight: 5})\<CR>")
16817
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16811
diff changeset
51 call term_sendkeys(buf, ":redraw\<CR>")
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16811
diff changeset
52 call VerifyScreenDump(buf, 'Test_popupwin_05', {})
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16811
diff changeset
53
16839
032d5335987e patch 8.1.1421: drawing "~" line in popup window
Bram Moolenaar <Bram@vim.org>
parents: 16837
diff changeset
54 " show not fitting line at bottom
032d5335987e patch 8.1.1421: drawing "~" line in popup window
Bram Moolenaar <Bram@vim.org>
parents: 16837
diff changeset
55 call term_sendkeys(buf, ":call setbufline(winbufnr(popupwin), 3, 'this line will not fit here')\<CR>")
032d5335987e patch 8.1.1421: drawing "~" line in popup window
Bram Moolenaar <Bram@vim.org>
parents: 16837
diff changeset
56 call term_sendkeys(buf, ":redraw\<CR>")
032d5335987e patch 8.1.1421: drawing "~" line in popup window
Bram Moolenaar <Bram@vim.org>
parents: 16837
diff changeset
57 call VerifyScreenDump(buf, 'Test_popupwin_06', {})
032d5335987e patch 8.1.1421: drawing "~" line in popup window
Bram Moolenaar <Bram@vim.org>
parents: 16837
diff changeset
58
16998
2ec0f953ec3f patch 8.1.1499: ruler not updated after popup window was removed
Bram Moolenaar <Bram@vim.org>
parents: 16965
diff changeset
59 " move popup over ruler
2ec0f953ec3f patch 8.1.1499: ruler not updated after popup window was removed
Bram Moolenaar <Bram@vim.org>
parents: 16965
diff changeset
60 call term_sendkeys(buf, ":set cmdheight=2\<CR>")
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
61 call term_sendkeys(buf, ":call popup_move(popupwin, #{line: 7, col: 55})\<CR>")
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
62 call term_sendkeys(buf, ":\<CR>")
16998
2ec0f953ec3f patch 8.1.1499: ruler not updated after popup window was removed
Bram Moolenaar <Bram@vim.org>
parents: 16965
diff changeset
63 call VerifyScreenDump(buf, 'Test_popupwin_07', {})
2ec0f953ec3f patch 8.1.1499: ruler not updated after popup window was removed
Bram Moolenaar <Bram@vim.org>
parents: 16965
diff changeset
64
2ec0f953ec3f patch 8.1.1499: ruler not updated after popup window was removed
Bram Moolenaar <Bram@vim.org>
parents: 16965
diff changeset
65 " clear all popups after moving the cursor a bit, so that ruler is updated
2ec0f953ec3f patch 8.1.1499: ruler not updated after popup window was removed
Bram Moolenaar <Bram@vim.org>
parents: 16965
diff changeset
66 call term_sendkeys(buf, "axxx\<Esc>")
2ec0f953ec3f patch 8.1.1499: ruler not updated after popup window was removed
Bram Moolenaar <Bram@vim.org>
parents: 16965
diff changeset
67 call term_wait(buf)
2ec0f953ec3f patch 8.1.1499: ruler not updated after popup window was removed
Bram Moolenaar <Bram@vim.org>
parents: 16965
diff changeset
68 call term_sendkeys(buf, "0")
2ec0f953ec3f patch 8.1.1499: ruler not updated after popup window was removed
Bram Moolenaar <Bram@vim.org>
parents: 16965
diff changeset
69 call term_wait(buf)
17026
905e1b154058 patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents: 17022
diff changeset
70 call term_sendkeys(buf, ":call popup_clear()\<CR>")
16998
2ec0f953ec3f patch 8.1.1499: ruler not updated after popup window was removed
Bram Moolenaar <Bram@vim.org>
parents: 16965
diff changeset
71 call VerifyScreenDump(buf, 'Test_popupwin_08', {})
2ec0f953ec3f patch 8.1.1499: ruler not updated after popup window was removed
Bram Moolenaar <Bram@vim.org>
parents: 16965
diff changeset
72
16778
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
73 " clean up
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
74 call StopVimInTerminal(buf)
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
75 call delete('XtestPopup')
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
76 endfunc
16800
12e3a3afdb6a patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents: 16794
diff changeset
77
16884
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
78 func Test_popup_with_border_and_padding()
17680
55704f587945 patch 8.1.1837: popup test fails if clipboard is supported but not working
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
79 CheckScreendump
16884
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
80
16886
2bd51fdcc793 patch 8.1.1444: not using double line characters for popup border
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
81 for iter in range(0, 1)
17172
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
82 let lines =<< trim END
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
83 call setline(1, range(1, 100))
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
84 call popup_create('hello border', #{line: 2, col: 3, border: []})
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
85 call popup_create('hello padding', #{line: 2, col: 23, padding: []})
17628
6146b10714de patch 8.1.1811: popup window color cannot be set to "Normal"
Bram Moolenaar <Bram@vim.org>
parents: 17626
diff changeset
86 call popup_create('hello both', #{line: 2, col: 43, border: [], padding: [], highlight: 'Normal'})
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
87 call popup_create('border TL', #{line: 6, col: 3, border: [1, 0, 0, 4]})
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
88 call popup_create('paddings', #{line: 6, col: 23, padding: [1, 3, 2, 4]})
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
89 call popup_create('wrapped longer text', #{line: 8, col: 55, padding: [0, 3, 0, 3], border: [0, 1, 0, 1]})
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
90 call popup_create('right aligned text', #{line: 11, col: 56, wrap: 0, padding: [0, 3, 0, 3], border: [0, 1, 0, 1]})
17172
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
91 END
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
92 call insert(lines, iter == 1 ? '' : 'set enc=latin1')
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
93 call writefile(lines, 'XtestPopupBorder')
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
94 let buf = RunVimInTerminal('-S XtestPopupBorder', #{rows: 15})
16886
2bd51fdcc793 patch 8.1.1444: not using double line characters for popup border
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
95 call VerifyScreenDump(buf, 'Test_popupwin_2' .. iter, {})
2bd51fdcc793 patch 8.1.1444: not using double line characters for popup border
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
96
2bd51fdcc793 patch 8.1.1444: not using double line characters for popup border
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
97 call StopVimInTerminal(buf)
2bd51fdcc793 patch 8.1.1444: not using double line characters for popup border
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
98 call delete('XtestPopupBorder')
2bd51fdcc793 patch 8.1.1444: not using double line characters for popup border
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
99 endfor
16884
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
100
17172
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
101 let lines =<< trim END
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
102 call setline(1, range(1, 100))
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
103 hi BlueColor ctermbg=lightblue
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
104 hi TopColor ctermbg=253
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
105 hi RightColor ctermbg=245
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
106 hi BottomColor ctermbg=240
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
107 hi LeftColor ctermbg=248
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
108 call popup_create('hello border', #{line: 2, col: 3, border: [], borderhighlight: ['BlueColor']})
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
109 call popup_create(['hello border', 'and more'], #{line: 2, col: 23, border: [], borderhighlight: ['TopColor', 'RightColor', 'BottomColor', 'LeftColor']})
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
110 call popup_create(['hello border', 'lines only'], #{line: 2, col: 43, border: [], borderhighlight: ['BlueColor'], borderchars: ['x']})
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
111 call popup_create(['hello border', 'with corners'], #{line: 2, col: 60, border: [], borderhighlight: ['BlueColor'], borderchars: ['x', '#']})
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
112 let winid = popup_create(['hello border', 'with numbers'], #{line: 6, col: 3, border: [], borderhighlight: ['BlueColor'], borderchars: ['0', '1', '2', '3', '4', '5', '6', '7']})
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
113 call popup_create(['hello border', 'just blanks'], #{line: 7, col: 23, border: [], borderhighlight: ['BlueColor'], borderchars: [' ']})
17312
484424955bfa patch 8.1.1655: popup window border drawn wrong with multi-byte char
Bram Moolenaar <Bram@vim.org>
parents: 17292
diff changeset
114 func MultiByte()
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
115 call popup_create(['hello'], #{line: 8, col: 43, border: [], borderchars: ['─', '│', '─', '│', '┌', '┐', '┘', '└']})
17312
484424955bfa patch 8.1.1655: popup window border drawn wrong with multi-byte char
Bram Moolenaar <Bram@vim.org>
parents: 17292
diff changeset
116 endfunc
17172
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
117 END
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
118 call writefile(lines, 'XtestPopupBorder')
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
119 let buf = RunVimInTerminal('-S XtestPopupBorder', #{rows: 12})
16888
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16886
diff changeset
120 call VerifyScreenDump(buf, 'Test_popupwin_22', {})
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16886
diff changeset
121
17125
b4eb06233448 patch 8.1.1562: popup window not always redrawn after popup_setoptions()
Bram Moolenaar <Bram@vim.org>
parents: 17123
diff changeset
122 " check that changing borderchars triggers a redraw
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
123 call term_sendkeys(buf, ":call popup_setoptions(winid, #{borderchars: ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']})\<CR>")
17125
b4eb06233448 patch 8.1.1562: popup window not always redrawn after popup_setoptions()
Bram Moolenaar <Bram@vim.org>
parents: 17123
diff changeset
124 call VerifyScreenDump(buf, 'Test_popupwin_23', {})
b4eb06233448 patch 8.1.1562: popup window not always redrawn after popup_setoptions()
Bram Moolenaar <Bram@vim.org>
parents: 17123
diff changeset
125
17312
484424955bfa patch 8.1.1655: popup window border drawn wrong with multi-byte char
Bram Moolenaar <Bram@vim.org>
parents: 17292
diff changeset
126 " check multi-byte border only with 'ambiwidth' single
484424955bfa patch 8.1.1655: popup window border drawn wrong with multi-byte char
Bram Moolenaar <Bram@vim.org>
parents: 17292
diff changeset
127 if &ambiwidth == 'single'
484424955bfa patch 8.1.1655: popup window border drawn wrong with multi-byte char
Bram Moolenaar <Bram@vim.org>
parents: 17292
diff changeset
128 call term_sendkeys(buf, ":call MultiByte()\<CR>")
484424955bfa patch 8.1.1655: popup window border drawn wrong with multi-byte char
Bram Moolenaar <Bram@vim.org>
parents: 17292
diff changeset
129 call VerifyScreenDump(buf, 'Test_popupwin_24', {})
484424955bfa patch 8.1.1655: popup window border drawn wrong with multi-byte char
Bram Moolenaar <Bram@vim.org>
parents: 17292
diff changeset
130 endif
484424955bfa patch 8.1.1655: popup window border drawn wrong with multi-byte char
Bram Moolenaar <Bram@vim.org>
parents: 17292
diff changeset
131
16888
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16886
diff changeset
132 call StopVimInTerminal(buf)
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16886
diff changeset
133 call delete('XtestPopupBorder')
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16886
diff changeset
134
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
135 let with_border_or_padding = #{
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
136 \ line: 2,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
137 \ core_line: 3,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
138 \ col: 3,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
139 \ core_col: 4,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
140 \ width: 14,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
141 \ core_width: 12,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
142 \ height: 3,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
143 \ core_height: 1,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
144 \ firstline: 1,
18512
e855058e0c23 patch 8.1.2250: CTRL-U and CTRL-D don't work in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18494
diff changeset
145 \ lastline: 1,
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
146 \ scrollbar: 0,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
147 \ visible: 1}
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
148 let winid = popup_create('hello border', #{line: 2, col: 3, border: []})",
17972
a170c48e0f91 patch 8.1.1982: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17946
diff changeset
149 call assert_equal(with_border_or_padding, winid->popup_getpos())
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
150 let options = popup_getoptions(winid)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
151 call assert_equal([], options.border)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
152 call assert_false(has_key(options, "padding"))
16884
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
153
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
154 let winid = popup_create('hello padding', #{line: 2, col: 3, padding: []})
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
155 let with_border_or_padding.width = 15
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
156 let with_border_or_padding.core_width = 13
16884
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
157 call assert_equal(with_border_or_padding, popup_getpos(winid))
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
158 let options = popup_getoptions(winid)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
159 call assert_false(has_key(options, "border"))
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
160 call assert_equal([], options.padding)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
161
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
162 call popup_setoptions(winid, #{
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
163 \ padding: [1, 2, 3, 4],
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
164 \ border: [4, 0, 7, 8],
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
165 \ borderhighlight: ['Top', 'Right', 'Bottom', 'Left'],
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
166 \ borderchars: ['1', '^', '2', '>', '3', 'v', '4', '<'],
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
167 \ })
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
168 let options = popup_getoptions(winid)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
169 call assert_equal([1, 0, 1, 1], options.border)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
170 call assert_equal([1, 2, 3, 4], options.padding)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
171 call assert_equal(['Top', 'Right', 'Bottom', 'Left'], options.borderhighlight)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
172 call assert_equal(['1', '^', '2', '>', '3', 'v', '4', '<'], options.borderchars)
16884
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
173
18398
21c25bee9df8 patch 8.1.2193: popup_setoptions(popup_getoptions()) does not work
Bram Moolenaar <Bram@vim.org>
parents: 18396
diff changeset
174 " Check that popup_setoptions() takes the output of popup_getoptions()
21c25bee9df8 patch 8.1.2193: popup_setoptions(popup_getoptions()) does not work
Bram Moolenaar <Bram@vim.org>
parents: 18396
diff changeset
175 call popup_setoptions(winid, options)
21c25bee9df8 patch 8.1.2193: popup_setoptions(popup_getoptions()) does not work
Bram Moolenaar <Bram@vim.org>
parents: 18396
diff changeset
176 call assert_equal(options, popup_getoptions(winid))
21c25bee9df8 patch 8.1.2193: popup_setoptions(popup_getoptions()) does not work
Bram Moolenaar <Bram@vim.org>
parents: 18396
diff changeset
177
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
178 let winid = popup_create('hello both', #{line: 3, col: 8, border: [], padding: []})
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
179 call assert_equal(#{
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
180 \ line: 3,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
181 \ core_line: 5,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
182 \ col: 8,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
183 \ core_col: 10,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
184 \ width: 14,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
185 \ core_width: 10,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
186 \ height: 5,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
187 \ scrollbar: 0,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
188 \ core_height: 1,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
189 \ firstline: 1,
18512
e855058e0c23 patch 8.1.2250: CTRL-U and CTRL-D don't work in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18494
diff changeset
190 \ lastline: 1,
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
191 \ visible: 1}, popup_getpos(winid))
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
192
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
193 call popup_clear()
16884
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
194 endfunc
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
195
16849
629f3d3b6886 patch 8.1.1426: no test for syntax highlight in popup window
Bram Moolenaar <Bram@vim.org>
parents: 16843
diff changeset
196 func Test_popup_with_syntax_win_execute()
17680
55704f587945 patch 8.1.1837: popup test fails if clipboard is supported but not working
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
197 CheckScreendump
55704f587945 patch 8.1.1837: popup test fails if clipboard is supported but not working
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
198
17172
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
199 let lines =<< trim END
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
200 call setline(1, range(1, 100))
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
201 hi PopupColor ctermbg=lightblue
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
202 let winid = popup_create([
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
203 \ '#include <stdio.h>',
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
204 \ 'int main(void)',
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
205 \ '{',
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
206 \ ' printf(123);',
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
207 \ '}',
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
208 \], #{line: 3, col: 25, highlight: 'PopupColor'})
17172
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
209 call win_execute(winid, 'set syntax=cpp')
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
210 END
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
211 call writefile(lines, 'XtestPopup')
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
212 let buf = RunVimInTerminal('-S XtestPopup', #{rows: 10})
16849
629f3d3b6886 patch 8.1.1426: no test for syntax highlight in popup window
Bram Moolenaar <Bram@vim.org>
parents: 16843
diff changeset
213 call VerifyScreenDump(buf, 'Test_popupwin_10', {})
629f3d3b6886 patch 8.1.1426: no test for syntax highlight in popup window
Bram Moolenaar <Bram@vim.org>
parents: 16843
diff changeset
214
629f3d3b6886 patch 8.1.1426: no test for syntax highlight in popup window
Bram Moolenaar <Bram@vim.org>
parents: 16843
diff changeset
215 " clean up
629f3d3b6886 patch 8.1.1426: no test for syntax highlight in popup window
Bram Moolenaar <Bram@vim.org>
parents: 16843
diff changeset
216 call StopVimInTerminal(buf)
629f3d3b6886 patch 8.1.1426: no test for syntax highlight in popup window
Bram Moolenaar <Bram@vim.org>
parents: 16843
diff changeset
217 call delete('XtestPopup')
629f3d3b6886 patch 8.1.1426: no test for syntax highlight in popup window
Bram Moolenaar <Bram@vim.org>
parents: 16843
diff changeset
218 endfunc
629f3d3b6886 patch 8.1.1426: no test for syntax highlight in popup window
Bram Moolenaar <Bram@vim.org>
parents: 16843
diff changeset
219
629f3d3b6886 patch 8.1.1426: no test for syntax highlight in popup window
Bram Moolenaar <Bram@vim.org>
parents: 16843
diff changeset
220 func Test_popup_with_syntax_setbufvar()
17680
55704f587945 patch 8.1.1837: popup test fails if clipboard is supported but not working
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
221 CheckScreendump
55704f587945 patch 8.1.1837: popup test fails if clipboard is supported but not working
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
222
16857
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
223 let lines =<< trim END
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
224 call setline(1, range(1, 100))
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
225 hi PopupColor ctermbg=lightgrey
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
226 let winid = popup_create([
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
227 \ '#include <stdio.h>',
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
228 \ 'int main(void)',
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
229 \ '{',
17314
b60402471f69 patch 8.1.1656: popup window width is wrong when using Tabs
Bram Moolenaar <Bram@vim.org>
parents: 17312
diff changeset
230 \ "\tprintf(567);",
16857
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
231 \ '}',
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
232 \], #{line: 3, col: 21, highlight: 'PopupColor'})
16857
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
233 call setbufvar(winbufnr(winid), '&syntax', 'cpp')
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
234 END
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
235 call writefile(lines, 'XtestPopup')
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
236 let buf = RunVimInTerminal('-S XtestPopup', #{rows: 10})
16849
629f3d3b6886 patch 8.1.1426: no test for syntax highlight in popup window
Bram Moolenaar <Bram@vim.org>
parents: 16843
diff changeset
237 call VerifyScreenDump(buf, 'Test_popupwin_11', {})
629f3d3b6886 patch 8.1.1426: no test for syntax highlight in popup window
Bram Moolenaar <Bram@vim.org>
parents: 16843
diff changeset
238
629f3d3b6886 patch 8.1.1426: no test for syntax highlight in popup window
Bram Moolenaar <Bram@vim.org>
parents: 16843
diff changeset
239 " clean up
629f3d3b6886 patch 8.1.1426: no test for syntax highlight in popup window
Bram Moolenaar <Bram@vim.org>
parents: 16843
diff changeset
240 call StopVimInTerminal(buf)
629f3d3b6886 patch 8.1.1426: no test for syntax highlight in popup window
Bram Moolenaar <Bram@vim.org>
parents: 16843
diff changeset
241 call delete('XtestPopup')
629f3d3b6886 patch 8.1.1426: no test for syntax highlight in popup window
Bram Moolenaar <Bram@vim.org>
parents: 16843
diff changeset
242 endfunc
629f3d3b6886 patch 8.1.1426: no test for syntax highlight in popup window
Bram Moolenaar <Bram@vim.org>
parents: 16843
diff changeset
243
17022
79c3a52fdb07 patch 8.1.1511: matches in a popup window are not displayed properly
Bram Moolenaar <Bram@vim.org>
parents: 16998
diff changeset
244 func Test_popup_with_matches()
17680
55704f587945 patch 8.1.1837: popup test fails if clipboard is supported but not working
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
245 CheckScreendump
55704f587945 patch 8.1.1837: popup test fails if clipboard is supported but not working
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
246
17022
79c3a52fdb07 patch 8.1.1511: matches in a popup window are not displayed properly
Bram Moolenaar <Bram@vim.org>
parents: 16998
diff changeset
247 let lines =<< trim END
79c3a52fdb07 patch 8.1.1511: matches in a popup window are not displayed properly
Bram Moolenaar <Bram@vim.org>
parents: 16998
diff changeset
248 call setline(1, ['111 222 333', '444 555 666'])
79c3a52fdb07 patch 8.1.1511: matches in a popup window are not displayed properly
Bram Moolenaar <Bram@vim.org>
parents: 16998
diff changeset
249 let winid = popup_create([
79c3a52fdb07 patch 8.1.1511: matches in a popup window are not displayed properly
Bram Moolenaar <Bram@vim.org>
parents: 16998
diff changeset
250 \ '111 222 333',
79c3a52fdb07 patch 8.1.1511: matches in a popup window are not displayed properly
Bram Moolenaar <Bram@vim.org>
parents: 16998
diff changeset
251 \ '444 555 666',
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
252 \], #{line: 3, col: 10, border: []})
17022
79c3a52fdb07 patch 8.1.1511: matches in a popup window are not displayed properly
Bram Moolenaar <Bram@vim.org>
parents: 16998
diff changeset
253 set hlsearch
18494
04a40c1514c4 patch 8.1.2241: match highlight does not combine with 'wincolor'
Bram Moolenaar <Bram@vim.org>
parents: 18492
diff changeset
254 hi VeryBlue ctermfg=blue guifg=blue
17022
79c3a52fdb07 patch 8.1.1511: matches in a popup window are not displayed properly
Bram Moolenaar <Bram@vim.org>
parents: 16998
diff changeset
255 /666
79c3a52fdb07 patch 8.1.1511: matches in a popup window are not displayed properly
Bram Moolenaar <Bram@vim.org>
parents: 16998
diff changeset
256 call matchadd('ErrorMsg', '111')
18494
04a40c1514c4 patch 8.1.2241: match highlight does not combine with 'wincolor'
Bram Moolenaar <Bram@vim.org>
parents: 18492
diff changeset
257 call matchadd('VeryBlue', '444')
17022
79c3a52fdb07 patch 8.1.1511: matches in a popup window are not displayed properly
Bram Moolenaar <Bram@vim.org>
parents: 16998
diff changeset
258 call win_execute(winid, "call matchadd('ErrorMsg', '111')")
18494
04a40c1514c4 patch 8.1.2241: match highlight does not combine with 'wincolor'
Bram Moolenaar <Bram@vim.org>
parents: 18492
diff changeset
259 call win_execute(winid, "call matchadd('VeryBlue', '555')")
17022
79c3a52fdb07 patch 8.1.1511: matches in a popup window are not displayed properly
Bram Moolenaar <Bram@vim.org>
parents: 16998
diff changeset
260 END
79c3a52fdb07 patch 8.1.1511: matches in a popup window are not displayed properly
Bram Moolenaar <Bram@vim.org>
parents: 16998
diff changeset
261 call writefile(lines, 'XtestPopupMatches')
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
262 let buf = RunVimInTerminal('-S XtestPopupMatches', #{rows: 10})
17022
79c3a52fdb07 patch 8.1.1511: matches in a popup window are not displayed properly
Bram Moolenaar <Bram@vim.org>
parents: 16998
diff changeset
263 call VerifyScreenDump(buf, 'Test_popupwin_matches', {})
79c3a52fdb07 patch 8.1.1511: matches in a popup window are not displayed properly
Bram Moolenaar <Bram@vim.org>
parents: 16998
diff changeset
264
79c3a52fdb07 patch 8.1.1511: matches in a popup window are not displayed properly
Bram Moolenaar <Bram@vim.org>
parents: 16998
diff changeset
265 " clean up
79c3a52fdb07 patch 8.1.1511: matches in a popup window are not displayed properly
Bram Moolenaar <Bram@vim.org>
parents: 16998
diff changeset
266 call StopVimInTerminal(buf)
79c3a52fdb07 patch 8.1.1511: matches in a popup window are not displayed properly
Bram Moolenaar <Bram@vim.org>
parents: 16998
diff changeset
267 call delete('XtestPopupMatches')
79c3a52fdb07 patch 8.1.1511: matches in a popup window are not displayed properly
Bram Moolenaar <Bram@vim.org>
parents: 16998
diff changeset
268 endfunc
79c3a52fdb07 patch 8.1.1511: matches in a popup window are not displayed properly
Bram Moolenaar <Bram@vim.org>
parents: 16998
diff changeset
269
16898
16fd1bb2e675 patch 8.1.1450: popup window positioning wrong when using padding or borders
Bram Moolenaar <Bram@vim.org>
parents: 16896
diff changeset
270 func Test_popup_all_corners()
17680
55704f587945 patch 8.1.1837: popup test fails if clipboard is supported but not working
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
271 CheckScreendump
55704f587945 patch 8.1.1837: popup test fails if clipboard is supported but not working
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
272
16898
16fd1bb2e675 patch 8.1.1450: popup window positioning wrong when using padding or borders
Bram Moolenaar <Bram@vim.org>
parents: 16896
diff changeset
273 let lines =<< trim END
16fd1bb2e675 patch 8.1.1450: popup window positioning wrong when using padding or borders
Bram Moolenaar <Bram@vim.org>
parents: 16896
diff changeset
274 call setline(1, repeat([repeat('-', 60)], 15))
16fd1bb2e675 patch 8.1.1450: popup window positioning wrong when using padding or borders
Bram Moolenaar <Bram@vim.org>
parents: 16896
diff changeset
275 set so=0
16fd1bb2e675 patch 8.1.1450: popup window positioning wrong when using padding or borders
Bram Moolenaar <Bram@vim.org>
parents: 16896
diff changeset
276 normal 2G3|r#
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
277 let winid1 = popup_create(['first', 'second'], #{
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
278 \ line: 'cursor+1',
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
279 \ col: 'cursor',
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
280 \ pos: 'topleft',
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
281 \ border: [],
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
282 \ padding: [],
16898
16fd1bb2e675 patch 8.1.1450: popup window positioning wrong when using padding or borders
Bram Moolenaar <Bram@vim.org>
parents: 16896
diff changeset
283 \ })
18432
ee8db42dacf6 patch 8.1.2210: using negative offset for popup_create() does not work
Bram Moolenaar <Bram@vim.org>
parents: 18398
diff changeset
284 normal 24|r@
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
285 let winid1 = popup_create(['First', 'SeconD'], #{
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
286 \ line: 'cursor+1',
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
287 \ col: 'cursor',
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
288 \ pos: 'topright',
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
289 \ border: [],
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
290 \ padding: [],
16898
16fd1bb2e675 patch 8.1.1450: popup window positioning wrong when using padding or borders
Bram Moolenaar <Bram@vim.org>
parents: 16896
diff changeset
291 \ })
18432
ee8db42dacf6 patch 8.1.2210: using negative offset for popup_create() does not work
Bram Moolenaar <Bram@vim.org>
parents: 18398
diff changeset
292 normal 9G27|r%
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
293 let winid1 = popup_create(['fiRSt', 'seCOnd'], #{
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
294 \ line: 'cursor-1',
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
295 \ col: 'cursor',
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
296 \ pos: 'botleft',
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
297 \ border: [],
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
298 \ padding: [],
16898
16fd1bb2e675 patch 8.1.1450: popup window positioning wrong when using padding or borders
Bram Moolenaar <Bram@vim.org>
parents: 16896
diff changeset
299 \ })
18432
ee8db42dacf6 patch 8.1.2210: using negative offset for popup_create() does not work
Bram Moolenaar <Bram@vim.org>
parents: 18398
diff changeset
300 normal 48|r&
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
301 let winid1 = popup_create(['FIrsT', 'SEcoND'], #{
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
302 \ line: 'cursor-1',
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
303 \ col: 'cursor',
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
304 \ pos: 'botright',
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
305 \ border: [],
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
306 \ padding: [],
16898
16fd1bb2e675 patch 8.1.1450: popup window positioning wrong when using padding or borders
Bram Moolenaar <Bram@vim.org>
parents: 16896
diff changeset
307 \ })
18432
ee8db42dacf6 patch 8.1.2210: using negative offset for popup_create() does not work
Bram Moolenaar <Bram@vim.org>
parents: 18398
diff changeset
308 normal 1G51|r*
ee8db42dacf6 patch 8.1.2210: using negative offset for popup_create() does not work
Bram Moolenaar <Bram@vim.org>
parents: 18398
diff changeset
309 let winid1 = popup_create(['one', 'two'], #{
ee8db42dacf6 patch 8.1.2210: using negative offset for popup_create() does not work
Bram Moolenaar <Bram@vim.org>
parents: 18398
diff changeset
310 \ line: 'cursor-1',
ee8db42dacf6 patch 8.1.2210: using negative offset for popup_create() does not work
Bram Moolenaar <Bram@vim.org>
parents: 18398
diff changeset
311 \ col: 'cursor',
ee8db42dacf6 patch 8.1.2210: using negative offset for popup_create() does not work
Bram Moolenaar <Bram@vim.org>
parents: 18398
diff changeset
312 \ pos: 'botleft',
ee8db42dacf6 patch 8.1.2210: using negative offset for popup_create() does not work
Bram Moolenaar <Bram@vim.org>
parents: 18398
diff changeset
313 \ border: [],
ee8db42dacf6 patch 8.1.2210: using negative offset for popup_create() does not work
Bram Moolenaar <Bram@vim.org>
parents: 18398
diff changeset
314 \ padding: [],
ee8db42dacf6 patch 8.1.2210: using negative offset for popup_create() does not work
Bram Moolenaar <Bram@vim.org>
parents: 18398
diff changeset
315 \ })
16898
16fd1bb2e675 patch 8.1.1450: popup window positioning wrong when using padding or borders
Bram Moolenaar <Bram@vim.org>
parents: 16896
diff changeset
316 END
16fd1bb2e675 patch 8.1.1450: popup window positioning wrong when using padding or borders
Bram Moolenaar <Bram@vim.org>
parents: 16896
diff changeset
317 call writefile(lines, 'XtestPopupCorners')
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
318 let buf = RunVimInTerminal('-S XtestPopupCorners', #{rows: 12})
16898
16fd1bb2e675 patch 8.1.1450: popup window positioning wrong when using padding or borders
Bram Moolenaar <Bram@vim.org>
parents: 16896
diff changeset
319 call VerifyScreenDump(buf, 'Test_popupwin_corners', {})
16fd1bb2e675 patch 8.1.1450: popup window positioning wrong when using padding or borders
Bram Moolenaar <Bram@vim.org>
parents: 16896
diff changeset
320
16fd1bb2e675 patch 8.1.1450: popup window positioning wrong when using padding or borders
Bram Moolenaar <Bram@vim.org>
parents: 16896
diff changeset
321 " clean up
16fd1bb2e675 patch 8.1.1450: popup window positioning wrong when using padding or borders
Bram Moolenaar <Bram@vim.org>
parents: 16896
diff changeset
322 call StopVimInTerminal(buf)
16fd1bb2e675 patch 8.1.1450: popup window positioning wrong when using padding or borders
Bram Moolenaar <Bram@vim.org>
parents: 16896
diff changeset
323 call delete('XtestPopupCorners')
16fd1bb2e675 patch 8.1.1450: popup window positioning wrong when using padding or borders
Bram Moolenaar <Bram@vim.org>
parents: 16896
diff changeset
324 endfunc
16fd1bb2e675 patch 8.1.1450: popup window positioning wrong when using padding or borders
Bram Moolenaar <Bram@vim.org>
parents: 16896
diff changeset
325
18542
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
326 func Test_popup_nospace()
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
327 CheckScreendump
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
328
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
329 let lines =<< trim END
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
330 call setline(1, repeat([repeat('-', 60)], 15))
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
331 set so=0
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
332
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
333 " cursor in a line in top half, using "botleft" with popup that
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
334 " does fit
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
335 normal 5G2|r@
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
336 let winid1 = popup_create(['one', 'two'], #{
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
337 \ line: 'cursor-1',
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
338 \ col: 'cursor',
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
339 \ pos: 'botleft',
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
340 \ border: [],
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
341 \ })
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
342 " cursor in a line in top half, using "botleft" with popup that
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
343 " doesn't fit: gets truncated
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
344 normal 5G9|r#
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
345 let winid1 = popup_create(['one', 'two', 'tee'], #{
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
346 \ line: 'cursor-1',
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
347 \ col: 'cursor',
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
348 \ pos: 'botleft',
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
349 \ posinvert: 0,
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
350 \ border: [],
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
351 \ })
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
352 " cursor in a line in top half, using "botleft" with popup that
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
353 " doesn't fit and 'posinvert' set: flips to below.
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
354 normal 5G16|r%
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
355 let winid1 = popup_create(['one', 'two', 'tee'], #{
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
356 \ line: 'cursor-1',
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
357 \ col: 'cursor',
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
358 \ pos: 'botleft',
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
359 \ border: [],
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
360 \ })
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
361 " cursor in a line in bottom half, using "botleft" with popup that
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
362 " doesn't fit: does not flip.
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
363 normal 8G23|r*
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
364 let winid1 = popup_create(['aaa', 'bbb', 'ccc', 'ddd', 'eee', 'fff'], #{
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
365 \ line: 'cursor-1',
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
366 \ col: 'cursor',
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
367 \ pos: 'botleft',
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
368 \ border: [],
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
369 \ })
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
370
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
371 " cursor in a line in bottom half, using "topleft" with popup that
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
372 " does fit
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
373 normal 8G30|r@
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
374 let winid1 = popup_create(['one', 'two'], #{
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
375 \ line: 'cursor+1',
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
376 \ col: 'cursor',
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
377 \ pos: 'topleft',
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
378 \ border: [],
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
379 \ })
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
380 " cursor in a line in top half, using "topleft" with popup that
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
381 " doesn't fit: truncated
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
382 normal 8G37|r#
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
383 let winid1 = popup_create(['one', 'two', 'tee'], #{
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
384 \ line: 'cursor+1',
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
385 \ col: 'cursor',
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
386 \ pos: 'topleft',
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
387 \ posinvert: 0,
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
388 \ border: [],
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
389 \ })
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
390 " cursor in a line in top half, using "topleft" with popup that
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
391 " doesn't fit and "posinvert" set: flips to below.
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
392 normal 8G44|r%
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
393 let winid1 = popup_create(['one', 'two', 'tee'], #{
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
394 \ line: 'cursor+1',
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
395 \ col: 'cursor',
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
396 \ pos: 'topleft',
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
397 \ border: [],
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
398 \ })
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
399 " cursor in a line in top half, using "topleft" with popup that
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
400 " doesn't fit: does not flip.
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
401 normal 5G51|r*
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
402 let winid1 = popup_create(['aaa', 'bbb', 'ccc', 'ddd', 'eee', 'fff'], #{
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
403 \ line: 'cursor+1',
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
404 \ col: 'cursor',
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
405 \ pos: 'topleft',
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
406 \ border: [],
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
407 \ })
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
408 END
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
409 call writefile(lines, 'XtestPopupNospace')
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
410 let buf = RunVimInTerminal('-S XtestPopupNospace', #{rows: 12})
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
411 call VerifyScreenDump(buf, 'Test_popupwin_nospace', {})
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
412
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
413 " clean up
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
414 call StopVimInTerminal(buf)
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
415 call delete('XtestPopupNospace')
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
416 endfunc
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
417
17047
6400d1ad5e4b patch 8.1.1523: cannot show range of buffer lines in popup window
Bram Moolenaar <Bram@vim.org>
parents: 17045
diff changeset
418 func Test_popup_firstline()
17680
55704f587945 patch 8.1.1837: popup test fails if clipboard is supported but not working
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
419 CheckScreendump
55704f587945 patch 8.1.1837: popup test fails if clipboard is supported but not working
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
420
17047
6400d1ad5e4b patch 8.1.1523: cannot show range of buffer lines in popup window
Bram Moolenaar <Bram@vim.org>
parents: 17045
diff changeset
421 let lines =<< trim END
6400d1ad5e4b patch 8.1.1523: cannot show range of buffer lines in popup window
Bram Moolenaar <Bram@vim.org>
parents: 17045
diff changeset
422 call setline(1, range(1, 20))
17905
fb773f73a4be patch 8.1.1949: cannot scroll a popup window to the very bottom
Bram Moolenaar <Bram@vim.org>
parents: 17897
diff changeset
423 let winid = popup_create(['1111', '222222', '33333', '44', '5', '666666', '77777', '888', '9999999999999999'], #{
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
424 \ maxheight: 4,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
425 \ firstline: 3,
17047
6400d1ad5e4b patch 8.1.1523: cannot show range of buffer lines in popup window
Bram Moolenaar <Bram@vim.org>
parents: 17045
diff changeset
426 \ })
6400d1ad5e4b patch 8.1.1523: cannot show range of buffer lines in popup window
Bram Moolenaar <Bram@vim.org>
parents: 17045
diff changeset
427 END
6400d1ad5e4b patch 8.1.1523: cannot show range of buffer lines in popup window
Bram Moolenaar <Bram@vim.org>
parents: 17045
diff changeset
428 call writefile(lines, 'XtestPopupFirstline')
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
429 let buf = RunVimInTerminal('-S XtestPopupFirstline', #{rows: 10})
17905
fb773f73a4be patch 8.1.1949: cannot scroll a popup window to the very bottom
Bram Moolenaar <Bram@vim.org>
parents: 17897
diff changeset
430 call VerifyScreenDump(buf, 'Test_popupwin_firstline_1', {})
fb773f73a4be patch 8.1.1949: cannot scroll a popup window to the very bottom
Bram Moolenaar <Bram@vim.org>
parents: 17897
diff changeset
431
fb773f73a4be patch 8.1.1949: cannot scroll a popup window to the very bottom
Bram Moolenaar <Bram@vim.org>
parents: 17897
diff changeset
432 call term_sendkeys(buf, ":call popup_setoptions(winid, #{firstline: -1})\<CR>")
fb773f73a4be patch 8.1.1949: cannot scroll a popup window to the very bottom
Bram Moolenaar <Bram@vim.org>
parents: 17897
diff changeset
433 call term_sendkeys(buf, ":\<CR>")
fb773f73a4be patch 8.1.1949: cannot scroll a popup window to the very bottom
Bram Moolenaar <Bram@vim.org>
parents: 17897
diff changeset
434 call VerifyScreenDump(buf, 'Test_popupwin_firstline_2', {})
17047
6400d1ad5e4b patch 8.1.1523: cannot show range of buffer lines in popup window
Bram Moolenaar <Bram@vim.org>
parents: 17045
diff changeset
435
6400d1ad5e4b patch 8.1.1523: cannot show range of buffer lines in popup window
Bram Moolenaar <Bram@vim.org>
parents: 17045
diff changeset
436 " clean up
6400d1ad5e4b patch 8.1.1523: cannot show range of buffer lines in popup window
Bram Moolenaar <Bram@vim.org>
parents: 17045
diff changeset
437 call StopVimInTerminal(buf)
6400d1ad5e4b patch 8.1.1523: cannot show range of buffer lines in popup window
Bram Moolenaar <Bram@vim.org>
parents: 17045
diff changeset
438 call delete('XtestPopupFirstline')
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
439
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
440 let winid = popup_create(['1111', '222222', '33333', '44444'], #{
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
441 \ maxheight: 2,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
442 \ firstline: 3,
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
443 \ })
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
444 call assert_equal(3, popup_getoptions(winid).firstline)
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
445 call popup_setoptions(winid, #{firstline: 1})
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
446 call assert_equal(1, popup_getoptions(winid).firstline)
17972
a170c48e0f91 patch 8.1.1982: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17946
diff changeset
447 eval winid->popup_close()
17897
fa032e079825 patch 8.1.1945: popup window "firstline" cannot be reset
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
448
fa032e079825 patch 8.1.1945: popup window "firstline" cannot be reset
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
449 let winid = popup_create(['xxx']->repeat(50), #{
fa032e079825 patch 8.1.1945: popup window "firstline" cannot be reset
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
450 \ maxheight: 3,
fa032e079825 patch 8.1.1945: popup window "firstline" cannot be reset
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
451 \ firstline: 11,
fa032e079825 patch 8.1.1945: popup window "firstline" cannot be reset
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
452 \ })
fa032e079825 patch 8.1.1945: popup window "firstline" cannot be reset
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
453 redraw
fa032e079825 patch 8.1.1945: popup window "firstline" cannot be reset
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
454 call assert_equal(11, popup_getoptions(winid).firstline)
fa032e079825 patch 8.1.1945: popup window "firstline" cannot be reset
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
455 call assert_equal(11, popup_getpos(winid).firstline)
17942
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17934
diff changeset
456 " check line() works with popup window
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17934
diff changeset
457 call assert_equal(11, line('.', winid))
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17934
diff changeset
458 call assert_equal(50, line('$', winid))
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17934
diff changeset
459 call assert_equal(0, line('$', 123456))
17897
fa032e079825 patch 8.1.1945: popup window "firstline" cannot be reset
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
460
fa032e079825 patch 8.1.1945: popup window "firstline" cannot be reset
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
461 " Normal command changes what is displayed but not "firstline"
fa032e079825 patch 8.1.1945: popup window "firstline" cannot be reset
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
462 call win_execute(winid, "normal! \<c-y>")
fa032e079825 patch 8.1.1945: popup window "firstline" cannot be reset
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
463 call assert_equal(11, popup_getoptions(winid).firstline)
fa032e079825 patch 8.1.1945: popup window "firstline" cannot be reset
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
464 call assert_equal(10, popup_getpos(winid).firstline)
fa032e079825 patch 8.1.1945: popup window "firstline" cannot be reset
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
465
fa032e079825 patch 8.1.1945: popup window "firstline" cannot be reset
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
466 " Making some property change applies "firstline" again
fa032e079825 patch 8.1.1945: popup window "firstline" cannot be reset
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
467 call popup_setoptions(winid, #{line: 4})
fa032e079825 patch 8.1.1945: popup window "firstline" cannot be reset
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
468 call assert_equal(11, popup_getoptions(winid).firstline)
fa032e079825 patch 8.1.1945: popup window "firstline" cannot be reset
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
469 call assert_equal(11, popup_getpos(winid).firstline)
fa032e079825 patch 8.1.1945: popup window "firstline" cannot be reset
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
470
fa032e079825 patch 8.1.1945: popup window "firstline" cannot be reset
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
471 " Remove "firstline" property and scroll
fa032e079825 patch 8.1.1945: popup window "firstline" cannot be reset
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
472 call popup_setoptions(winid, #{firstline: 0})
fa032e079825 patch 8.1.1945: popup window "firstline" cannot be reset
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
473 call win_execute(winid, "normal! \<c-y>")
fa032e079825 patch 8.1.1945: popup window "firstline" cannot be reset
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
474 call assert_equal(0, popup_getoptions(winid).firstline)
fa032e079825 patch 8.1.1945: popup window "firstline" cannot be reset
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
475 call assert_equal(10, popup_getpos(winid).firstline)
fa032e079825 patch 8.1.1945: popup window "firstline" cannot be reset
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
476
fa032e079825 patch 8.1.1945: popup window "firstline" cannot be reset
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
477 " Making some property change has no side effect
fa032e079825 patch 8.1.1945: popup window "firstline" cannot be reset
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
478 call popup_setoptions(winid, #{line: 3})
fa032e079825 patch 8.1.1945: popup window "firstline" cannot be reset
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
479 call assert_equal(0, popup_getoptions(winid).firstline)
fa032e079825 patch 8.1.1945: popup window "firstline" cannot be reset
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
480 call assert_equal(10, popup_getpos(winid).firstline)
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
481
18512
e855058e0c23 patch 8.1.2250: CTRL-U and CTRL-D don't work in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18494
diff changeset
482 " CTRL-D scrolls down half a page
e855058e0c23 patch 8.1.2250: CTRL-U and CTRL-D don't work in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18494
diff changeset
483 let winid = popup_create(['xxx']->repeat(50), #{
e855058e0c23 patch 8.1.2250: CTRL-U and CTRL-D don't work in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18494
diff changeset
484 \ maxheight: 8,
e855058e0c23 patch 8.1.2250: CTRL-U and CTRL-D don't work in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18494
diff changeset
485 \ })
e855058e0c23 patch 8.1.2250: CTRL-U and CTRL-D don't work in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18494
diff changeset
486 redraw
e855058e0c23 patch 8.1.2250: CTRL-U and CTRL-D don't work in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18494
diff changeset
487 call assert_equal(1, popup_getpos(winid).firstline)
e855058e0c23 patch 8.1.2250: CTRL-U and CTRL-D don't work in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18494
diff changeset
488 call win_execute(winid, "normal! \<C-D>")
e855058e0c23 patch 8.1.2250: CTRL-U and CTRL-D don't work in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18494
diff changeset
489 call assert_equal(5, popup_getpos(winid).firstline)
e855058e0c23 patch 8.1.2250: CTRL-U and CTRL-D don't work in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18494
diff changeset
490 call win_execute(winid, "normal! \<C-D>")
e855058e0c23 patch 8.1.2250: CTRL-U and CTRL-D don't work in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18494
diff changeset
491 call assert_equal(9, popup_getpos(winid).firstline)
e855058e0c23 patch 8.1.2250: CTRL-U and CTRL-D don't work in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18494
diff changeset
492 call win_execute(winid, "normal! \<C-U>")
e855058e0c23 patch 8.1.2250: CTRL-U and CTRL-D don't work in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18494
diff changeset
493 call assert_equal(5, popup_getpos(winid).firstline)
e855058e0c23 patch 8.1.2250: CTRL-U and CTRL-D don't work in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18494
diff changeset
494
e855058e0c23 patch 8.1.2250: CTRL-U and CTRL-D don't work in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18494
diff changeset
495 call win_execute(winid, "normal! \<C-F>")
e855058e0c23 patch 8.1.2250: CTRL-U and CTRL-D don't work in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18494
diff changeset
496 call assert_equal(11, popup_getpos(winid).firstline)
e855058e0c23 patch 8.1.2250: CTRL-U and CTRL-D don't work in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18494
diff changeset
497 call win_execute(winid, "normal! \<C-B>")
e855058e0c23 patch 8.1.2250: CTRL-U and CTRL-D don't work in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18494
diff changeset
498 call assert_equal(5, popup_getpos(winid).firstline)
e855058e0c23 patch 8.1.2250: CTRL-U and CTRL-D don't work in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18494
diff changeset
499
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
500 call popup_close(winid)
17047
6400d1ad5e4b patch 8.1.1523: cannot show range of buffer lines in popup window
Bram Moolenaar <Bram@vim.org>
parents: 17045
diff changeset
501 endfunc
6400d1ad5e4b patch 8.1.1523: cannot show range of buffer lines in popup window
Bram Moolenaar <Bram@vim.org>
parents: 17045
diff changeset
502
17926
ad7a4bd65f20 patch 8.1.1959: when using "firstline" in popup window text may jump
Bram Moolenaar <Bram@vim.org>
parents: 17920
diff changeset
503 func Test_popup_noscrolloff()
ad7a4bd65f20 patch 8.1.1959: when using "firstline" in popup window text may jump
Bram Moolenaar <Bram@vim.org>
parents: 17920
diff changeset
504 set scrolloff=5
ad7a4bd65f20 patch 8.1.1959: when using "firstline" in popup window text may jump
Bram Moolenaar <Bram@vim.org>
parents: 17920
diff changeset
505 let winid = popup_create(['xxx']->repeat(50), #{
ad7a4bd65f20 patch 8.1.1959: when using "firstline" in popup window text may jump
Bram Moolenaar <Bram@vim.org>
parents: 17920
diff changeset
506 \ maxheight: 5,
ad7a4bd65f20 patch 8.1.1959: when using "firstline" in popup window text may jump
Bram Moolenaar <Bram@vim.org>
parents: 17920
diff changeset
507 \ firstline: 11,
ad7a4bd65f20 patch 8.1.1959: when using "firstline" in popup window text may jump
Bram Moolenaar <Bram@vim.org>
parents: 17920
diff changeset
508 \ })
ad7a4bd65f20 patch 8.1.1959: when using "firstline" in popup window text may jump
Bram Moolenaar <Bram@vim.org>
parents: 17920
diff changeset
509 redraw
ad7a4bd65f20 patch 8.1.1959: when using "firstline" in popup window text may jump
Bram Moolenaar <Bram@vim.org>
parents: 17920
diff changeset
510 call assert_equal(11, popup_getoptions(winid).firstline)
ad7a4bd65f20 patch 8.1.1959: when using "firstline" in popup window text may jump
Bram Moolenaar <Bram@vim.org>
parents: 17920
diff changeset
511 call assert_equal(11, popup_getpos(winid).firstline)
ad7a4bd65f20 patch 8.1.1959: when using "firstline" in popup window text may jump
Bram Moolenaar <Bram@vim.org>
parents: 17920
diff changeset
512
ad7a4bd65f20 patch 8.1.1959: when using "firstline" in popup window text may jump
Bram Moolenaar <Bram@vim.org>
parents: 17920
diff changeset
513 call popup_setoptions(winid, #{firstline: 0})
ad7a4bd65f20 patch 8.1.1959: when using "firstline" in popup window text may jump
Bram Moolenaar <Bram@vim.org>
parents: 17920
diff changeset
514 call win_execute(winid, "normal! \<c-y>")
ad7a4bd65f20 patch 8.1.1959: when using "firstline" in popup window text may jump
Bram Moolenaar <Bram@vim.org>
parents: 17920
diff changeset
515 call assert_equal(0, popup_getoptions(winid).firstline)
ad7a4bd65f20 patch 8.1.1959: when using "firstline" in popup window text may jump
Bram Moolenaar <Bram@vim.org>
parents: 17920
diff changeset
516 call assert_equal(10, popup_getpos(winid).firstline)
ad7a4bd65f20 patch 8.1.1959: when using "firstline" in popup window text may jump
Bram Moolenaar <Bram@vim.org>
parents: 17920
diff changeset
517
ad7a4bd65f20 patch 8.1.1959: when using "firstline" in popup window text may jump
Bram Moolenaar <Bram@vim.org>
parents: 17920
diff changeset
518 call popup_close(winid)
ad7a4bd65f20 patch 8.1.1959: when using "firstline" in popup window text may jump
Bram Moolenaar <Bram@vim.org>
parents: 17920
diff changeset
519 endfunc
ad7a4bd65f20 patch 8.1.1959: when using "firstline" in popup window text may jump
Bram Moolenaar <Bram@vim.org>
parents: 17920
diff changeset
520
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
521 func Test_popup_drag()
17680
55704f587945 patch 8.1.1837: popup test fails if clipboard is supported but not working
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
522 CheckScreendump
55704f587945 patch 8.1.1837: popup test fails if clipboard is supported but not working
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
523
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
524 " create a popup that covers the command line
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
525 let lines =<< trim END
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
526 call setline(1, range(1, 20))
17841
9513821d9d8f patch 8.1.1917: non-current window is not redrawn when moving popup
Bram Moolenaar <Bram@vim.org>
parents: 17825
diff changeset
527 split
9513821d9d8f patch 8.1.1917: non-current window is not redrawn when moving popup
Bram Moolenaar <Bram@vim.org>
parents: 17825
diff changeset
528 vsplit
9513821d9d8f patch 8.1.1917: non-current window is not redrawn when moving popup
Bram Moolenaar <Bram@vim.org>
parents: 17825
diff changeset
529 $wincmd w
9513821d9d8f patch 8.1.1917: non-current window is not redrawn when moving popup
Bram Moolenaar <Bram@vim.org>
parents: 17825
diff changeset
530 vsplit
9513821d9d8f patch 8.1.1917: non-current window is not redrawn when moving popup
Bram Moolenaar <Bram@vim.org>
parents: 17825
diff changeset
531 1wincmd w
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
532 let winid = popup_create(['1111', '222222', '33333'], #{
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
533 \ drag: 1,
17580
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17551
diff changeset
534 \ resize: 1,
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
535 \ border: [],
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
536 \ line: &lines - 4,
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
537 \ })
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
538 func Dragit()
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
539 call feedkeys("\<F3>\<LeftMouse>\<F4>\<LeftDrag>\<LeftRelease>", "xt")
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
540 endfunc
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
541 map <silent> <F3> :call test_setmouse(&lines - 4, &columns / 2)<CR>
17841
9513821d9d8f patch 8.1.1917: non-current window is not redrawn when moving popup
Bram Moolenaar <Bram@vim.org>
parents: 17825
diff changeset
542 map <silent> <F4> :call test_setmouse(&lines - 8, &columns / 2 - 20)<CR>
17580
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17551
diff changeset
543 func Resize()
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17551
diff changeset
544 call feedkeys("\<F5>\<LeftMouse>\<F6>\<LeftDrag>\<LeftRelease>", "xt")
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17551
diff changeset
545 endfunc
17841
9513821d9d8f patch 8.1.1917: non-current window is not redrawn when moving popup
Bram Moolenaar <Bram@vim.org>
parents: 17825
diff changeset
546 map <silent> <F5> :call test_setmouse(6, 21)<CR>
9513821d9d8f patch 8.1.1917: non-current window is not redrawn when moving popup
Bram Moolenaar <Bram@vim.org>
parents: 17825
diff changeset
547 map <silent> <F6> :call test_setmouse(7, 25)<CR>
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
548 END
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
549 call writefile(lines, 'XtestPopupDrag')
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
550 let buf = RunVimInTerminal('-S XtestPopupDrag', #{rows: 10})
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
551 call VerifyScreenDump(buf, 'Test_popupwin_drag_01', {})
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
552
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
553 call term_sendkeys(buf, ":call Dragit()\<CR>")
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
554 call VerifyScreenDump(buf, 'Test_popupwin_drag_02', {})
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
555
17580
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17551
diff changeset
556 call term_sendkeys(buf, ":call Resize()\<CR>")
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17551
diff changeset
557 call VerifyScreenDump(buf, 'Test_popupwin_drag_03', {})
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17551
diff changeset
558
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
559 " clean up
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
560 call StopVimInTerminal(buf)
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
561 call delete('XtestPopupDrag')
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
562 endfunc
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
563
17219
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
564 func Test_popup_close_with_mouse()
17680
55704f587945 patch 8.1.1837: popup test fails if clipboard is supported but not working
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
565 CheckScreendump
55704f587945 patch 8.1.1837: popup test fails if clipboard is supported but not working
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
566
17219
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
567 let lines =<< trim END
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
568 call setline(1, range(1, 20))
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
569 " With border, can click on X
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
570 let winid = popup_create('foobar', #{
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
571 \ close: 'button',
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
572 \ border: [],
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
573 \ line: 1,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
574 \ col: 1,
17219
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
575 \ })
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
576 func CloseMsg(id, result)
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
577 echomsg 'Popup closed with ' .. a:result
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
578 endfunc
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
579 let winid = popup_create('notification', #{
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
580 \ close: 'click',
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
581 \ line: 3,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
582 \ col: 15,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
583 \ callback: 'CloseMsg',
17219
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
584 \ })
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
585 let winid = popup_create('no border here', #{
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
586 \ close: 'button',
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
587 \ line: 5,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
588 \ col: 3,
17219
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
589 \ })
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
590 let winid = popup_create('only padding', #{
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
591 \ close: 'button',
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
592 \ padding: [],
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
593 \ line: 5,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
594 \ col: 23,
17219
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
595 \ })
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
596 func CloseWithX()
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
597 call feedkeys("\<F3>\<LeftMouse>\<LeftRelease>", "xt")
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
598 endfunc
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
599 map <silent> <F3> :call test_setmouse(1, len('foobar') + 2)<CR>
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
600 func CloseWithClick()
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
601 call feedkeys("\<F4>\<LeftMouse>\<LeftRelease>", "xt")
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
602 endfunc
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
603 map <silent> <F4> :call test_setmouse(3, 17)<CR>
17847
bdddd215bf09 patch 8.1.1920: cannot always close a popup when filter consumes all events
Bram Moolenaar <Bram@vim.org>
parents: 17845
diff changeset
604 func CreateWithMenuFilter()
bdddd215bf09 patch 8.1.1920: cannot always close a popup when filter consumes all events
Bram Moolenaar <Bram@vim.org>
parents: 17845
diff changeset
605 let winid = popup_create('barfoo', #{
bdddd215bf09 patch 8.1.1920: cannot always close a popup when filter consumes all events
Bram Moolenaar <Bram@vim.org>
parents: 17845
diff changeset
606 \ close: 'button',
bdddd215bf09 patch 8.1.1920: cannot always close a popup when filter consumes all events
Bram Moolenaar <Bram@vim.org>
parents: 17845
diff changeset
607 \ filter: 'popup_filter_menu',
bdddd215bf09 patch 8.1.1920: cannot always close a popup when filter consumes all events
Bram Moolenaar <Bram@vim.org>
parents: 17845
diff changeset
608 \ border: [],
bdddd215bf09 patch 8.1.1920: cannot always close a popup when filter consumes all events
Bram Moolenaar <Bram@vim.org>
parents: 17845
diff changeset
609 \ line: 1,
bdddd215bf09 patch 8.1.1920: cannot always close a popup when filter consumes all events
Bram Moolenaar <Bram@vim.org>
parents: 17845
diff changeset
610 \ col: 40,
bdddd215bf09 patch 8.1.1920: cannot always close a popup when filter consumes all events
Bram Moolenaar <Bram@vim.org>
parents: 17845
diff changeset
611 \ })
bdddd215bf09 patch 8.1.1920: cannot always close a popup when filter consumes all events
Bram Moolenaar <Bram@vim.org>
parents: 17845
diff changeset
612 endfunc
17219
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
613 END
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
614 call writefile(lines, 'XtestPopupClose')
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
615 let buf = RunVimInTerminal('-S XtestPopupClose', #{rows: 10})
17219
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
616 call VerifyScreenDump(buf, 'Test_popupwin_close_01', {})
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
617
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
618 call term_sendkeys(buf, ":call CloseWithX()\<CR>")
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
619 call VerifyScreenDump(buf, 'Test_popupwin_close_02', {})
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
620
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
621 call term_sendkeys(buf, ":call CloseWithClick()\<CR>")
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
622 call VerifyScreenDump(buf, 'Test_popupwin_close_03', {})
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
623
17847
bdddd215bf09 patch 8.1.1920: cannot always close a popup when filter consumes all events
Bram Moolenaar <Bram@vim.org>
parents: 17845
diff changeset
624 call term_sendkeys(buf, ":call CreateWithMenuFilter()\<CR>")
bdddd215bf09 patch 8.1.1920: cannot always close a popup when filter consumes all events
Bram Moolenaar <Bram@vim.org>
parents: 17845
diff changeset
625 call VerifyScreenDump(buf, 'Test_popupwin_close_04', {})
bdddd215bf09 patch 8.1.1920: cannot always close a popup when filter consumes all events
Bram Moolenaar <Bram@vim.org>
parents: 17845
diff changeset
626
bdddd215bf09 patch 8.1.1920: cannot always close a popup when filter consumes all events
Bram Moolenaar <Bram@vim.org>
parents: 17845
diff changeset
627 " We have to send the actual mouse code, feedkeys() would be caught the
bdddd215bf09 patch 8.1.1920: cannot always close a popup when filter consumes all events
Bram Moolenaar <Bram@vim.org>
parents: 17845
diff changeset
628 " filter.
bdddd215bf09 patch 8.1.1920: cannot always close a popup when filter consumes all events
Bram Moolenaar <Bram@vim.org>
parents: 17845
diff changeset
629 call term_sendkeys(buf, "\<Esc>[<0;47;1M")
bdddd215bf09 patch 8.1.1920: cannot always close a popup when filter consumes all events
Bram Moolenaar <Bram@vim.org>
parents: 17845
diff changeset
630 call VerifyScreenDump(buf, 'Test_popupwin_close_05', {})
bdddd215bf09 patch 8.1.1920: cannot always close a popup when filter consumes all events
Bram Moolenaar <Bram@vim.org>
parents: 17845
diff changeset
631
17219
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
632 " clean up
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
633 call StopVimInTerminal(buf)
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
634 call delete('XtestPopupClose')
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
635 endfunction
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
636
18339
a776385eac9f patch 8.1.2164: stuck when using "j" in a popupwin with popup_filter_menu
Bram Moolenaar <Bram@vim.org>
parents: 18231
diff changeset
637 func Test_popup_menu_wrap()
a776385eac9f patch 8.1.2164: stuck when using "j" in a popupwin with popup_filter_menu
Bram Moolenaar <Bram@vim.org>
parents: 18231
diff changeset
638 CheckScreendump
a776385eac9f patch 8.1.2164: stuck when using "j" in a popupwin with popup_filter_menu
Bram Moolenaar <Bram@vim.org>
parents: 18231
diff changeset
639
a776385eac9f patch 8.1.2164: stuck when using "j" in a popupwin with popup_filter_menu
Bram Moolenaar <Bram@vim.org>
parents: 18231
diff changeset
640 let lines =<< trim END
a776385eac9f patch 8.1.2164: stuck when using "j" in a popupwin with popup_filter_menu
Bram Moolenaar <Bram@vim.org>
parents: 18231
diff changeset
641 call setline(1, range(1, 20))
a776385eac9f patch 8.1.2164: stuck when using "j" in a popupwin with popup_filter_menu
Bram Moolenaar <Bram@vim.org>
parents: 18231
diff changeset
642 call popup_create([
a776385eac9f patch 8.1.2164: stuck when using "j" in a popupwin with popup_filter_menu
Bram Moolenaar <Bram@vim.org>
parents: 18231
diff changeset
643 \ 'one',
a776385eac9f patch 8.1.2164: stuck when using "j" in a popupwin with popup_filter_menu
Bram Moolenaar <Bram@vim.org>
parents: 18231
diff changeset
644 \ 'asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfas',
a776385eac9f patch 8.1.2164: stuck when using "j" in a popupwin with popup_filter_menu
Bram Moolenaar <Bram@vim.org>
parents: 18231
diff changeset
645 \ 'three',
a776385eac9f patch 8.1.2164: stuck when using "j" in a popupwin with popup_filter_menu
Bram Moolenaar <Bram@vim.org>
parents: 18231
diff changeset
646 \ 'four',
a776385eac9f patch 8.1.2164: stuck when using "j" in a popupwin with popup_filter_menu
Bram Moolenaar <Bram@vim.org>
parents: 18231
diff changeset
647 \ ], #{
a776385eac9f patch 8.1.2164: stuck when using "j" in a popupwin with popup_filter_menu
Bram Moolenaar <Bram@vim.org>
parents: 18231
diff changeset
648 \ pos: "botleft",
a776385eac9f patch 8.1.2164: stuck when using "j" in a popupwin with popup_filter_menu
Bram Moolenaar <Bram@vim.org>
parents: 18231
diff changeset
649 \ border: [],
a776385eac9f patch 8.1.2164: stuck when using "j" in a popupwin with popup_filter_menu
Bram Moolenaar <Bram@vim.org>
parents: 18231
diff changeset
650 \ padding: [0,1,0,1],
a776385eac9f patch 8.1.2164: stuck when using "j" in a popupwin with popup_filter_menu
Bram Moolenaar <Bram@vim.org>
parents: 18231
diff changeset
651 \ maxheight: 3,
a776385eac9f patch 8.1.2164: stuck when using "j" in a popupwin with popup_filter_menu
Bram Moolenaar <Bram@vim.org>
parents: 18231
diff changeset
652 \ cursorline: 1,
a776385eac9f patch 8.1.2164: stuck when using "j" in a popupwin with popup_filter_menu
Bram Moolenaar <Bram@vim.org>
parents: 18231
diff changeset
653 \ filter: 'popup_filter_menu',
a776385eac9f patch 8.1.2164: stuck when using "j" in a popupwin with popup_filter_menu
Bram Moolenaar <Bram@vim.org>
parents: 18231
diff changeset
654 \ })
a776385eac9f patch 8.1.2164: stuck when using "j" in a popupwin with popup_filter_menu
Bram Moolenaar <Bram@vim.org>
parents: 18231
diff changeset
655 END
a776385eac9f patch 8.1.2164: stuck when using "j" in a popupwin with popup_filter_menu
Bram Moolenaar <Bram@vim.org>
parents: 18231
diff changeset
656 call writefile(lines, 'XtestPopupWrap')
a776385eac9f patch 8.1.2164: stuck when using "j" in a popupwin with popup_filter_menu
Bram Moolenaar <Bram@vim.org>
parents: 18231
diff changeset
657 let buf = RunVimInTerminal('-S XtestPopupWrap', #{rows: 10})
a776385eac9f patch 8.1.2164: stuck when using "j" in a popupwin with popup_filter_menu
Bram Moolenaar <Bram@vim.org>
parents: 18231
diff changeset
658 call VerifyScreenDump(buf, 'Test_popupwin_wrap_1', {})
a776385eac9f patch 8.1.2164: stuck when using "j" in a popupwin with popup_filter_menu
Bram Moolenaar <Bram@vim.org>
parents: 18231
diff changeset
659
a776385eac9f patch 8.1.2164: stuck when using "j" in a popupwin with popup_filter_menu
Bram Moolenaar <Bram@vim.org>
parents: 18231
diff changeset
660 call term_sendkeys(buf, "jj")
a776385eac9f patch 8.1.2164: stuck when using "j" in a popupwin with popup_filter_menu
Bram Moolenaar <Bram@vim.org>
parents: 18231
diff changeset
661 call VerifyScreenDump(buf, 'Test_popupwin_wrap_2', {})
a776385eac9f patch 8.1.2164: stuck when using "j" in a popupwin with popup_filter_menu
Bram Moolenaar <Bram@vim.org>
parents: 18231
diff changeset
662
a776385eac9f patch 8.1.2164: stuck when using "j" in a popupwin with popup_filter_menu
Bram Moolenaar <Bram@vim.org>
parents: 18231
diff changeset
663 " clean up
a776385eac9f patch 8.1.2164: stuck when using "j" in a popupwin with popup_filter_menu
Bram Moolenaar <Bram@vim.org>
parents: 18231
diff changeset
664 call term_sendkeys(buf, "\<Esc>")
a776385eac9f patch 8.1.2164: stuck when using "j" in a popupwin with popup_filter_menu
Bram Moolenaar <Bram@vim.org>
parents: 18231
diff changeset
665 call StopVimInTerminal(buf)
a776385eac9f patch 8.1.2164: stuck when using "j" in a popupwin with popup_filter_menu
Bram Moolenaar <Bram@vim.org>
parents: 18231
diff changeset
666 call delete('XtestPopupWrap')
a776385eac9f patch 8.1.2164: stuck when using "j" in a popupwin with popup_filter_menu
Bram Moolenaar <Bram@vim.org>
parents: 18231
diff changeset
667 endfunction
a776385eac9f patch 8.1.2164: stuck when using "j" in a popupwin with popup_filter_menu
Bram Moolenaar <Bram@vim.org>
parents: 18231
diff changeset
668
17172
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
669 func Test_popup_with_mask()
17680
55704f587945 patch 8.1.1837: popup test fails if clipboard is supported but not working
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
670 CheckScreendump
55704f587945 patch 8.1.1837: popup test fails if clipboard is supported but not working
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
671
17172
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
672 let lines =<< trim END
17241
3ada3d207b33 patch 8.1.1620: no test for popup window with border and mask
Bram Moolenaar <Bram@vim.org>
parents: 17235
diff changeset
673 call setline(1, repeat([join(range(1, 42), '')], 13))
17172
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
674 hi PopupColor ctermbg=lightgrey
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
675 let winid = popup_create([
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
676 \ 'some text',
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
677 \ 'another line',
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
678 \], #{
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
679 \ line: 1,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
680 \ col: 10,
18542
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
681 \ posinvert: 0,
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
682 \ wrap: 0,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
683 \ fixed: 1,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
684 \ zindex: 90,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
685 \ padding: [],
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
686 \ highlight: 'PopupColor',
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
687 \ mask: [[1,1,1,1], [-5,-1,4,4], [7,9,2,3], [2,4,3,3]]})
17172
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
688 call popup_create([
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
689 \ 'xxxxxxxxx',
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
690 \ 'yyyyyyyyy',
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
691 \], #{
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
692 \ line: 3,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
693 \ col: 18,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
694 \ zindex: 20})
17241
3ada3d207b33 patch 8.1.1620: no test for popup window with border and mask
Bram Moolenaar <Bram@vim.org>
parents: 17235
diff changeset
695 let winidb = popup_create([
3ada3d207b33 patch 8.1.1620: no test for popup window with border and mask
Bram Moolenaar <Bram@vim.org>
parents: 17235
diff changeset
696 \ 'just one line',
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
697 \], #{
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
698 \ line: 7,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
699 \ col: 10,
18542
244b336b94ce patch 8.1.2265: when popup with "botleft" does not fit it flips incorrectly
Bram Moolenaar <Bram@vim.org>
parents: 18512
diff changeset
700 \ posinvert: 0,
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
701 \ wrap: 0,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
702 \ fixed: 1,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
703 \ close: 'button',
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
704 \ zindex: 90,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
705 \ padding: [],
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
706 \ border: [],
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
707 \ mask: [[1,2,1,1], [-5,-1,4,4], [7,9,2,3], [3,5,5,5],[-7,-4,5,5]]})
17172
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
708 END
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
709 call writefile(lines, 'XtestPopupMask')
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
710 let buf = RunVimInTerminal('-S XtestPopupMask', #{rows: 13})
17172
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
711 call VerifyScreenDump(buf, 'Test_popupwin_mask_1', {})
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
712
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
713 call term_sendkeys(buf, ":call popup_move(winid, #{col: 11, line: 2})\<CR>")
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
714 call term_sendkeys(buf, ":call popup_move(winidb, #{col: 12})\<CR>")
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
715 call term_sendkeys(buf, ":\<CR>")
17172
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
716 call VerifyScreenDump(buf, 'Test_popupwin_mask_2', {})
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
717
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
718 call term_sendkeys(buf, ":call popup_move(winid, #{col: 65, line: 2})\<CR>")
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
719 call term_sendkeys(buf, ":call popup_move(winidb, #{col: 63})\<CR>")
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
720 call term_sendkeys(buf, ":\<CR>")
17235
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
721 call VerifyScreenDump(buf, 'Test_popupwin_mask_3', {})
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
722
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
723 call term_sendkeys(buf, ":call popup_move(winid, #{pos: 'topright', col: 12, line: 2})\<CR>")
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
724 call term_sendkeys(buf, ":call popup_move(winidb, #{pos: 'topright', col: 12})\<CR>")
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
725 call term_sendkeys(buf, ":\<CR>")
17235
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
726 call VerifyScreenDump(buf, 'Test_popupwin_mask_4', {})
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
727
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
728 call term_sendkeys(buf, ":call popup_move(winid, #{pos: 'topright', col: 12, line: 11})\<CR>")
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
729 call term_sendkeys(buf, ":call popup_move(winidb, #{pos: 'topleft', col: 42, line: 11})\<CR>")
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
730 call term_sendkeys(buf, ":\<CR>")
17332
61f0bf94ef92 patch 8.1.1665: crash when popup window with mask is below the screen
Bram Moolenaar <Bram@vim.org>
parents: 17314
diff changeset
731 call VerifyScreenDump(buf, 'Test_popupwin_mask_5', {})
61f0bf94ef92 patch 8.1.1665: crash when popup window with mask is below the screen
Bram Moolenaar <Bram@vim.org>
parents: 17314
diff changeset
732
17172
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
733 " clean up
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
734 call StopVimInTerminal(buf)
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
735 call delete('XtestPopupMask')
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
736 endfunc
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
737
17069
76ae212a9075 patch 8.1.1534: modeless selection in popup window selects too much
Bram Moolenaar <Bram@vim.org>
parents: 17055
diff changeset
738 func Test_popup_select()
17680
55704f587945 patch 8.1.1837: popup test fails if clipboard is supported but not working
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
739 CheckScreendump
55704f587945 patch 8.1.1837: popup test fails if clipboard is supported but not working
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
740 CheckFeature clipboard_working
55704f587945 patch 8.1.1837: popup test fails if clipboard is supported but not working
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
741
17069
76ae212a9075 patch 8.1.1534: modeless selection in popup window selects too much
Bram Moolenaar <Bram@vim.org>
parents: 17055
diff changeset
742 " create a popup with some text to be selected
76ae212a9075 patch 8.1.1534: modeless selection in popup window selects too much
Bram Moolenaar <Bram@vim.org>
parents: 17055
diff changeset
743 let lines =<< trim END
17073
89753fdfab85 patch 8.1.1536: popup select test still fails on Mac
Bram Moolenaar <Bram@vim.org>
parents: 17071
diff changeset
744 set clipboard=autoselect
17069
76ae212a9075 patch 8.1.1534: modeless selection in popup window selects too much
Bram Moolenaar <Bram@vim.org>
parents: 17055
diff changeset
745 call setline(1, range(1, 20))
17754
65b89c9eb946 patch 8.1.1874: modeless selection in popup window overlaps scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17718
diff changeset
746 let winid = popup_create(['the word', 'some more', 'several words here', 'invisible', '5', '6', '7'], #{
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
747 \ drag: 1,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
748 \ border: [],
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
749 \ line: 3,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
750 \ col: 10,
17754
65b89c9eb946 patch 8.1.1874: modeless selection in popup window overlaps scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17718
diff changeset
751 \ maxheight: 3,
17069
76ae212a9075 patch 8.1.1534: modeless selection in popup window selects too much
Bram Moolenaar <Bram@vim.org>
parents: 17055
diff changeset
752 \ })
76ae212a9075 patch 8.1.1534: modeless selection in popup window selects too much
Bram Moolenaar <Bram@vim.org>
parents: 17055
diff changeset
753 func Select1()
76ae212a9075 patch 8.1.1534: modeless selection in popup window selects too much
Bram Moolenaar <Bram@vim.org>
parents: 17055
diff changeset
754 call feedkeys("\<F3>\<LeftMouse>\<F4>\<LeftDrag>\<LeftRelease>", "xt")
76ae212a9075 patch 8.1.1534: modeless selection in popup window selects too much
Bram Moolenaar <Bram@vim.org>
parents: 17055
diff changeset
755 endfunc
76ae212a9075 patch 8.1.1534: modeless selection in popup window selects too much
Bram Moolenaar <Bram@vim.org>
parents: 17055
diff changeset
756 map <silent> <F3> :call test_setmouse(4, 15)<CR>
76ae212a9075 patch 8.1.1534: modeless selection in popup window selects too much
Bram Moolenaar <Bram@vim.org>
parents: 17055
diff changeset
757 map <silent> <F4> :call test_setmouse(6, 23)<CR>
76ae212a9075 patch 8.1.1534: modeless selection in popup window selects too much
Bram Moolenaar <Bram@vim.org>
parents: 17055
diff changeset
758 END
76ae212a9075 patch 8.1.1534: modeless selection in popup window selects too much
Bram Moolenaar <Bram@vim.org>
parents: 17055
diff changeset
759 call writefile(lines, 'XtestPopupSelect')
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
760 let buf = RunVimInTerminal('-S XtestPopupSelect', #{rows: 10})
17069
76ae212a9075 patch 8.1.1534: modeless selection in popup window selects too much
Bram Moolenaar <Bram@vim.org>
parents: 17055
diff changeset
761 call term_sendkeys(buf, ":call Select1()\<CR>")
76ae212a9075 patch 8.1.1534: modeless selection in popup window selects too much
Bram Moolenaar <Bram@vim.org>
parents: 17055
diff changeset
762 call VerifyScreenDump(buf, 'Test_popupwin_select_01', {})
76ae212a9075 patch 8.1.1534: modeless selection in popup window selects too much
Bram Moolenaar <Bram@vim.org>
parents: 17055
diff changeset
763
76ae212a9075 patch 8.1.1534: modeless selection in popup window selects too much
Bram Moolenaar <Bram@vim.org>
parents: 17055
diff changeset
764 call term_sendkeys(buf, ":call popup_close(winid)\<CR>")
76ae212a9075 patch 8.1.1534: modeless selection in popup window selects too much
Bram Moolenaar <Bram@vim.org>
parents: 17055
diff changeset
765 call term_sendkeys(buf, "\"*p")
17338
b0de2e92ed46 patch 8.1.1668: popup window test is a bit flaky on some systems
Bram Moolenaar <Bram@vim.org>
parents: 17334
diff changeset
766 " clean the command line, sometimes it still shows a command
b0de2e92ed46 patch 8.1.1668: popup window test is a bit flaky on some systems
Bram Moolenaar <Bram@vim.org>
parents: 17334
diff changeset
767 call term_sendkeys(buf, ":\<esc>")
b0de2e92ed46 patch 8.1.1668: popup window test is a bit flaky on some systems
Bram Moolenaar <Bram@vim.org>
parents: 17334
diff changeset
768
17069
76ae212a9075 patch 8.1.1534: modeless selection in popup window selects too much
Bram Moolenaar <Bram@vim.org>
parents: 17055
diff changeset
769 call VerifyScreenDump(buf, 'Test_popupwin_select_02', {})
76ae212a9075 patch 8.1.1534: modeless selection in popup window selects too much
Bram Moolenaar <Bram@vim.org>
parents: 17055
diff changeset
770
76ae212a9075 patch 8.1.1534: modeless selection in popup window selects too much
Bram Moolenaar <Bram@vim.org>
parents: 17055
diff changeset
771 " clean up
76ae212a9075 patch 8.1.1534: modeless selection in popup window selects too much
Bram Moolenaar <Bram@vim.org>
parents: 17055
diff changeset
772 call StopVimInTerminal(buf)
76ae212a9075 patch 8.1.1534: modeless selection in popup window selects too much
Bram Moolenaar <Bram@vim.org>
parents: 17055
diff changeset
773 call delete('XtestPopupSelect')
76ae212a9075 patch 8.1.1534: modeless selection in popup window selects too much
Bram Moolenaar <Bram@vim.org>
parents: 17055
diff changeset
774 endfunc
76ae212a9075 patch 8.1.1534: modeless selection in popup window selects too much
Bram Moolenaar <Bram@vim.org>
parents: 17055
diff changeset
775
16902
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
776 func Test_popup_in_tab()
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
777 " default popup is local to tab, not visible when in other tab
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
778 let winid = popup_create("text", {})
17043
d99805d25b42 patch 8.1.1521: when a popup window is closed the buffer remains
Bram Moolenaar <Bram@vim.org>
parents: 17037
diff changeset
779 let bufnr = winbufnr(winid)
16902
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
780 call assert_equal(1, popup_getpos(winid).visible)
17149
c90fdb999393 patch 8.1.1574: tabpage option not yet implemented for popup window
Bram Moolenaar <Bram@vim.org>
parents: 17125
diff changeset
781 call assert_equal(0, popup_getoptions(winid).tabpage)
16902
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
782 tabnew
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
783 call assert_equal(0, popup_getpos(winid).visible)
17149
c90fdb999393 patch 8.1.1574: tabpage option not yet implemented for popup window
Bram Moolenaar <Bram@vim.org>
parents: 17125
diff changeset
784 call assert_equal(1, popup_getoptions(winid).tabpage)
16902
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
785 quit
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
786 call assert_equal(1, popup_getpos(winid).visible)
17043
d99805d25b42 patch 8.1.1521: when a popup window is closed the buffer remains
Bram Moolenaar <Bram@vim.org>
parents: 17037
diff changeset
787
d99805d25b42 patch 8.1.1521: when a popup window is closed the buffer remains
Bram Moolenaar <Bram@vim.org>
parents: 17037
diff changeset
788 call assert_equal(1, bufexists(bufnr))
17026
905e1b154058 patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents: 17022
diff changeset
789 call popup_clear()
17043
d99805d25b42 patch 8.1.1521: when a popup window is closed the buffer remains
Bram Moolenaar <Bram@vim.org>
parents: 17037
diff changeset
790 " buffer is gone now
d99805d25b42 patch 8.1.1521: when a popup window is closed the buffer remains
Bram Moolenaar <Bram@vim.org>
parents: 17037
diff changeset
791 call assert_equal(0, bufexists(bufnr))
16902
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
792
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
793 " global popup is visible in any tab
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
794 let winid = popup_create("text", #{tabpage: -1})
16902
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
795 call assert_equal(1, popup_getpos(winid).visible)
17149
c90fdb999393 patch 8.1.1574: tabpage option not yet implemented for popup window
Bram Moolenaar <Bram@vim.org>
parents: 17125
diff changeset
796 call assert_equal(-1, popup_getoptions(winid).tabpage)
16902
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
797 tabnew
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
798 call assert_equal(1, popup_getpos(winid).visible)
17149
c90fdb999393 patch 8.1.1574: tabpage option not yet implemented for popup window
Bram Moolenaar <Bram@vim.org>
parents: 17125
diff changeset
799 call assert_equal(-1, popup_getoptions(winid).tabpage)
16902
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
800 quit
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
801 call assert_equal(1, popup_getpos(winid).visible)
17026
905e1b154058 patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents: 17022
diff changeset
802 call popup_clear()
17149
c90fdb999393 patch 8.1.1574: tabpage option not yet implemented for popup window
Bram Moolenaar <Bram@vim.org>
parents: 17125
diff changeset
803
c90fdb999393 patch 8.1.1574: tabpage option not yet implemented for popup window
Bram Moolenaar <Bram@vim.org>
parents: 17125
diff changeset
804 " create popup in other tab
c90fdb999393 patch 8.1.1574: tabpage option not yet implemented for popup window
Bram Moolenaar <Bram@vim.org>
parents: 17125
diff changeset
805 tabnew
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
806 let winid = popup_create("text", #{tabpage: 1})
17149
c90fdb999393 patch 8.1.1574: tabpage option not yet implemented for popup window
Bram Moolenaar <Bram@vim.org>
parents: 17125
diff changeset
807 call assert_equal(0, popup_getpos(winid).visible)
c90fdb999393 patch 8.1.1574: tabpage option not yet implemented for popup window
Bram Moolenaar <Bram@vim.org>
parents: 17125
diff changeset
808 call assert_equal(1, popup_getoptions(winid).tabpage)
c90fdb999393 patch 8.1.1574: tabpage option not yet implemented for popup window
Bram Moolenaar <Bram@vim.org>
parents: 17125
diff changeset
809 quit
c90fdb999393 patch 8.1.1574: tabpage option not yet implemented for popup window
Bram Moolenaar <Bram@vim.org>
parents: 17125
diff changeset
810 call assert_equal(1, popup_getpos(winid).visible)
c90fdb999393 patch 8.1.1574: tabpage option not yet implemented for popup window
Bram Moolenaar <Bram@vim.org>
parents: 17125
diff changeset
811 call assert_equal(0, popup_getoptions(winid).tabpage)
c90fdb999393 patch 8.1.1574: tabpage option not yet implemented for popup window
Bram Moolenaar <Bram@vim.org>
parents: 17125
diff changeset
812 call popup_clear()
16902
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
813 endfunc
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
814
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
815 func Test_popup_valid_arguments()
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
816 " Zero value is like the property wasn't there
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
817 let winid = popup_create("text", #{col: 0})
16902
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
818 let pos = popup_getpos(winid)
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
819 call assert_inrange(&columns / 2 - 1, &columns / 2 + 1, pos.col)
17026
905e1b154058 patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents: 17022
diff changeset
820 call popup_clear()
16902
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
821
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
822 " using cursor column has minimum value of 1
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
823 let winid = popup_create("text", #{col: 'cursor-100'})
16902
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
824 let pos = popup_getpos(winid)
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
825 call assert_equal(1, pos.col)
17026
905e1b154058 patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents: 17022
diff changeset
826 call popup_clear()
16902
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
827
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
828 " center
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
829 let winid = popup_create("text", #{pos: 'center'})
16902
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
830 let pos = popup_getpos(winid)
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
831 let around = (&columns - pos.width) / 2
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
832 call assert_inrange(around - 1, around + 1, pos.col)
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
833 let around = (&lines - pos.height) / 2
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
834 call assert_inrange(around - 1, around + 1, pos.line)
17026
905e1b154058 patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents: 17022
diff changeset
835 call popup_clear()
16902
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
836 endfunc
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
837
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
838 func Test_popup_invalid_arguments()
17225
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
839 call assert_fails('call popup_create(666, {})', 'E86:')
17026
905e1b154058 patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents: 17022
diff changeset
840 call popup_clear()
16902
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
841 call assert_fails('call popup_create("text", "none")', 'E715:')
17026
905e1b154058 patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents: 17022
diff changeset
842 call popup_clear()
16902
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
843
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
844 call assert_fails('call popup_create("text", #{col: "xxx"})', 'E475:')
17026
905e1b154058 patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents: 17022
diff changeset
845 call popup_clear()
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
846 call assert_fails('call popup_create("text", #{col: "cursor8"})', 'E15:')
17026
905e1b154058 patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents: 17022
diff changeset
847 call popup_clear()
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
848 call assert_fails('call popup_create("text", #{col: "cursor+x"})', 'E15:')
17026
905e1b154058 patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents: 17022
diff changeset
849 call popup_clear()
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
850 call assert_fails('call popup_create("text", #{col: "cursor+8x"})', 'E15:')
17026
905e1b154058 patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents: 17022
diff changeset
851 call popup_clear()
16902
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
852
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
853 call assert_fails('call popup_create("text", #{line: "xxx"})', 'E475:')
17026
905e1b154058 patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents: 17022
diff changeset
854 call popup_clear()
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
855 call assert_fails('call popup_create("text", #{line: "cursor8"})', 'E15:')
17026
905e1b154058 patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents: 17022
diff changeset
856 call popup_clear()
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
857 call assert_fails('call popup_create("text", #{line: "cursor+x"})', 'E15:')
17026
905e1b154058 patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents: 17022
diff changeset
858 call popup_clear()
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
859 call assert_fails('call popup_create("text", #{line: "cursor+8x"})', 'E15:')
17026
905e1b154058 patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents: 17022
diff changeset
860 call popup_clear()
16902
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
861
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
862 call assert_fails('call popup_create("text", #{pos: "there"})', 'E475:')
17026
905e1b154058 patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents: 17022
diff changeset
863 call popup_clear()
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
864 call assert_fails('call popup_create("text", #{padding: "none"})', 'E714:')
17026
905e1b154058 patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents: 17022
diff changeset
865 call popup_clear()
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
866 call assert_fails('call popup_create("text", #{border: "none"})', 'E714:')
17026
905e1b154058 patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents: 17022
diff changeset
867 call popup_clear()
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
868 call assert_fails('call popup_create("text", #{borderhighlight: "none"})', 'E714:')
17026
905e1b154058 patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents: 17022
diff changeset
869 call popup_clear()
17421
73e81cd9e6cb patch 8.1.1709: Coverity warns for possibly using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 17417
diff changeset
870 call assert_fails('call popup_create("text", #{borderhighlight: test_null_list()})', 'E714:')
73e81cd9e6cb patch 8.1.1709: Coverity warns for possibly using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 17417
diff changeset
871 call popup_clear()
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
872 call assert_fails('call popup_create("text", #{borderchars: "none"})', 'E714:')
17026
905e1b154058 patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents: 17022
diff changeset
873 call popup_clear()
16902
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
874
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
875 call assert_fails('call popup_create([#{text: "text"}, 666], {})', 'E715:')
17026
905e1b154058 patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents: 17022
diff changeset
876 call popup_clear()
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
877 call assert_fails('call popup_create([#{text: "text", props: "none"}], {})', 'E714:')
17026
905e1b154058 patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents: 17022
diff changeset
878 call popup_clear()
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
879 call assert_fails('call popup_create([#{text: "text", props: ["none"]}], {})', 'E715:')
17026
905e1b154058 patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents: 17022
diff changeset
880 call popup_clear()
17417
aa4532c1d001 patch 8.1.1707: Coverity warns for possibly using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 17413
diff changeset
881 call assert_fails('call popup_create("text", #{mask: ["asdf"]})', 'E475:')
aa4532c1d001 patch 8.1.1707: Coverity warns for possibly using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 17413
diff changeset
882 call popup_clear()
aa4532c1d001 patch 8.1.1707: Coverity warns for possibly using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 17413
diff changeset
883 call assert_fails('call popup_create("text", #{mask: test_null_list()})', 'E475:')
17604
506dd2efcbb2 patch 8.1.1799: cannot avoid mapping for a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
884 call assert_fails('call popup_create("text", #{mapping: []})', 'E745:')
17417
aa4532c1d001 patch 8.1.1707: Coverity warns for possibly using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 17413
diff changeset
885 call popup_clear()
16902
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
886 endfunc
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
887
16863
2b00163053cd patch 8.1.1433: win_execute() may leave popup window focused
Bram Moolenaar <Bram@vim.org>
parents: 16859
diff changeset
888 func Test_win_execute_closing_curwin()
2b00163053cd patch 8.1.1433: win_execute() may leave popup window focused
Bram Moolenaar <Bram@vim.org>
parents: 16859
diff changeset
889 split
2b00163053cd patch 8.1.1433: win_execute() may leave popup window focused
Bram Moolenaar <Bram@vim.org>
parents: 16859
diff changeset
890 let winid = popup_create('some text', {})
16874
da5f5836e90c patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 16863
diff changeset
891 call assert_fails('call win_execute(winid, winnr() .. "close")', 'E994')
17026
905e1b154058 patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents: 17022
diff changeset
892 call popup_clear()
16874
da5f5836e90c patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 16863
diff changeset
893 endfunc
da5f5836e90c patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 16863
diff changeset
894
da5f5836e90c patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 16863
diff changeset
895 func Test_win_execute_not_allowed()
da5f5836e90c patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 16863
diff changeset
896 let winid = popup_create('some text', {})
da5f5836e90c patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 16863
diff changeset
897 call assert_fails('call win_execute(winid, "split")', 'E994:')
da5f5836e90c patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 16863
diff changeset
898 call assert_fails('call win_execute(winid, "vsplit")', 'E994:')
da5f5836e90c patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 16863
diff changeset
899 call assert_fails('call win_execute(winid, "close")', 'E994:')
da5f5836e90c patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 16863
diff changeset
900 call assert_fails('call win_execute(winid, "bdelete")', 'E994:')
16878
4096722cd9c1 patch 8.1.1440: win_execute() test fails
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
901 call assert_fails('call win_execute(winid, "bwipe!")', 'E994:')
16874
da5f5836e90c patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 16863
diff changeset
902 call assert_fails('call win_execute(winid, "tabnew")', 'E994:')
da5f5836e90c patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 16863
diff changeset
903 call assert_fails('call win_execute(winid, "tabnext")', 'E994:')
da5f5836e90c patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 16863
diff changeset
904 call assert_fails('call win_execute(winid, "next")', 'E994:')
da5f5836e90c patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 16863
diff changeset
905 call assert_fails('call win_execute(winid, "rewind")', 'E994:')
da5f5836e90c patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 16863
diff changeset
906 call assert_fails('call win_execute(winid, "buf")', 'E994:')
da5f5836e90c patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 16863
diff changeset
907 call assert_fails('call win_execute(winid, "edit")', 'E994:')
da5f5836e90c patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 16863
diff changeset
908 call assert_fails('call win_execute(winid, "enew")', 'E994:')
da5f5836e90c patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 16863
diff changeset
909 call assert_fails('call win_execute(winid, "wincmd x")', 'E994:')
da5f5836e90c patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 16863
diff changeset
910 call assert_fails('call win_execute(winid, "wincmd w")', 'E994:')
da5f5836e90c patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 16863
diff changeset
911 call assert_fails('call win_execute(winid, "wincmd t")', 'E994:')
da5f5836e90c patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 16863
diff changeset
912 call assert_fails('call win_execute(winid, "wincmd b")', 'E994:')
17026
905e1b154058 patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents: 17022
diff changeset
913 call popup_clear()
16863
2b00163053cd patch 8.1.1433: win_execute() may leave popup window focused
Bram Moolenaar <Bram@vim.org>
parents: 16859
diff changeset
914 endfunc
2b00163053cd patch 8.1.1433: win_execute() may leave popup window focused
Bram Moolenaar <Bram@vim.org>
parents: 16859
diff changeset
915
16857
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
916 func Test_popup_with_wrap()
17680
55704f587945 patch 8.1.1837: popup test fails if clipboard is supported but not working
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
917 CheckScreendump
55704f587945 patch 8.1.1837: popup test fails if clipboard is supported but not working
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
918
16857
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
919 let lines =<< trim END
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
920 call setline(1, range(1, 100))
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
921 let winid = popup_create(
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
922 \ 'a long line that wont fit',
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
923 \ #{line: 3, col: 20, maxwidth: 10, wrap: 1})
16857
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
924 END
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
925 call writefile(lines, 'XtestPopup')
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
926 let buf = RunVimInTerminal('-S XtestPopup', #{rows: 10})
16857
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
927 call VerifyScreenDump(buf, 'Test_popupwin_wrap', {})
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
928
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
929 " clean up
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
930 call StopVimInTerminal(buf)
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
931 call delete('XtestPopup')
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
932 endfunc
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
933
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
934 func Test_popup_without_wrap()
17680
55704f587945 patch 8.1.1837: popup test fails if clipboard is supported but not working
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
935 CheckScreendump
55704f587945 patch 8.1.1837: popup test fails if clipboard is supported but not working
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
936
16857
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
937 let lines =<< trim END
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
938 call setline(1, range(1, 100))
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
939 let winid = popup_create(
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
940 \ 'a long line that wont fit',
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
941 \ #{line: 3, col: 20, maxwidth: 10, wrap: 0})
16857
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
942 END
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
943 call writefile(lines, 'XtestPopup')
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
944 let buf = RunVimInTerminal('-S XtestPopup', #{rows: 10})
16857
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
945 call VerifyScreenDump(buf, 'Test_popupwin_nowrap', {})
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
946
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
947 " clean up
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
948 call StopVimInTerminal(buf)
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
949 call delete('XtestPopup')
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
950 endfunc
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
951
17442
57b9fca8c7d2 patch 8.1.1719: popup too wide when 'showbreak' is set
Bram Moolenaar <Bram@vim.org>
parents: 17438
diff changeset
952 func Test_popup_with_showbreak()
17680
55704f587945 patch 8.1.1837: popup test fails if clipboard is supported but not working
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
953 CheckScreendump
55704f587945 patch 8.1.1837: popup test fails if clipboard is supported but not working
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
954
17442
57b9fca8c7d2 patch 8.1.1719: popup too wide when 'showbreak' is set
Bram Moolenaar <Bram@vim.org>
parents: 17438
diff changeset
955 let lines =<< trim END
57b9fca8c7d2 patch 8.1.1719: popup too wide when 'showbreak' is set
Bram Moolenaar <Bram@vim.org>
parents: 17438
diff changeset
956 set showbreak=>>\
57b9fca8c7d2 patch 8.1.1719: popup too wide when 'showbreak' is set
Bram Moolenaar <Bram@vim.org>
parents: 17438
diff changeset
957 call setline(1, range(1, 20))
57b9fca8c7d2 patch 8.1.1719: popup too wide when 'showbreak' is set
Bram Moolenaar <Bram@vim.org>
parents: 17438
diff changeset
958 let winid = popup_dialog(
18088
687d08fee911 patch 8.1.2039: character from 'showbreak' does not use 'wincolor'
Bram Moolenaar <Bram@vim.org>
parents: 18070
diff changeset
959 \ 'a long line here that wraps',
687d08fee911 patch 8.1.2039: character from 'showbreak' does not use 'wincolor'
Bram Moolenaar <Bram@vim.org>
parents: 18070
diff changeset
960 \ #{filter: 'popup_filter_yesno',
687d08fee911 patch 8.1.2039: character from 'showbreak' does not use 'wincolor'
Bram Moolenaar <Bram@vim.org>
parents: 18070
diff changeset
961 \ maxwidth: 12})
17442
57b9fca8c7d2 patch 8.1.1719: popup too wide when 'showbreak' is set
Bram Moolenaar <Bram@vim.org>
parents: 17438
diff changeset
962 END
57b9fca8c7d2 patch 8.1.1719: popup too wide when 'showbreak' is set
Bram Moolenaar <Bram@vim.org>
parents: 17438
diff changeset
963 call writefile(lines, 'XtestPopupShowbreak')
57b9fca8c7d2 patch 8.1.1719: popup too wide when 'showbreak' is set
Bram Moolenaar <Bram@vim.org>
parents: 17438
diff changeset
964 let buf = RunVimInTerminal('-S XtestPopupShowbreak', #{rows: 10})
57b9fca8c7d2 patch 8.1.1719: popup too wide when 'showbreak' is set
Bram Moolenaar <Bram@vim.org>
parents: 17438
diff changeset
965 call VerifyScreenDump(buf, 'Test_popupwin_showbreak', {})
57b9fca8c7d2 patch 8.1.1719: popup too wide when 'showbreak' is set
Bram Moolenaar <Bram@vim.org>
parents: 17438
diff changeset
966
57b9fca8c7d2 patch 8.1.1719: popup too wide when 'showbreak' is set
Bram Moolenaar <Bram@vim.org>
parents: 17438
diff changeset
967 " clean up
57b9fca8c7d2 patch 8.1.1719: popup too wide when 'showbreak' is set
Bram Moolenaar <Bram@vim.org>
parents: 17438
diff changeset
968 call term_sendkeys(buf, "y")
57b9fca8c7d2 patch 8.1.1719: popup too wide when 'showbreak' is set
Bram Moolenaar <Bram@vim.org>
parents: 17438
diff changeset
969 call StopVimInTerminal(buf)
57b9fca8c7d2 patch 8.1.1719: popup too wide when 'showbreak' is set
Bram Moolenaar <Bram@vim.org>
parents: 17438
diff changeset
970 call delete('XtestPopupShowbreak')
57b9fca8c7d2 patch 8.1.1719: popup too wide when 'showbreak' is set
Bram Moolenaar <Bram@vim.org>
parents: 17438
diff changeset
971 endfunc
57b9fca8c7d2 patch 8.1.1719: popup too wide when 'showbreak' is set
Bram Moolenaar <Bram@vim.org>
parents: 17438
diff changeset
972
16800
12e3a3afdb6a patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents: 16794
diff changeset
973 func Test_popup_time()
17680
55704f587945 patch 8.1.1837: popup test fails if clipboard is supported but not working
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
974 CheckFeature timers
55704f587945 patch 8.1.1837: popup test fails if clipboard is supported but not working
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
975
16800
12e3a3afdb6a patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents: 16794
diff changeset
976 topleft vnew
12e3a3afdb6a patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents: 16794
diff changeset
977 call setline(1, 'hello')
12e3a3afdb6a patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents: 16794
diff changeset
978
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
979 let winid = popup_create('world', #{
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
980 \ line: 1,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
981 \ col: 1,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
982 \ minwidth: 20,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
983 \ time: 500,
16800
12e3a3afdb6a patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents: 16794
diff changeset
984 \})
12e3a3afdb6a patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents: 16794
diff changeset
985 redraw
12e3a3afdb6a patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents: 16794
diff changeset
986 let line = join(map(range(1, 5), 'screenstring(1, v:val)'), '')
12e3a3afdb6a patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents: 16794
diff changeset
987 call assert_equal('world', line)
12e3a3afdb6a patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents: 16794
diff changeset
988
17348
d82b0cfb1e82 patch 8.1.1673: cannot easily find the popup window at a certain position
Bram Moolenaar <Bram@vim.org>
parents: 17338
diff changeset
989 call assert_equal(winid, popup_locate(1, 1))
d82b0cfb1e82 patch 8.1.1673: cannot easily find the popup window at a certain position
Bram Moolenaar <Bram@vim.org>
parents: 17338
diff changeset
990 call assert_equal(winid, popup_locate(1, 20))
d82b0cfb1e82 patch 8.1.1673: cannot easily find the popup window at a certain position
Bram Moolenaar <Bram@vim.org>
parents: 17338
diff changeset
991 call assert_equal(0, popup_locate(1, 21))
d82b0cfb1e82 patch 8.1.1673: cannot easily find the popup window at a certain position
Bram Moolenaar <Bram@vim.org>
parents: 17338
diff changeset
992 call assert_equal(0, popup_locate(2, 1))
d82b0cfb1e82 patch 8.1.1673: cannot easily find the popup window at a certain position
Bram Moolenaar <Bram@vim.org>
parents: 17338
diff changeset
993
16800
12e3a3afdb6a patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents: 16794
diff changeset
994 sleep 700m
16802
f5487021fdad patch 8.1.1403: cannot build without the timer feature
Bram Moolenaar <Bram@vim.org>
parents: 16800
diff changeset
995 redraw
17994
0dcc2ee838dd patch 8.1.1993: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17972
diff changeset
996 let line = join(map(range(1, 5), '1->screenstring(v:val)'), '')
16800
12e3a3afdb6a patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents: 16794
diff changeset
997 call assert_equal('hello', line)
12e3a3afdb6a patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents: 16794
diff changeset
998
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
999 call popup_create('on the command line', #{
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1000 \ line: &lines,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1001 \ col: 10,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1002 \ minwidth: 20,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1003 \ time: 500,
16800
12e3a3afdb6a patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents: 16794
diff changeset
1004 \})
12e3a3afdb6a patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents: 16794
diff changeset
1005 redraw
12e3a3afdb6a patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents: 16794
diff changeset
1006 let line = join(map(range(1, 30), 'screenstring(&lines, v:val)'), '')
12e3a3afdb6a patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents: 16794
diff changeset
1007 call assert_match('.*on the command line.*', line)
12e3a3afdb6a patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents: 16794
diff changeset
1008
12e3a3afdb6a patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents: 16794
diff changeset
1009 sleep 700m
12e3a3afdb6a patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents: 16794
diff changeset
1010 redraw
12e3a3afdb6a patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents: 16794
diff changeset
1011 let line = join(map(range(1, 30), 'screenstring(&lines, v:val)'), '')
12e3a3afdb6a patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents: 16794
diff changeset
1012 call assert_notmatch('.*on the command line.*', line)
12e3a3afdb6a patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents: 16794
diff changeset
1013
12e3a3afdb6a patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents: 16794
diff changeset
1014 bwipe!
12e3a3afdb6a patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents: 16794
diff changeset
1015 endfunc
16809
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
1016
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
1017 func Test_popup_hide()
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
1018 topleft vnew
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
1019 call setline(1, 'hello')
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
1020
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
1021 let winid = popup_create('world', #{
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1022 \ line: 1,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1023 \ col: 1,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1024 \ minwidth: 20,
16809
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
1025 \})
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
1026 redraw
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
1027 let line = join(map(range(1, 5), 'screenstring(1, v:val)'), '')
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
1028 call assert_equal('world', line)
16857
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1029 call assert_equal(1, popup_getpos(winid).visible)
16859
0154363d3b98 patch 8.1.1431: popup window listed as "Scratch"
Bram Moolenaar <Bram@vim.org>
parents: 16857
diff changeset
1030 " buffer is still listed and active
0154363d3b98 patch 8.1.1431: popup window listed as "Scratch"
Bram Moolenaar <Bram@vim.org>
parents: 16857
diff changeset
1031 call assert_match(winbufnr(winid) .. 'u a.*\[Popup\]', execute('ls u'))
16809
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
1032
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
1033 call popup_hide(winid)
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
1034 redraw
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
1035 let line = join(map(range(1, 5), 'screenstring(1, v:val)'), '')
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
1036 call assert_equal('hello', line)
16857
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1037 call assert_equal(0, popup_getpos(winid).visible)
16859
0154363d3b98 patch 8.1.1431: popup window listed as "Scratch"
Bram Moolenaar <Bram@vim.org>
parents: 16857
diff changeset
1038 " buffer is still listed but hidden
0154363d3b98 patch 8.1.1431: popup window listed as "Scratch"
Bram Moolenaar <Bram@vim.org>
parents: 16857
diff changeset
1039 call assert_match(winbufnr(winid) .. 'u h.*\[Popup\]', execute('ls u'))
16809
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
1040
17972
a170c48e0f91 patch 8.1.1982: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17946
diff changeset
1041 eval winid->popup_show()
16809
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
1042 redraw
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
1043 let line = join(map(range(1, 5), 'screenstring(1, v:val)'), '')
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
1044 call assert_equal('world', line)
16857
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1045 call assert_equal(1, popup_getpos(winid).visible)
16809
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
1046
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
1047
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
1048 call popup_close(winid)
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
1049 redraw
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
1050 let line = join(map(range(1, 5), 'screenstring(1, v:val)'), '')
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
1051 call assert_equal('hello', line)
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
1052
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
1053 " error is given for existing non-popup window
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
1054 call assert_fails('call popup_hide(win_getid())', 'E993:')
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
1055
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
1056 " no error non-existing window
17972
a170c48e0f91 patch 8.1.1982: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17946
diff changeset
1057 eval 1234234->popup_hide()
16809
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
1058 call popup_show(41234234)
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
1059
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
1060 bwipe!
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
1061 endfunc
16817
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16811
diff changeset
1062
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16811
diff changeset
1063 func Test_popup_move()
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16811
diff changeset
1064 topleft vnew
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16811
diff changeset
1065 call setline(1, 'hello')
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16811
diff changeset
1066
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
1067 let winid = popup_create('world', #{
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1068 \ line: 1,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1069 \ col: 1,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1070 \ minwidth: 20,
16817
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16811
diff changeset
1071 \})
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16811
diff changeset
1072 redraw
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16811
diff changeset
1073 let line = join(map(range(1, 6), 'screenstring(1, v:val)'), '')
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16811
diff changeset
1074 call assert_equal('world ', line)
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16811
diff changeset
1075
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
1076 call popup_move(winid, #{line: 2, col: 2})
16817
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16811
diff changeset
1077 redraw
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16811
diff changeset
1078 let line = join(map(range(1, 6), 'screenstring(1, v:val)'), '')
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16811
diff changeset
1079 call assert_equal('hello ', line)
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16811
diff changeset
1080 let line = join(map(range(1, 6), 'screenstring(2, v:val)'), '')
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16811
diff changeset
1081 call assert_equal('~world', line)
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16811
diff changeset
1082
17972
a170c48e0f91 patch 8.1.1982: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17946
diff changeset
1083 eval winid->popup_move(#{line: 1})
16817
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16811
diff changeset
1084 redraw
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16811
diff changeset
1085 let line = join(map(range(1, 6), 'screenstring(1, v:val)'), '')
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16811
diff changeset
1086 call assert_equal('hworld', line)
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16811
diff changeset
1087
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16811
diff changeset
1088 call popup_close(winid)
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16811
diff changeset
1089
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16811
diff changeset
1090 bwipe!
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16811
diff changeset
1091 endfunc
16829
5cebaecad422 patch 8.1.1416: popup_getposition() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16817
diff changeset
1092
16857
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1093 func Test_popup_getpos()
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
1094 let winid = popup_create('hello', #{
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1095 \ line: 2,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1096 \ col: 3,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1097 \ minwidth: 10,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1098 \ minheight: 11,
16829
5cebaecad422 patch 8.1.1416: popup_getposition() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16817
diff changeset
1099 \})
5cebaecad422 patch 8.1.1416: popup_getposition() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16817
diff changeset
1100 redraw
16857
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1101 let res = popup_getpos(winid)
16829
5cebaecad422 patch 8.1.1416: popup_getposition() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16817
diff changeset
1102 call assert_equal(2, res.line)
5cebaecad422 patch 8.1.1416: popup_getposition() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16817
diff changeset
1103 call assert_equal(3, res.col)
5cebaecad422 patch 8.1.1416: popup_getposition() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16817
diff changeset
1104 call assert_equal(10, res.width)
5cebaecad422 patch 8.1.1416: popup_getposition() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16817
diff changeset
1105 call assert_equal(11, res.height)
16841
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
1106 call assert_equal(1, res.visible)
16829
5cebaecad422 patch 8.1.1416: popup_getposition() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16817
diff changeset
1107
5cebaecad422 patch 8.1.1416: popup_getposition() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16817
diff changeset
1108 call popup_close(winid)
5cebaecad422 patch 8.1.1416: popup_getposition() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16817
diff changeset
1109 endfunc
16837
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
1110
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
1111 func Test_popup_width_longest()
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
1112 let tests = [
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
1113 \ [['hello', 'this', 'window', 'displays', 'all of its text'], 15],
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
1114 \ [['hello', 'this', 'window', 'all of its text', 'displays'], 15],
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
1115 \ [['hello', 'this', 'all of its text', 'window', 'displays'], 15],
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
1116 \ [['hello', 'all of its text', 'this', 'window', 'displays'], 15],
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
1117 \ [['all of its text', 'hello', 'this', 'window', 'displays'], 15],
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
1118 \ ]
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
1119
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
1120 for test in tests
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
1121 let winid = popup_create(test[0], #{line: 2, col: 3})
16837
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
1122 redraw
16857
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1123 let position = popup_getpos(winid)
16837
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
1124 call assert_equal(test[1], position.width)
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
1125 call popup_close(winid)
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
1126 endfor
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
1127 endfunc
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
1128
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
1129 func Test_popup_wraps()
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
1130 let tests = [
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
1131 \ ['nowrap', 6, 1],
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
1132 \ ['a line that wraps once', 12, 2],
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
1133 \ ['a line that wraps two times', 12, 3],
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
1134 \ ]
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
1135 for test in tests
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
1136 let winid = popup_create(test[0],
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
1137 \ #{line: 2, col: 3, maxwidth: 12})
16837
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
1138 redraw
16857
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1139 let position = popup_getpos(winid)
16837
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
1140 call assert_equal(test[1], position.width)
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
1141 call assert_equal(test[2], position.height)
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
1142
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
1143 call popup_close(winid)
16857
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1144 call assert_equal({}, popup_getpos(winid))
16837
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
1145 endfor
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
1146 endfunc
16841
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
1147
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
1148 func Test_popup_getoptions()
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
1149 let winid = popup_create('hello', #{
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1150 \ line: 2,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1151 \ col: 3,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1152 \ minwidth: 10,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1153 \ minheight: 11,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1154 \ maxwidth: 20,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1155 \ maxheight: 21,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1156 \ zindex: 100,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1157 \ time: 5000,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1158 \ fixed: 1
16841
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
1159 \})
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
1160 redraw
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
1161 let res = popup_getoptions(winid)
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
1162 call assert_equal(2, res.line)
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
1163 call assert_equal(3, res.col)
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
1164 call assert_equal(10, res.minwidth)
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
1165 call assert_equal(11, res.minheight)
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
1166 call assert_equal(20, res.maxwidth)
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
1167 call assert_equal(21, res.maxheight)
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
1168 call assert_equal(100, res.zindex)
16896
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1169 call assert_equal(1, res.fixed)
17626
2ae30dac20d6 patch 8.1.1810: popup_getoptions() is missing an entry for "mapping"
Bram Moolenaar <Bram@vim.org>
parents: 17604
diff changeset
1170 call assert_equal(1, res.mapping)
16841
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
1171 if has('timers')
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
1172 call assert_equal(5000, res.time)
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
1173 endif
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
1174 call popup_close(winid)
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
1175
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
1176 let winid = popup_create('hello', {})
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
1177 redraw
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
1178 let res = popup_getoptions(winid)
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
1179 call assert_equal(0, res.line)
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
1180 call assert_equal(0, res.col)
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
1181 call assert_equal(0, res.minwidth)
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
1182 call assert_equal(0, res.minheight)
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
1183 call assert_equal(0, res.maxwidth)
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
1184 call assert_equal(0, res.maxheight)
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
1185 call assert_equal(50, res.zindex)
16896
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1186 call assert_equal(0, res.fixed)
16841
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
1187 if has('timers')
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
1188 call assert_equal(0, res.time)
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
1189 endif
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
1190 call popup_close(winid)
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
1191 call assert_equal({}, popup_getoptions(winid))
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
1192 endfunc
16843
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16841
diff changeset
1193
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16841
diff changeset
1194 func Test_popup_option_values()
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16841
diff changeset
1195 new
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16841
diff changeset
1196 " window-local
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16841
diff changeset
1197 setlocal number
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16841
diff changeset
1198 setlocal nowrap
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16841
diff changeset
1199 " buffer-local
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16841
diff changeset
1200 setlocal omnifunc=Something
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16841
diff changeset
1201 " global/buffer-local
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16841
diff changeset
1202 setlocal path=/there
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16841
diff changeset
1203 " global/window-local
17926
ad7a4bd65f20 patch 8.1.1959: when using "firstline" in popup window text may jump
Bram Moolenaar <Bram@vim.org>
parents: 17920
diff changeset
1204 setlocal statusline=2
16843
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16841
diff changeset
1205
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16841
diff changeset
1206 let winid = popup_create('hello', {})
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16841
diff changeset
1207 call assert_equal(0, getwinvar(winid, '&number'))
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16841
diff changeset
1208 call assert_equal(1, getwinvar(winid, '&wrap'))
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16841
diff changeset
1209 call assert_equal('', getwinvar(winid, '&omnifunc'))
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16841
diff changeset
1210 call assert_equal(&g:path, getwinvar(winid, '&path'))
17926
ad7a4bd65f20 patch 8.1.1959: when using "firstline" in popup window text may jump
Bram Moolenaar <Bram@vim.org>
parents: 17920
diff changeset
1211 call assert_equal(&g:statusline, getwinvar(winid, '&statusline'))
ad7a4bd65f20 patch 8.1.1959: when using "firstline" in popup window text may jump
Bram Moolenaar <Bram@vim.org>
parents: 17920
diff changeset
1212
ad7a4bd65f20 patch 8.1.1959: when using "firstline" in popup window text may jump
Bram Moolenaar <Bram@vim.org>
parents: 17920
diff changeset
1213 " 'scrolloff' is reset to zero
ad7a4bd65f20 patch 8.1.1959: when using "firstline" in popup window text may jump
Bram Moolenaar <Bram@vim.org>
parents: 17920
diff changeset
1214 call assert_equal(5, &scrolloff)
ad7a4bd65f20 patch 8.1.1959: when using "firstline" in popup window text may jump
Bram Moolenaar <Bram@vim.org>
parents: 17920
diff changeset
1215 call assert_equal(0, getwinvar(winid, '&scrolloff'))
16843
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16841
diff changeset
1216
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16841
diff changeset
1217 call popup_close(winid)
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16841
diff changeset
1218 bwipe
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16841
diff changeset
1219 endfunc
16853
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
1220
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
1221 func Test_popup_atcursor()
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
1222 topleft vnew
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
1223 call setline(1, [
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
1224 \ 'xxxxxxxxxxxxxxxxx',
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
1225 \ 'xxxxxxxxxxxxxxxxx',
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
1226 \ 'xxxxxxxxxxxxxxxxx',
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
1227 \])
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
1228
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
1229 call cursor(2, 2)
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
1230 redraw
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
1231 let winid = popup_atcursor('vim', {})
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
1232 redraw
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
1233 let line = join(map(range(1, 17), 'screenstring(1, v:val)'), '')
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
1234 call assert_equal('xvimxxxxxxxxxxxxx', line)
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
1235 call popup_close(winid)
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
1236
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
1237 call cursor(3, 4)
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
1238 redraw
17972
a170c48e0f91 patch 8.1.1982: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17946
diff changeset
1239 let winid = 'vim'->popup_atcursor({})
16853
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
1240 redraw
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
1241 let line = join(map(range(1, 17), 'screenstring(2, v:val)'), '')
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
1242 call assert_equal('xxxvimxxxxxxxxxxx', line)
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
1243 call popup_close(winid)
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
1244
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
1245 call cursor(1, 1)
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
1246 redraw
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
1247 let winid = popup_create('vim', #{
17551
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1248 \ line: 'cursor+2',
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1249 \ col: 'cursor+1',
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1250 \})
16853
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
1251 redraw
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
1252 let line = join(map(range(1, 17), 'screenstring(3, v:val)'), '')
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
1253 call assert_equal('xvimxxxxxxxxxxxxx', line)
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
1254 call popup_close(winid)
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
1255
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
1256 call cursor(3, 3)
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
1257 redraw
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
1258 let winid = popup_create('vim', #{
17551
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1259 \ line: 'cursor-2',
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1260 \ col: 'cursor-1',
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1261 \})
16853
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
1262 redraw
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
1263 let line = join(map(range(1, 17), 'screenstring(1, v:val)'), '')
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
1264 call assert_equal('xvimxxxxxxxxxxxxx', line)
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
1265 call popup_close(winid)
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
1266
16857
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1267 " just enough room above
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1268 call cursor(3, 3)
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1269 redraw
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1270 let winid = popup_atcursor(['vim', 'is great'], {})
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1271 redraw
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1272 let pos = popup_getpos(winid)
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1273 call assert_equal(1, pos.line)
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1274 call popup_close(winid)
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1275
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1276 " not enough room above, popup goes below the cursor
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1277 call cursor(3, 3)
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1278 redraw
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1279 let winid = popup_atcursor(['vim', 'is', 'great'], {})
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1280 redraw
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1281 let pos = popup_getpos(winid)
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1282 call assert_equal(4, pos.line)
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1283 call popup_close(winid)
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1284
16902
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
1285 " cursor in first line, popup in line 2
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
1286 call cursor(1, 1)
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
1287 redraw
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
1288 let winid = popup_atcursor(['vim', 'is', 'great'], {})
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
1289 redraw
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
1290 let pos = popup_getpos(winid)
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
1291 call assert_equal(2, pos.line)
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
1292 call popup_close(winid)
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
1293
16853
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
1294 bwipe!
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
1295 endfunc
16880
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1296
17292
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1297 func Test_popup_beval()
17680
55704f587945 patch 8.1.1837: popup test fails if clipboard is supported but not working
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
1298 CheckScreendump
18137
5a5e9eed6029 patch 8.1.2063: some tests fail when +balloon_eval_term is missing
Bram Moolenaar <Bram@vim.org>
parents: 18110
diff changeset
1299 CheckFeature balloon_eval_term
17292
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1300
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1301 let lines =<< trim END
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1302 call setline(1, range(1, 20))
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1303 call setline(5, 'here is some text to hover over')
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1304 set balloonevalterm
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1305 set balloonexpr=BalloonExpr()
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1306 set balloondelay=100
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1307 func BalloonExpr()
17972
a170c48e0f91 patch 8.1.1982: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17946
diff changeset
1308 let s:winid = [v:beval_text]->popup_beval({})
17292
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1309 return ''
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1310 endfunc
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1311 func Hover()
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1312 call test_setmouse(5, 15)
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1313 call feedkeys("\<MouseMove>\<Ignore>", "xt")
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1314 sleep 100m
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1315 endfunc
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1316 func MoveOntoPopup()
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1317 call test_setmouse(4, 17)
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1318 call feedkeys("\<F4>\<MouseMove>\<Ignore>", "xt")
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1319 endfunc
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1320 func MoveAway()
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1321 call test_setmouse(5, 13)
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1322 call feedkeys("\<F5>\<MouseMove>\<Ignore>", "xt")
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1323 endfunc
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1324 END
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1325 call writefile(lines, 'XtestPopupBeval')
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
1326 let buf = RunVimInTerminal('-S XtestPopupBeval', #{rows: 10})
17292
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1327 call term_wait(buf, 100)
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1328 call term_sendkeys(buf, 'j')
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1329 call term_sendkeys(buf, ":call Hover()\<CR>")
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1330 call VerifyScreenDump(buf, 'Test_popupwin_beval_1', {})
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1331
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1332 call term_sendkeys(buf, ":call MoveOntoPopup()\<CR>")
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1333 call VerifyScreenDump(buf, 'Test_popupwin_beval_2', {})
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1334
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1335 call term_sendkeys(buf, ":call MoveAway()\<CR>")
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1336 call VerifyScreenDump(buf, 'Test_popupwin_beval_3', {})
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1337
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1338 " clean up
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1339 call StopVimInTerminal(buf)
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1340 call delete('XtestPopupBeval')
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1341 endfunc
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1342
16880
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1343 func Test_popup_filter()
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1344 new
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1345 call setline(1, 'some text')
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1346
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1347 func MyPopupFilter(winid, c)
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1348 if a:c == 'e'
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1349 let g:eaten = 'e'
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1350 return 1
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1351 endif
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1352 if a:c == '0'
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1353 let g:ignored = '0'
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1354 return 0
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1355 endif
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1356 if a:c == 'x'
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1357 call popup_close(a:winid)
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1358 return 1
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1359 endif
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1360 return 0
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1361 endfunc
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1362
17972
a170c48e0f91 patch 8.1.1982: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17946
diff changeset
1363 let winid = 'something'->popup_create(#{filter: 'MyPopupFilter'})
16880
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1364 redraw
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1365
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1366 " e is consumed by the filter
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1367 call feedkeys('e', 'xt')
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1368 call assert_equal('e', g:eaten)
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1369
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1370 " 0 is ignored by the filter
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1371 normal $
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1372 call assert_equal(9, getcurpos()[2])
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1373 call feedkeys('0', 'xt')
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1374 call assert_equal('0', g:ignored)
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1375 call assert_equal(1, getcurpos()[2])
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1376
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1377 " x closes the popup
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1378 call feedkeys('x', 'xt')
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1379 call assert_equal('e', g:eaten)
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1380 call assert_equal(-1, winbufnr(winid))
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1381
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1382 delfunc MyPopupFilter
17026
905e1b154058 patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents: 17022
diff changeset
1383 call popup_clear()
16880
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1384 endfunc
16890
5131023c5728 patch 8.1.1446: popup window callback not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16888
diff changeset
1385
17097
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1386 func ShowDialog(key, result)
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1387 let s:cb_res = 999
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
1388 let winid = popup_dialog('do you want to quit (Yes/no)?', #{
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1389 \ filter: 'popup_filter_yesno',
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1390 \ callback: 'QuitCallback',
17097
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1391 \ })
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1392 redraw
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1393 call feedkeys(a:key, "xt")
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1394 call assert_equal(winid, s:cb_winid)
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1395 call assert_equal(a:result, s:cb_res)
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1396 endfunc
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1397
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1398 func Test_popup_dialog()
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1399 func QuitCallback(id, res)
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1400 let s:cb_winid = a:id
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1401 let s:cb_res = a:res
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1402 endfunc
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1403
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1404 let winid = ShowDialog("y", 1)
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1405 let winid = ShowDialog("Y", 1)
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1406 let winid = ShowDialog("n", 0)
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1407 let winid = ShowDialog("N", 0)
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1408 let winid = ShowDialog("x", 0)
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1409 let winid = ShowDialog("X", 0)
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1410 let winid = ShowDialog("\<Esc>", 0)
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1411 let winid = ShowDialog("\<C-C>", -1)
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1412
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1413 delfunc QuitCallback
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1414 endfunc
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1415
17117
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1416 func ShowMenu(key, result)
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1417 let s:cb_res = 999
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
1418 let winid = popup_menu(['one', 'two', 'something else'], #{
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1419 \ callback: 'QuitCallback',
17117
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1420 \ })
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1421 redraw
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1422 call feedkeys(a:key, "xt")
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1423 call assert_equal(winid, s:cb_winid)
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1424 call assert_equal(a:result, s:cb_res)
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1425 endfunc
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1426
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1427 func Test_popup_menu()
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1428 func QuitCallback(id, res)
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1429 let s:cb_winid = a:id
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1430 let s:cb_res = a:res
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1431 endfunc
17604
506dd2efcbb2 patch 8.1.1799: cannot avoid mapping for a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
1432 " mapping won't be used in popup
506dd2efcbb2 patch 8.1.1799: cannot avoid mapping for a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
1433 map j k
17117
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1434
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1435 let winid = ShowMenu(" ", 1)
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1436 let winid = ShowMenu("j \<CR>", 2)
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1437 let winid = ShowMenu("JjK \<CR>", 2)
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1438 let winid = ShowMenu("jjjjjj ", 3)
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1439 let winid = ShowMenu("kkk ", 1)
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1440 let winid = ShowMenu("x", -1)
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1441 let winid = ShowMenu("X", -1)
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1442 let winid = ShowMenu("\<Esc>", -1)
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1443 let winid = ShowMenu("\<C-C>", -1)
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1444
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1445 delfunc QuitCallback
17604
506dd2efcbb2 patch 8.1.1799: cannot avoid mapping for a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
1446 unmap j
17117
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1447 endfunc
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1448
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1449 func Test_popup_menu_screenshot()
17680
55704f587945 patch 8.1.1837: popup test fails if clipboard is supported but not working
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
1450 CheckScreendump
17117
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1451
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1452 let lines =<< trim END
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1453 call setline(1, range(1, 20))
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1454 hi PopupSelected ctermbg=lightblue
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
1455 call popup_menu(['one', 'two', 'another'], #{callback: 'MenuDone', title: ' make a choice from the list '})
17117
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1456 func MenuDone(id, res)
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1457 echomsg "selected " .. a:res
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1458 endfunc
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1459 END
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1460 call writefile(lines, 'XtestPopupMenu')
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
1461 let buf = RunVimInTerminal('-S XtestPopupMenu', #{rows: 10})
17117
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1462 call VerifyScreenDump(buf, 'Test_popupwin_menu_01', {})
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1463
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1464 call term_sendkeys(buf, "jj")
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1465 call VerifyScreenDump(buf, 'Test_popupwin_menu_02', {})
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1466
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1467 call term_sendkeys(buf, " ")
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1468 call VerifyScreenDump(buf, 'Test_popupwin_menu_03', {})
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1469
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1470 " clean up
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1471 call StopVimInTerminal(buf)
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1472 call delete('XtestPopupMenu')
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1473 endfunc
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1474
17438
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1475 func Test_popup_menu_narrow()
17680
55704f587945 patch 8.1.1837: popup test fails if clipboard is supported but not working
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
1476 CheckScreendump
17438
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1477
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1478 let lines =<< trim END
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1479 call setline(1, range(1, 20))
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1480 hi PopupSelected ctermbg=green
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1481 call popup_menu(['one', 'two', 'three'], #{callback: 'MenuDone'})
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1482 func MenuDone(id, res)
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1483 echomsg "selected " .. a:res
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1484 endfunc
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1485 END
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1486 call writefile(lines, 'XtestPopupNarrowMenu')
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1487 let buf = RunVimInTerminal('-S XtestPopupNarrowMenu', #{rows: 10})
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1488 call VerifyScreenDump(buf, 'Test_popupwin_menu_04', {})
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1489
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1490 " clean up
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1491 call term_sendkeys(buf, "x")
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1492 call StopVimInTerminal(buf)
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1493 call delete('XtestPopupNarrowMenu')
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1494 endfunc
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1495
17119
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
1496 func Test_popup_title()
17680
55704f587945 patch 8.1.1837: popup test fails if clipboard is supported but not working
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
1497 CheckScreendump
17119
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
1498
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
1499 " Create a popup without title or border, a line of padding will be added to
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
1500 " put the title on.
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
1501 let lines =<< trim END
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
1502 call setline(1, range(1, 20))
17634
6e6a84993444 patch 8.1.1814: a long title in a popup window overflows
Bram Moolenaar <Bram@vim.org>
parents: 17628
diff changeset
1503 let winid = popup_create(['one', 'two', 'another'], #{title: 'Title String'})
17119
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
1504 END
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
1505 call writefile(lines, 'XtestPopupTitle')
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
1506 let buf = RunVimInTerminal('-S XtestPopupTitle', #{rows: 10})
17119
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
1507 call VerifyScreenDump(buf, 'Test_popupwin_title', {})
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
1508
17634
6e6a84993444 patch 8.1.1814: a long title in a popup window overflows
Bram Moolenaar <Bram@vim.org>
parents: 17628
diff changeset
1509 call term_sendkeys(buf, ":call popup_setoptions(winid, #{maxwidth: 20, title: 'a very long title that is not going to fit'})\<CR>")
6e6a84993444 patch 8.1.1814: a long title in a popup window overflows
Bram Moolenaar <Bram@vim.org>
parents: 17628
diff changeset
1510 call term_sendkeys(buf, ":\<CR>")
6e6a84993444 patch 8.1.1814: a long title in a popup window overflows
Bram Moolenaar <Bram@vim.org>
parents: 17628
diff changeset
1511 call VerifyScreenDump(buf, 'Test_popupwin_longtitle_1', {})
6e6a84993444 patch 8.1.1814: a long title in a popup window overflows
Bram Moolenaar <Bram@vim.org>
parents: 17628
diff changeset
1512
6e6a84993444 patch 8.1.1814: a long title in a popup window overflows
Bram Moolenaar <Bram@vim.org>
parents: 17628
diff changeset
1513 call term_sendkeys(buf, ":call popup_setoptions(winid, #{border: []})\<CR>")
6e6a84993444 patch 8.1.1814: a long title in a popup window overflows
Bram Moolenaar <Bram@vim.org>
parents: 17628
diff changeset
1514 call term_sendkeys(buf, ":\<CR>")
6e6a84993444 patch 8.1.1814: a long title in a popup window overflows
Bram Moolenaar <Bram@vim.org>
parents: 17628
diff changeset
1515 call VerifyScreenDump(buf, 'Test_popupwin_longtitle_2', {})
6e6a84993444 patch 8.1.1814: a long title in a popup window overflows
Bram Moolenaar <Bram@vim.org>
parents: 17628
diff changeset
1516
17119
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
1517 " clean up
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
1518 call StopVimInTerminal(buf)
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
1519 call delete('XtestPopupTitle')
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
1520
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
1521 let winid = popup_create('something', #{title: 'Some Title'})
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
1522 call assert_equal('Some Title', popup_getoptions(winid).title)
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
1523 call popup_setoptions(winid, #{title: 'Another Title'})
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
1524 call assert_equal('Another Title', popup_getoptions(winid).title)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
1525
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
1526 call popup_clear()
17119
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
1527 endfunc
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
1528
16890
5131023c5728 patch 8.1.1446: popup window callback not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16888
diff changeset
1529 func Test_popup_close_callback()
5131023c5728 patch 8.1.1446: popup window callback not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16888
diff changeset
1530 func PopupDone(id, result)
5131023c5728 patch 8.1.1446: popup window callback not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16888
diff changeset
1531 let g:result = a:result
5131023c5728 patch 8.1.1446: popup window callback not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16888
diff changeset
1532 endfunc
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
1533 let winid = popup_create('something', #{callback: 'PopupDone'})
16890
5131023c5728 patch 8.1.1446: popup window callback not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16888
diff changeset
1534 redraw
5131023c5728 patch 8.1.1446: popup window callback not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16888
diff changeset
1535 call popup_close(winid, 'done')
5131023c5728 patch 8.1.1446: popup window callback not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16888
diff changeset
1536 call assert_equal('done', g:result)
5131023c5728 patch 8.1.1446: popup window callback not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16888
diff changeset
1537 endfunc
16892
60c9ac14a2ec patch 8.1.1447: not allowed to create an empty popup
Bram Moolenaar <Bram@vim.org>
parents: 16890
diff changeset
1538
60c9ac14a2ec patch 8.1.1447: not allowed to create an empty popup
Bram Moolenaar <Bram@vim.org>
parents: 16890
diff changeset
1539 func Test_popup_empty()
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
1540 let winid = popup_create('', #{padding: [2,2,2,2]})
16892
60c9ac14a2ec patch 8.1.1447: not allowed to create an empty popup
Bram Moolenaar <Bram@vim.org>
parents: 16890
diff changeset
1541 redraw
60c9ac14a2ec patch 8.1.1447: not allowed to create an empty popup
Bram Moolenaar <Bram@vim.org>
parents: 16890
diff changeset
1542 let pos = popup_getpos(winid)
17107
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1543 call assert_equal(5, pos.width)
16892
60c9ac14a2ec patch 8.1.1447: not allowed to create an empty popup
Bram Moolenaar <Bram@vim.org>
parents: 16890
diff changeset
1544 call assert_equal(5, pos.height)
60c9ac14a2ec patch 8.1.1447: not allowed to create an empty popup
Bram Moolenaar <Bram@vim.org>
parents: 16890
diff changeset
1545
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
1546 let winid = popup_create([], #{border: []})
16892
60c9ac14a2ec patch 8.1.1447: not allowed to create an empty popup
Bram Moolenaar <Bram@vim.org>
parents: 16890
diff changeset
1547 redraw
60c9ac14a2ec patch 8.1.1447: not allowed to create an empty popup
Bram Moolenaar <Bram@vim.org>
parents: 16890
diff changeset
1548 let pos = popup_getpos(winid)
17107
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1549 call assert_equal(3, pos.width)
16892
60c9ac14a2ec patch 8.1.1447: not allowed to create an empty popup
Bram Moolenaar <Bram@vim.org>
parents: 16890
diff changeset
1550 call assert_equal(3, pos.height)
60c9ac14a2ec patch 8.1.1447: not allowed to create an empty popup
Bram Moolenaar <Bram@vim.org>
parents: 16890
diff changeset
1551 endfunc
16894
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1552
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1553 func Test_popup_never_behind()
17680
55704f587945 patch 8.1.1837: popup test fails if clipboard is supported but not working
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
1554 CheckScreendump
55704f587945 patch 8.1.1837: popup test fails if clipboard is supported but not working
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
1555
16894
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1556 " +-----------------------------+
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1557 " | | |
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1558 " | | |
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1559 " | | |
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1560 " | line1 |
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1561 " |------------line2------------|
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1562 " | line3 |
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1563 " | line4 |
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1564 " | |
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1565 " | |
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1566 " +-----------------------------+
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1567 let lines =<< trim END
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1568 split
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1569 vsplit
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1570 let info_window1 = getwininfo()[0]
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1571 let line = info_window1['height']
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1572 let col = info_window1['width']
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
1573 call popup_create(['line1', 'line2', 'line3', 'line4'], #{
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1574 \ line : line,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1575 \ col : col,
16894
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1576 \ })
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1577 END
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1578 call writefile(lines, 'XtestPopupBehind')
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
1579 let buf = RunVimInTerminal('-S XtestPopupBehind', #{rows: 10})
16894
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1580 call term_sendkeys(buf, "\<C-W>w")
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1581 call VerifyScreenDump(buf, 'Test_popupwin_behind', {})
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1582
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1583 " clean up
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1584 call StopVimInTerminal(buf)
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1585 call delete('XtestPopupBehind')
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1586 endfunc
16896
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1587
17551
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1588 func s:VerifyPosition(p, msg, line, col, width, height)
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1589 call assert_equal(a:line, popup_getpos(a:p).line, a:msg . ' (l)')
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1590 call assert_equal(a:col, popup_getpos(a:p).col, a:msg . ' (c)')
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1591 call assert_equal(a:width, popup_getpos(a:p).width, a:msg . ' (w)')
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1592 call assert_equal(a:height, popup_getpos(a:p).height, a:msg . ' (h)')
16896
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1593 endfunc
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1594
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1595 func Test_popup_position_adjust()
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1596 " Anything placed past 2 cells from of the right of the screen is moved to the
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1597 " left.
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1598 "
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1599 " When wrapping is disabled, we also shift to the left to display on the
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1600 " screen, unless fixed is set.
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1601
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1602 " Entries for cases which don't vary based on wrapping.
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1603 " Format is per tests described below
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1604 let both_wrap_tests = [
17551
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1605 \ ['a', 5, &columns, 5, &columns - 2, 1, 1],
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1606 \ ['b', 5, &columns + 1, 5, &columns - 2, 1, 1],
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1607 \ ['c', 5, &columns - 1, 5, &columns - 2, 1, 1],
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1608 \ ['d', 5, &columns - 2, 5, &columns - 2, 1, 1],
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1609 \ ['e', 5, &columns - 3, 5, &columns - 3, 1, 1],
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1610 \
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1611 \ ['aa', 5, &columns, 5, &columns - 2, 2, 1],
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1612 \ ['bb', 5, &columns + 1, 5, &columns - 2, 2, 1],
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1613 \ ['cc', 5, &columns - 1, 5, &columns - 2, 2, 1],
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1614 \ ['dd', 5, &columns - 2, 5, &columns - 2, 2, 1],
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1615 \ ['ee', 5, &columns - 3, 5, &columns - 3, 2, 1],
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1616 \
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1617 \ ['aaa', 5, &columns, 5, &columns - 2, 3, 1],
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1618 \ ['bbb', 5, &columns + 1, 5, &columns - 2, 3, 1],
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1619 \ ['ccc', 5, &columns - 1, 5, &columns - 2, 3, 1],
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1620 \ ['ddd', 5, &columns - 2, 5, &columns - 2, 3, 1],
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1621 \ ['eee', 5, &columns - 3, 5, &columns - 3, 3, 1],
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1622 \ ]
16896
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1623
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1624 " these test groups are dicts with:
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1625 " - comment: something to identify the group of tests by
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1626 " - options: dict of options to merge with the row/col in tests
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1627 " - tests: list of cases. Each one is a list with elements:
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1628 " - text
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1629 " - row
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1630 " - col
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1631 " - expected row
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1632 " - expected col
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1633 " - expected width
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1634 " - expected height
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1635 let tests = [
17551
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1636 \ #{
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1637 \ comment: 'left-aligned with wrapping',
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1638 \ options: #{
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1639 \ wrap: 1,
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1640 \ pos: 'botleft',
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1641 \ },
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1642 \ tests: both_wrap_tests + [
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1643 \ ['aaaa', 5, &columns, 4, &columns - 2, 3, 2],
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1644 \ ['bbbb', 5, &columns + 1, 4, &columns - 2, 3, 2],
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1645 \ ['cccc', 5, &columns - 1, 4, &columns - 2, 3, 2],
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1646 \ ['dddd', 5, &columns - 2, 4, &columns - 2, 3, 2],
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1647 \ ['eeee', 5, &columns - 3, 5, &columns - 3, 4, 1],
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1648 \ ],
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1649 \ },
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1650 \ #{
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1651 \ comment: 'left aligned without wrapping',
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1652 \ options: #{
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1653 \ wrap: 0,
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1654 \ pos: 'botleft',
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1655 \ },
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1656 \ tests: both_wrap_tests + [
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1657 \ ['aaaa', 5, &columns, 5, &columns - 3, 4, 1],
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1658 \ ['bbbb', 5, &columns + 1, 5, &columns - 3, 4, 1],
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1659 \ ['cccc', 5, &columns - 1, 5, &columns - 3, 4, 1],
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1660 \ ['dddd', 5, &columns - 2, 5, &columns - 3, 4, 1],
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1661 \ ['eeee', 5, &columns - 3, 5, &columns - 3, 4, 1],
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1662 \ ],
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1663 \ },
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1664 \ #{
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1665 \ comment: 'left aligned with fixed position',
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1666 \ options: #{
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1667 \ wrap: 0,
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1668 \ fixed: 1,
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1669 \ pos: 'botleft',
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1670 \ },
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1671 \ tests: both_wrap_tests + [
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1672 \ ['aaaa', 5, &columns, 5, &columns - 2, 3, 1],
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1673 \ ['bbbb', 5, &columns + 1, 5, &columns - 2, 3, 1],
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1674 \ ['cccc', 5, &columns - 1, 5, &columns - 2, 3, 1],
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1675 \ ['dddd', 5, &columns - 2, 5, &columns - 2, 3, 1],
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1676 \ ['eeee', 5, &columns - 3, 5, &columns - 3, 4, 1],
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1677 \ ],
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1678 \ },
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1679 \ ]
16896
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1680
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1681 for test_group in tests
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1682 for test in test_group.tests
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1683 let [ text, line, col, e_line, e_col, e_width, e_height ] = test
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
1684 let options = #{
17551
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1685 \ line: line,
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1686 \ col: col,
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1687 \ }
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1688 call extend(options, test_group.options)
16896
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1689
17551
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1690 let p = popup_create(text, options)
16896
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1691
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
1692 let msg = string(extend(options, #{text: text}))
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1693 call s:VerifyPosition(p, msg, e_line, e_col, e_width, e_height)
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1694 call popup_close(p)
16896
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1695 endfor
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1696 endfor
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1697
17026
905e1b154058 patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents: 17022
diff changeset
1698 call popup_clear()
16896
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1699 %bwipe!
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1700 endfunc
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1701
16904
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1702 func Test_adjust_left_past_screen_width()
16896
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1703 " width of screen
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1704 let X = join(map(range(&columns), {->'X'}), '')
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1705
17551
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1706 let p = popup_create(X, #{line: 1, col: 1, wrap: 0})
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1707 call s:VerifyPosition(p, 'full width topleft', 1, 1, &columns, 1)
16896
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1708
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1709 redraw
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1710 let line = join(map(range(1, &columns + 1), 'screenstring(1, v:val)'), '')
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1711 call assert_equal(X, line)
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1712
17551
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1713 call popup_close(p)
16896
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1714 redraw
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1715
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1716 " Same if placed on the right hand side
17551
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1717 let p = popup_create(X, #{line: 1, col: &columns, wrap: 0})
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1718 call s:VerifyPosition(p, 'full width topright', 1, 1, &columns, 1)
16896
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1719
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1720 redraw
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1721 let line = join(map(range(1, &columns + 1), 'screenstring(1, v:val)'), '')
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1722 call assert_equal(X, line)
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1723
17551
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1724 call popup_close(p)
16896
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1725 redraw
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1726
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1727 " Extend so > window width
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1728 let X .= 'x'
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1729
17551
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1730 let p = popup_create(X, #{line: 1, col: 1, wrap: 0})
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1731 call s:VerifyPosition(p, 'full width + 1 topleft', 1, 1, &columns, 1)
16896
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1732
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1733 redraw
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1734 let line = join(map(range(1, &columns + 1), 'screenstring(1, v:val)'), '')
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1735 call assert_equal(X[ : -2 ], line)
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1736
17551
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1737 call popup_close(p)
16896
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1738 redraw
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1739
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1740 " Shifted then truncated (the x is not visible)
17551
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1741 let p = popup_create(X, #{line: 1, col: &columns - 3, wrap: 0})
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1742 call s:VerifyPosition(p, 'full width + 1 topright', 1, 1, &columns, 1)
16896
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1743
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1744 redraw
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1745 let line = join(map(range(1, &columns + 1), 'screenstring(1, v:val)'), '')
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1746 call assert_equal(X[ : -2 ], line)
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1747
17551
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1748 call popup_close(p)
16896
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1749 redraw
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1750
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1751 " Not shifted, just truncated
17551
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1752 let p = popup_create(X,
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1753 \ #{line: 1, col: 2, wrap: 0, fixed: 1})
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1754 call s:VerifyPosition(p, 'full width + 1 fixed', 1, 2, &columns - 1, 1)
16896
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1755
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1756 redraw
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1757 let line = join(map(range(1, &columns + 1), 'screenstring(1, v:val)'), '')
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1758 let e_line = ' ' . X[ 1 : -2 ]
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1759 call assert_equal(e_line, line)
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1760
17551
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
1761 call popup_close(p)
16896
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1762 redraw
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1763
17026
905e1b154058 patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents: 17022
diff changeset
1764 call popup_clear()
16896
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1765 %bwipe!
16904
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1766 endfunc
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1767
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1768 func Test_popup_moved()
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1769 new
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1770 call test_override('char_avail', 1)
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1771 call setline(1, ['one word to move around', 'a WORD.and->some thing'])
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1772
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1773 exe "normal gg0/word\<CR>"
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
1774 let winid = popup_atcursor('text', #{moved: 'any'})
16904
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1775 redraw
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1776 call assert_equal(1, popup_getpos(winid).visible)
17292
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1777 call assert_equal([1, 4, 4], popup_getoptions(winid).moved)
16904
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1778 " trigger the check for last_cursormoved by going into insert mode
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1779 call feedkeys("li\<Esc>", 'xt')
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1780 call assert_equal({}, popup_getpos(winid))
17026
905e1b154058 patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents: 17022
diff changeset
1781 call popup_clear()
16904
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1782
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1783 exe "normal gg0/word\<CR>"
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
1784 let winid = popup_atcursor('text', #{moved: 'word'})
16904
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1785 redraw
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1786 call assert_equal(1, popup_getpos(winid).visible)
17292
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1787 call assert_equal([1, 4, 7], popup_getoptions(winid).moved)
16904
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1788 call feedkeys("hi\<Esc>", 'xt')
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1789 call assert_equal({}, popup_getpos(winid))
17026
905e1b154058 patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents: 17022
diff changeset
1790 call popup_clear()
16904
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1791
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1792 exe "normal gg0/word\<CR>"
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
1793 let winid = popup_atcursor('text', #{moved: 'word'})
16904
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1794 redraw
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1795 call assert_equal(1, popup_getpos(winid).visible)
17292
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1796 call assert_equal([1, 4, 7], popup_getoptions(winid).moved)
16904
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1797 call feedkeys("li\<Esc>", 'xt')
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1798 call assert_equal(1, popup_getpos(winid).visible)
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1799 call feedkeys("ei\<Esc>", 'xt')
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1800 call assert_equal(1, popup_getpos(winid).visible)
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1801 call feedkeys("eli\<Esc>", 'xt')
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1802 call assert_equal({}, popup_getpos(winid))
17026
905e1b154058 patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents: 17022
diff changeset
1803 call popup_clear()
16904
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1804
16908
df06694b761b patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents: 16904
diff changeset
1805 " WORD is the default
16904
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1806 exe "normal gg0/WORD\<CR>"
16908
df06694b761b patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents: 16904
diff changeset
1807 let winid = popup_atcursor('text', {})
16904
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1808 redraw
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1809 call assert_equal(1, popup_getpos(winid).visible)
17292
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1810 call assert_equal([2, 2, 15], popup_getoptions(winid).moved)
16904
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1811 call feedkeys("eli\<Esc>", 'xt')
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1812 call assert_equal(1, popup_getpos(winid).visible)
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1813 call feedkeys("wi\<Esc>", 'xt')
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1814 call assert_equal(1, popup_getpos(winid).visible)
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1815 call feedkeys("Eli\<Esc>", 'xt')
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1816 call assert_equal({}, popup_getpos(winid))
17026
905e1b154058 patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents: 17022
diff changeset
1817 call popup_clear()
16904
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1818
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1819 exe "normal gg0/word\<CR>"
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
1820 let winid = popup_atcursor('text', #{moved: [5, 10]})
16904
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1821 redraw
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1822 call assert_equal(1, popup_getpos(winid).visible)
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1823 call feedkeys("eli\<Esc>", 'xt')
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1824 call feedkeys("ei\<Esc>", 'xt')
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1825 call assert_equal(1, popup_getpos(winid).visible)
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1826 call feedkeys("eli\<Esc>", 'xt')
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1827 call assert_equal({}, popup_getpos(winid))
17026
905e1b154058 patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents: 17022
diff changeset
1828 call popup_clear()
16904
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1829
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1830 bwipe!
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1831 call test_override('ALL', 0)
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1832 endfunc
17045
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17043
diff changeset
1833
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17043
diff changeset
1834 func Test_notifications()
17680
55704f587945 patch 8.1.1837: popup test fails if clipboard is supported but not working
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
1835 CheckFeature timers
55704f587945 patch 8.1.1837: popup test fails if clipboard is supported but not working
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
1836 CheckScreendump
17045
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17043
diff changeset
1837
17920
233e316c0b5a patch 8.1.1956: screenshot tests may use a different encoding
Bram Moolenaar <Bram@vim.org>
parents: 17918
diff changeset
1838 let lines =<< trim END
233e316c0b5a patch 8.1.1956: screenshot tests may use a different encoding
Bram Moolenaar <Bram@vim.org>
parents: 17918
diff changeset
1839 call setline(1, range(1, 20))
233e316c0b5a patch 8.1.1956: screenshot tests may use a different encoding
Bram Moolenaar <Bram@vim.org>
parents: 17918
diff changeset
1840 hi Notification ctermbg=lightblue
233e316c0b5a patch 8.1.1956: screenshot tests may use a different encoding
Bram Moolenaar <Bram@vim.org>
parents: 17918
diff changeset
1841 call popup_notification('first notification', {})
233e316c0b5a patch 8.1.1956: screenshot tests may use a different encoding
Bram Moolenaar <Bram@vim.org>
parents: 17918
diff changeset
1842 END
233e316c0b5a patch 8.1.1956: screenshot tests may use a different encoding
Bram Moolenaar <Bram@vim.org>
parents: 17918
diff changeset
1843 call writefile(lines, 'XtestNotifications')
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
1844 let buf = RunVimInTerminal('-S XtestNotifications', #{rows: 10})
17045
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17043
diff changeset
1845 call VerifyScreenDump(buf, 'Test_popupwin_notify_01', {})
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17043
diff changeset
1846
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17043
diff changeset
1847 " second one goes below the first one
17077
2546930657a9 patch 8.1.1538: cannot specify highlighting for notifications
Bram Moolenaar <Bram@vim.org>
parents: 17075
diff changeset
1848 call term_sendkeys(buf, ":hi link PopupNotification Notification\<CR>")
2546930657a9 patch 8.1.1538: cannot specify highlighting for notifications
Bram Moolenaar <Bram@vim.org>
parents: 17075
diff changeset
1849 call term_sendkeys(buf, ":call popup_notification('another important notification', {})\<CR>")
17045
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17043
diff changeset
1850 call VerifyScreenDump(buf, 'Test_popupwin_notify_02', {})
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17043
diff changeset
1851
17180
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1852 " clean up
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1853 call StopVimInTerminal(buf)
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1854 call delete('XtestNotifications')
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1855 endfunc
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1856
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1857 func Test_popup_scrollbar()
17680
55704f587945 patch 8.1.1837: popup test fails if clipboard is supported but not working
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
1858 CheckScreendump
17180
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1859
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1860 let lines =<< trim END
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1861 call setline(1, range(1, 20))
17204
1a6ccc91ed46 patch 8.1.1601: missing changes to popup window test file
Bram Moolenaar <Bram@vim.org>
parents: 17198
diff changeset
1862 hi ScrollThumb ctermbg=blue
1a6ccc91ed46 patch 8.1.1601: missing changes to popup window test file
Bram Moolenaar <Bram@vim.org>
parents: 17198
diff changeset
1863 hi ScrollBar ctermbg=red
17180
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1864 let winid = popup_create(['one', 'two', 'three', 'four', 'five',
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
1865 \ 'six', 'seven', 'eight', 'nine'], #{
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1866 \ minwidth: 8,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1867 \ maxheight: 4,
17180
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1868 \ })
17198
4c009ec23c0a patch 8.1.1598: update to test file missing
Bram Moolenaar <Bram@vim.org>
parents: 17182
diff changeset
1869 func ScrollUp()
4c009ec23c0a patch 8.1.1598: update to test file missing
Bram Moolenaar <Bram@vim.org>
parents: 17182
diff changeset
1870 call feedkeys("\<F3>\<ScrollWheelUp>", "xt")
4c009ec23c0a patch 8.1.1598: update to test file missing
Bram Moolenaar <Bram@vim.org>
parents: 17182
diff changeset
1871 endfunc
4c009ec23c0a patch 8.1.1598: update to test file missing
Bram Moolenaar <Bram@vim.org>
parents: 17182
diff changeset
1872 func ScrollDown()
4c009ec23c0a patch 8.1.1598: update to test file missing
Bram Moolenaar <Bram@vim.org>
parents: 17182
diff changeset
1873 call feedkeys("\<F3>\<ScrollWheelDown>", "xt")
4c009ec23c0a patch 8.1.1598: update to test file missing
Bram Moolenaar <Bram@vim.org>
parents: 17182
diff changeset
1874 endfunc
17216
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17210
diff changeset
1875 func ClickTop()
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17210
diff changeset
1876 call feedkeys("\<F4>\<LeftMouse>", "xt")
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17210
diff changeset
1877 endfunc
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17210
diff changeset
1878 func ClickBot()
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
1879 call popup_setoptions(g:winid, #{border: [], close: 'button'})
17216
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17210
diff changeset
1880 call feedkeys("\<F5>\<LeftMouse>", "xt")
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17210
diff changeset
1881 endfunc
18492
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1882 func Popup_filter(winid, key)
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1883 if a:key == 'j'
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1884 let line = popup_getoptions(a:winid).firstline
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1885 let nlines = line('$', a:winid)
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1886 let newline = line < nlines ? (line + 1) : nlines
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1887 call popup_setoptions(a:winid, #{firstline: newline})
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1888 return v:true
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1889 elseif a:key == 'x'
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1890 call popup_close(a:winid)
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1891 return v:true
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1892 endif
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1893 endfunc
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1894
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1895 func PopupScroll()
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1896 call popup_clear()
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1897 let text =<< trim END
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1898 1
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1899 2
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1900 3
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1901 4
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1902 long line long line long line long line long line long line
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1903 long line long line long line long line long line long line
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1904 long line long line long line long line long line long line
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1905 END
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1906 call popup_create(text, #{
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1907 \ minwidth: 30,
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1908 \ maxwidth: 30,
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1909 \ minheight: 4,
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1910 \ maxheight: 4,
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1911 \ firstline: 1,
18512
e855058e0c23 patch 8.1.2250: CTRL-U and CTRL-D don't work in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18494
diff changeset
1912 \ lastline: 4,
18492
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1913 \ wrap: v:true,
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1914 \ scrollbar: v:true,
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1915 \ mapping: v:false,
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1916 \ filter: funcref('Popup_filter')
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1917 \ })
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1918 endfunc
17198
4c009ec23c0a patch 8.1.1598: update to test file missing
Bram Moolenaar <Bram@vim.org>
parents: 17182
diff changeset
1919 map <silent> <F3> :call test_setmouse(5, 36)<CR>
17216
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17210
diff changeset
1920 map <silent> <F4> :call test_setmouse(4, 42)<CR>
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17210
diff changeset
1921 map <silent> <F5> :call test_setmouse(7, 42)<CR>
17180
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1922 END
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1923 call writefile(lines, 'XtestPopupScroll')
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
1924 let buf = RunVimInTerminal('-S XtestPopupScroll', #{rows: 10})
17180
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1925 call VerifyScreenDump(buf, 'Test_popupwin_scroll_1', {})
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1926
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
1927 call term_sendkeys(buf, ":call popup_setoptions(winid, #{firstline: 2})\<CR>")
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1928 call term_sendkeys(buf, ":\<CR>")
17180
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1929 call VerifyScreenDump(buf, 'Test_popupwin_scroll_2', {})
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1930
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
1931 call term_sendkeys(buf, ":call popup_setoptions(winid, #{firstline: 6})\<CR>")
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1932 call term_sendkeys(buf, ":\<CR>")
17180
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1933 call VerifyScreenDump(buf, 'Test_popupwin_scroll_3', {})
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1934
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
1935 call term_sendkeys(buf, ":call popup_setoptions(winid, #{firstline: 9})\<CR>")
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1936 call term_sendkeys(buf, ":\<CR>")
17180
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1937 call VerifyScreenDump(buf, 'Test_popupwin_scroll_4', {})
17045
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17043
diff changeset
1938
17897
fa032e079825 patch 8.1.1945: popup window "firstline" cannot be reset
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1939 call term_sendkeys(buf, ":call popup_setoptions(winid, #{scrollbarhighlight: 'ScrollBar', thumbhighlight: 'ScrollThumb', firstline: 5})\<CR>")
17926
ad7a4bd65f20 patch 8.1.1959: when using "firstline" in popup window text may jump
Bram Moolenaar <Bram@vim.org>
parents: 17920
diff changeset
1940 " this scrolls two lines (half the window height)
17198
4c009ec23c0a patch 8.1.1598: update to test file missing
Bram Moolenaar <Bram@vim.org>
parents: 17182
diff changeset
1941 call term_sendkeys(buf, ":call ScrollUp()\<CR>")
4c009ec23c0a patch 8.1.1598: update to test file missing
Bram Moolenaar <Bram@vim.org>
parents: 17182
diff changeset
1942 call VerifyScreenDump(buf, 'Test_popupwin_scroll_5', {})
4c009ec23c0a patch 8.1.1598: update to test file missing
Bram Moolenaar <Bram@vim.org>
parents: 17182
diff changeset
1943
4c009ec23c0a patch 8.1.1598: update to test file missing
Bram Moolenaar <Bram@vim.org>
parents: 17182
diff changeset
1944 call term_sendkeys(buf, ":call ScrollDown()\<CR>")
4c009ec23c0a patch 8.1.1598: update to test file missing
Bram Moolenaar <Bram@vim.org>
parents: 17182
diff changeset
1945 call VerifyScreenDump(buf, 'Test_popupwin_scroll_6', {})
4c009ec23c0a patch 8.1.1598: update to test file missing
Bram Moolenaar <Bram@vim.org>
parents: 17182
diff changeset
1946
4c009ec23c0a patch 8.1.1598: update to test file missing
Bram Moolenaar <Bram@vim.org>
parents: 17182
diff changeset
1947 call term_sendkeys(buf, ":call ScrollDown()\<CR>")
17210
175941dcc96b patch 8.1.1604: popup window scroll test is flaky
Bram Moolenaar <Bram@vim.org>
parents: 17204
diff changeset
1948 " wait a bit, otherwise it fails sometimes (double click recognized?)
175941dcc96b patch 8.1.1604: popup window scroll test is flaky
Bram Moolenaar <Bram@vim.org>
parents: 17204
diff changeset
1949 sleep 100m
17198
4c009ec23c0a patch 8.1.1598: update to test file missing
Bram Moolenaar <Bram@vim.org>
parents: 17182
diff changeset
1950 call term_sendkeys(buf, ":call ScrollDown()\<CR>")
4c009ec23c0a patch 8.1.1598: update to test file missing
Bram Moolenaar <Bram@vim.org>
parents: 17182
diff changeset
1951 call VerifyScreenDump(buf, 'Test_popupwin_scroll_7', {})
4c009ec23c0a patch 8.1.1598: update to test file missing
Bram Moolenaar <Bram@vim.org>
parents: 17182
diff changeset
1952
17216
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17210
diff changeset
1953 call term_sendkeys(buf, ":call ClickTop()\<CR>")
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17210
diff changeset
1954 sleep 100m
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17210
diff changeset
1955 call term_sendkeys(buf, ":call ClickTop()\<CR>")
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17210
diff changeset
1956 call VerifyScreenDump(buf, 'Test_popupwin_scroll_8', {})
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17210
diff changeset
1957
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17210
diff changeset
1958 call term_sendkeys(buf, ":call ClickBot()\<CR>")
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17210
diff changeset
1959 call VerifyScreenDump(buf, 'Test_popupwin_scroll_9', {})
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17210
diff changeset
1960
17905
fb773f73a4be patch 8.1.1949: cannot scroll a popup window to the very bottom
Bram Moolenaar <Bram@vim.org>
parents: 17897
diff changeset
1961 " remove the minwidth and maxheight
fb773f73a4be patch 8.1.1949: cannot scroll a popup window to the very bottom
Bram Moolenaar <Bram@vim.org>
parents: 17897
diff changeset
1962 call term_sendkeys(buf, ":call popup_setoptions(winid, #{maxheight: 0, minwidth: 0})\<CR>")
18110
6a6c4536ea4c patch 8.1.2050: popup window test fails in some configurations
Bram Moolenaar <Bram@vim.org>
parents: 18088
diff changeset
1963 call term_sendkeys(buf, ":\<CR>")
17905
fb773f73a4be patch 8.1.1949: cannot scroll a popup window to the very bottom
Bram Moolenaar <Bram@vim.org>
parents: 17897
diff changeset
1964 call VerifyScreenDump(buf, 'Test_popupwin_scroll_10', {})
fb773f73a4be patch 8.1.1949: cannot scroll a popup window to the very bottom
Bram Moolenaar <Bram@vim.org>
parents: 17897
diff changeset
1965
18492
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1966 " check size with non-wrapping lines
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1967 call term_sendkeys(buf, ":call PopupScroll()\<CR>")
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1968 call VerifyScreenDump(buf, 'Test_popupwin_scroll_11', {})
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1969
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1970 " check size with wrapping lines
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1971 call term_sendkeys(buf, "j")
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1972 call VerifyScreenDump(buf, 'Test_popupwin_scroll_12', {})
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1973 call term_sendkeys(buf, "x")
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1974
17045
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17043
diff changeset
1975 " clean up
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17043
diff changeset
1976 call StopVimInTerminal(buf)
17180
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1977 call delete('XtestPopupScroll')
17045
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17043
diff changeset
1978 endfunc
17107
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1979
17274
6a7ba68d448e patch 8.1.1636: crash when popup has fitting scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17253
diff changeset
1980 func Test_popup_fitting_scrollbar()
6a7ba68d448e patch 8.1.1636: crash when popup has fitting scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17253
diff changeset
1981 " this was causing a crash, divide by zero
6a7ba68d448e patch 8.1.1636: crash when popup has fitting scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17253
diff changeset
1982 let winid = popup_create([
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
1983 \ 'one', 'two', 'longer line that wraps', 'four', 'five'], #{
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1984 \ scrollbar: 1,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1985 \ maxwidth: 10,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1986 \ maxheight: 5,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1987 \ firstline: 2})
17274
6a7ba68d448e patch 8.1.1636: crash when popup has fitting scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17253
diff changeset
1988 redraw
6a7ba68d448e patch 8.1.1636: crash when popup has fitting scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17253
diff changeset
1989 call popup_clear()
6a7ba68d448e patch 8.1.1636: crash when popup has fitting scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17253
diff changeset
1990 endfunc
6a7ba68d448e patch 8.1.1636: crash when popup has fitting scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17253
diff changeset
1991
17121
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
1992 func Test_popup_settext()
17680
55704f587945 patch 8.1.1837: popup test fails if clipboard is supported but not working
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
1993 CheckScreendump
17107
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1994
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1995 let lines =<< trim END
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
1996 let opts = #{wrap: 0}
17107
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1997 let p = popup_create('test', opts)
17972
a170c48e0f91 patch 8.1.1982: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17946
diff changeset
1998 eval p->popup_settext('this is a text')
17107
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1999 END
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
2000
17551
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
2001 call writefile(lines, 'XtestPopupSetText')
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
2002 let buf = RunVimInTerminal('-S XtestPopupSetText', #{rows: 10})
17107
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
2003 call VerifyScreenDump(buf, 'Test_popup_settext_01', {})
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
2004
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
2005 " Setting to empty string clears it
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
2006 call term_sendkeys(buf, ":call popup_settext(p, '')\<CR>")
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
2007 call VerifyScreenDump(buf, 'Test_popup_settext_02', {})
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
2008
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
2009 " Setting a list
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
2010 call term_sendkeys(buf, ":call popup_settext(p, ['a','b','c'])\<CR>")
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
2011 call VerifyScreenDump(buf, 'Test_popup_settext_03', {})
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
2012
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
2013 " Shrinking with a list
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
2014 call term_sendkeys(buf, ":call popup_settext(p, ['a'])\<CR>")
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
2015 call VerifyScreenDump(buf, 'Test_popup_settext_04', {})
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
2016
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
2017 " Growing with a list
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
2018 call term_sendkeys(buf, ":call popup_settext(p, ['a','b','c'])\<CR>")
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
2019 call VerifyScreenDump(buf, 'Test_popup_settext_03', {})
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
2020
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
2021 " Empty list clears
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
2022 call term_sendkeys(buf, ":call popup_settext(p, [])\<CR>")
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
2023 call VerifyScreenDump(buf, 'Test_popup_settext_05', {})
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
2024
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
2025 " Dicts
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
2026 call term_sendkeys(buf, ":call popup_settext(p, [#{text: 'aaaa'}, #{text: 'bbbb'}, #{text: 'cccc'}])\<CR>")
17107
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
2027 call VerifyScreenDump(buf, 'Test_popup_settext_06', {})
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
2028
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
2029 " clean up
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
2030 call StopVimInTerminal(buf)
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
2031 call delete('XtestPopupSetText')
17121
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
2032 endfunc
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
2033
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
2034 func Test_popup_hidden()
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
2035 new
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
2036
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
2037 let winid = popup_atcursor('text', #{hidden: 1})
17121
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
2038 redraw
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
2039 call assert_equal(0, popup_getpos(winid).visible)
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
2040 call popup_close(winid)
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
2041
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
2042 let winid = popup_create('text', #{hidden: 1})
17121
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
2043 redraw
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
2044 call assert_equal(0, popup_getpos(winid).visible)
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
2045 call popup_close(winid)
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
2046
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
2047 func QuitCallback(id, res)
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
2048 let s:cb_winid = a:id
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
2049 let s:cb_res = a:res
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
2050 endfunc
17972
a170c48e0f91 patch 8.1.1982: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17946
diff changeset
2051 let winid = 'make a choice'->popup_dialog(#{hidden: 1,
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
2052 \ filter: 'popup_filter_yesno',
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
2053 \ callback: 'QuitCallback',
17121
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
2054 \ })
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
2055 redraw
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
2056 call assert_equal(0, popup_getpos(winid).visible)
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2057 call assert_equal(function('popup_filter_yesno'), popup_getoptions(winid).filter)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2058 call assert_equal(function('QuitCallback'), popup_getoptions(winid).callback)
17121
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
2059 exe "normal anot used by filter\<Esc>"
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
2060 call assert_equal('not used by filter', getline(1))
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
2061
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
2062 call popup_show(winid)
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
2063 call feedkeys('y', "xt")
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
2064 call assert_equal(1, s:cb_res)
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
2065
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
2066 bwipe!
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
2067 delfunc QuitCallback
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
2068 endfunc
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2069
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2070 " Test options not checked elsewhere
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2071 func Test_set_get_options()
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
2072 let winid = popup_create('some text', #{highlight: 'Beautiful'})
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2073 let options = popup_getoptions(winid)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2074 call assert_equal(1, options.wrap)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2075 call assert_equal(0, options.drag)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2076 call assert_equal('Beautiful', options.highlight)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2077
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
2078 call popup_setoptions(winid, #{wrap: 0, drag: 1, highlight: 'Another'})
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2079 let options = popup_getoptions(winid)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2080 call assert_equal(0, options.wrap)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2081 call assert_equal(1, options.drag)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2082 call assert_equal('Another', options.highlight)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2083
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2084 call popup_close(winid)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2085 endfunc
17151
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
2086
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
2087 func Test_popupwin_garbage_collect()
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
2088 func MyPopupFilter(x, winid, c)
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
2089 " NOP
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
2090 endfunc
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
2091
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
2092 let winid = popup_create('something', #{filter: function('MyPopupFilter', [{}])})
17151
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
2093 call test_garbagecollect_now()
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
2094 redraw
17918
9606c0adc148 patch 8.1.1955: tests contain typos
Bram Moolenaar <Bram@vim.org>
parents: 17905
diff changeset
2095 " Must not crash caused by invalid memory access
17151
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
2096 call feedkeys('j', 'xt')
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
2097 call assert_true(v:true)
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
2098
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
2099 call popup_close(winid)
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
2100 delfunc MyPopupFilter
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
2101 endfunc
17225
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
2102
17946
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2103 func Test_popupwin_filter_mode()
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2104 func MyPopupFilter(winid, c)
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2105 let s:typed = a:c
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2106 if a:c == ':' || a:c == "\r" || a:c == 'v'
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2107 " can start cmdline mode, get out, and start/stop Visual mode
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2108 return 0
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2109 endif
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2110 return 1
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2111 endfunc
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2112
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2113 " Normal, Visual and Insert mode
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2114 let winid = popup_create('something', #{filter: 'MyPopupFilter', filtermode: 'nvi'})
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2115 redraw
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2116 call feedkeys('x', 'xt')
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2117 call assert_equal('x', s:typed)
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2118
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2119 call feedkeys(":let g:foo = 'foo'\<CR>", 'xt')
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2120 call assert_equal(':', s:typed)
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2121 call assert_equal('foo', g:foo)
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2122
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2123 let @x = 'something'
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2124 call feedkeys('v$"xy', 'xt')
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2125 call assert_equal('y', s:typed)
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2126 call assert_equal('something', @x) " yank command is filtered out
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2127 call feedkeys('v', 'xt') " end Visual mode
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2128
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2129 call popup_close(winid)
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2130
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2131 " only Normal mode
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2132 let winid = popup_create('something', #{filter: 'MyPopupFilter', filtermode: 'n'})
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2133 redraw
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2134 call feedkeys('x', 'xt')
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2135 call assert_equal('x', s:typed)
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2136
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2137 call feedkeys(":let g:foo = 'foo'\<CR>", 'xt')
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2138 call assert_equal(':', s:typed)
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2139 call assert_equal('foo', g:foo)
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2140
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2141 let @x = 'something'
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2142 call feedkeys('v$"xy', 'xt')
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2143 call assert_equal('v', s:typed)
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2144 call assert_notequal('something', @x)
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2145
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2146 call popup_close(winid)
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2147
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2148 " default: all modes
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2149 let winid = popup_create('something', #{filter: 'MyPopupFilter'})
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2150 redraw
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2151 call feedkeys('x', 'xt')
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2152 call assert_equal('x', s:typed)
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2153
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2154 let g:foo = 'bar'
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2155 call feedkeys(":let g:foo = 'foo'\<CR>", 'xt')
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2156 call assert_equal("\r", s:typed)
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2157 call assert_equal('bar', g:foo)
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2158
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2159 let @x = 'something'
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2160 call feedkeys('v$"xy', 'xt')
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2161 call assert_equal('y', s:typed)
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2162 call assert_equal('something', @x) " yank command is filtered out
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2163 call feedkeys('v', 'xt') " end Visual mode
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2164
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2165 call popup_close(winid)
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2166 delfunc MyPopupFilter
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2167 endfunc
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
2168
18544
a6dbbedddce1 patch 8.1.2266: position unknown for a mouse click in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18542
diff changeset
2169 func Test_popupwin_filter_mouse()
a6dbbedddce1 patch 8.1.2266: position unknown for a mouse click in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18542
diff changeset
2170 func MyPopupFilter(winid, c)
a6dbbedddce1 patch 8.1.2266: position unknown for a mouse click in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18542
diff changeset
2171 let g:got_mouse_col = v:mouse_col
a6dbbedddce1 patch 8.1.2266: position unknown for a mouse click in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18542
diff changeset
2172 let g:got_mouse_lnum = v:mouse_lnum
a6dbbedddce1 patch 8.1.2266: position unknown for a mouse click in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18542
diff changeset
2173 return 0
a6dbbedddce1 patch 8.1.2266: position unknown for a mouse click in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18542
diff changeset
2174 endfunc
a6dbbedddce1 patch 8.1.2266: position unknown for a mouse click in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18542
diff changeset
2175
a6dbbedddce1 patch 8.1.2266: position unknown for a mouse click in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18542
diff changeset
2176 let winid = popup_create(['short', 'long line that will wrap', 'short'], #{
a6dbbedddce1 patch 8.1.2266: position unknown for a mouse click in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18542
diff changeset
2177 \ line: 4,
a6dbbedddce1 patch 8.1.2266: position unknown for a mouse click in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18542
diff changeset
2178 \ col: 8,
a6dbbedddce1 patch 8.1.2266: position unknown for a mouse click in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18542
diff changeset
2179 \ maxwidth: 12,
a6dbbedddce1 patch 8.1.2266: position unknown for a mouse click in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18542
diff changeset
2180 \ filter: 'MyPopupFilter',
a6dbbedddce1 patch 8.1.2266: position unknown for a mouse click in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18542
diff changeset
2181 \ })
a6dbbedddce1 patch 8.1.2266: position unknown for a mouse click in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18542
diff changeset
2182 redraw
a6dbbedddce1 patch 8.1.2266: position unknown for a mouse click in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18542
diff changeset
2183 call test_setmouse(4, 8)
a6dbbedddce1 patch 8.1.2266: position unknown for a mouse click in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18542
diff changeset
2184 call feedkeys("\<LeftMouse>", 'xt')
a6dbbedddce1 patch 8.1.2266: position unknown for a mouse click in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18542
diff changeset
2185 call assert_equal(1, g:got_mouse_col)
a6dbbedddce1 patch 8.1.2266: position unknown for a mouse click in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18542
diff changeset
2186 call assert_equal(1, g:got_mouse_lnum)
a6dbbedddce1 patch 8.1.2266: position unknown for a mouse click in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18542
diff changeset
2187
a6dbbedddce1 patch 8.1.2266: position unknown for a mouse click in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18542
diff changeset
2188 call test_setmouse(5, 8)
a6dbbedddce1 patch 8.1.2266: position unknown for a mouse click in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18542
diff changeset
2189 call feedkeys("\<LeftMouse>", 'xt')
a6dbbedddce1 patch 8.1.2266: position unknown for a mouse click in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18542
diff changeset
2190 call assert_equal(1, g:got_mouse_col)
a6dbbedddce1 patch 8.1.2266: position unknown for a mouse click in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18542
diff changeset
2191 call assert_equal(2, g:got_mouse_lnum)
a6dbbedddce1 patch 8.1.2266: position unknown for a mouse click in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18542
diff changeset
2192
a6dbbedddce1 patch 8.1.2266: position unknown for a mouse click in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18542
diff changeset
2193 call test_setmouse(6, 8)
a6dbbedddce1 patch 8.1.2266: position unknown for a mouse click in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18542
diff changeset
2194 call feedkeys("\<LeftMouse>", 'xt')
a6dbbedddce1 patch 8.1.2266: position unknown for a mouse click in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18542
diff changeset
2195 call assert_equal(13, g:got_mouse_col)
a6dbbedddce1 patch 8.1.2266: position unknown for a mouse click in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18542
diff changeset
2196 call assert_equal(2, g:got_mouse_lnum)
a6dbbedddce1 patch 8.1.2266: position unknown for a mouse click in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18542
diff changeset
2197
a6dbbedddce1 patch 8.1.2266: position unknown for a mouse click in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18542
diff changeset
2198 call test_setmouse(7, 20)
a6dbbedddce1 patch 8.1.2266: position unknown for a mouse click in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18542
diff changeset
2199 call feedkeys("\<LeftMouse>", 'xt')
a6dbbedddce1 patch 8.1.2266: position unknown for a mouse click in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18542
diff changeset
2200 call assert_equal(13, g:got_mouse_col)
a6dbbedddce1 patch 8.1.2266: position unknown for a mouse click in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18542
diff changeset
2201 call assert_equal(3, g:got_mouse_lnum)
a6dbbedddce1 patch 8.1.2266: position unknown for a mouse click in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18542
diff changeset
2202
a6dbbedddce1 patch 8.1.2266: position unknown for a mouse click in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18542
diff changeset
2203 call popup_close(winid)
a6dbbedddce1 patch 8.1.2266: position unknown for a mouse click in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18542
diff changeset
2204 delfunc MyPopupFilter
a6dbbedddce1 patch 8.1.2266: position unknown for a mouse click in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18542
diff changeset
2205 endfunc
a6dbbedddce1 patch 8.1.2266: position unknown for a mouse click in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18542
diff changeset
2206
17225
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
2207 func Test_popupwin_with_buffer()
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
2208 call writefile(['some text', 'in a buffer'], 'XsomeFile')
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
2209 let buf = bufadd('XsomeFile')
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
2210 call assert_equal(0, bufloaded(buf))
17845
b6acc24df7de patch 8.1.1919: using window options when passing a buffer to popup_create()
Bram Moolenaar <Bram@vim.org>
parents: 17841
diff changeset
2211
b6acc24df7de patch 8.1.1919: using window options when passing a buffer to popup_create()
Bram Moolenaar <Bram@vim.org>
parents: 17841
diff changeset
2212 setlocal number
b6acc24df7de patch 8.1.1919: using window options when passing a buffer to popup_create()
Bram Moolenaar <Bram@vim.org>
parents: 17841
diff changeset
2213 call setbufvar(buf, "&wrapmargin", 13)
b6acc24df7de patch 8.1.1919: using window options when passing a buffer to popup_create()
Bram Moolenaar <Bram@vim.org>
parents: 17841
diff changeset
2214
17225
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
2215 let winid = popup_create(buf, {})
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
2216 call assert_notequal(0, winid)
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
2217 let pos = popup_getpos(winid)
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
2218 call assert_equal(2, pos.height)
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
2219 call assert_equal(1, bufloaded(buf))
17845
b6acc24df7de patch 8.1.1919: using window options when passing a buffer to popup_create()
Bram Moolenaar <Bram@vim.org>
parents: 17841
diff changeset
2220
b6acc24df7de patch 8.1.1919: using window options when passing a buffer to popup_create()
Bram Moolenaar <Bram@vim.org>
parents: 17841
diff changeset
2221 " window-local option is set to default, buffer-local is not
b6acc24df7de patch 8.1.1919: using window options when passing a buffer to popup_create()
Bram Moolenaar <Bram@vim.org>
parents: 17841
diff changeset
2222 call assert_equal(0, getwinvar(winid, '&number'))
b6acc24df7de patch 8.1.1919: using window options when passing a buffer to popup_create()
Bram Moolenaar <Bram@vim.org>
parents: 17841
diff changeset
2223 call assert_equal(13, getbufvar(buf, '&wrapmargin'))
b6acc24df7de patch 8.1.1919: using window options when passing a buffer to popup_create()
Bram Moolenaar <Bram@vim.org>
parents: 17841
diff changeset
2224
17225
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
2225 call popup_close(winid)
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
2226 call assert_equal({}, popup_getpos(winid))
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
2227 call assert_equal(1, bufloaded(buf))
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
2228 exe 'bwipe! ' .. buf
17845
b6acc24df7de patch 8.1.1919: using window options when passing a buffer to popup_create()
Bram Moolenaar <Bram@vim.org>
parents: 17841
diff changeset
2229 setlocal nonumber
17231
e9ebf3f27af6 patch 8.1.1615: crash when passing buffer number to popup_create()
Bram Moolenaar <Bram@vim.org>
parents: 17225
diff changeset
2230
e9ebf3f27af6 patch 8.1.1615: crash when passing buffer number to popup_create()
Bram Moolenaar <Bram@vim.org>
parents: 17225
diff changeset
2231 edit test_popupwin.vim
e9ebf3f27af6 patch 8.1.1615: crash when passing buffer number to popup_create()
Bram Moolenaar <Bram@vim.org>
parents: 17225
diff changeset
2232 let winid = popup_create(bufnr(''), {})
e9ebf3f27af6 patch 8.1.1615: crash when passing buffer number to popup_create()
Bram Moolenaar <Bram@vim.org>
parents: 17225
diff changeset
2233 redraw
e9ebf3f27af6 patch 8.1.1615: crash when passing buffer number to popup_create()
Bram Moolenaar <Bram@vim.org>
parents: 17225
diff changeset
2234 call popup_close(winid)
17278
b6de6181e5ab patch 8.1.1638: running tests leaves some files behind
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
2235 call delete('XsomeFile')
17225
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
2236 endfunc
17245
13a2d3364b3f patch 8.1.1622: wrong width if displaying a lot of lines in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17241
diff changeset
2237
18162
9c3347b21b89 patch 8.1.2076: crash when trying to put a terminal in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18137
diff changeset
2238 func Test_popupwin_terminal_buffer()
18168
781a81bf4d24 patch 8.1.2079: popup window test fails without +terminal
Bram Moolenaar <Bram@vim.org>
parents: 18162
diff changeset
2239 CheckFeature terminal
781a81bf4d24 patch 8.1.2079: popup window test fails without +terminal
Bram Moolenaar <Bram@vim.org>
parents: 18162
diff changeset
2240
18162
9c3347b21b89 patch 8.1.2076: crash when trying to put a terminal in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18137
diff changeset
2241 let ptybuf = term_start(&shell, #{hidden: 1})
9c3347b21b89 patch 8.1.2076: crash when trying to put a terminal in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18137
diff changeset
2242 call assert_fails('let winnr = popup_create(ptybuf, #{})', 'E278:')
9c3347b21b89 patch 8.1.2076: crash when trying to put a terminal in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18137
diff changeset
2243 exe 'bwipe! ' .. ptybuf
9c3347b21b89 patch 8.1.2076: crash when trying to put a terminal in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18137
diff changeset
2244 endfunc
9c3347b21b89 patch 8.1.2076: crash when trying to put a terminal in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18137
diff changeset
2245
17934
0bf8cb0258be patch 8.1.1963: popup window filter may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 17926
diff changeset
2246 func Test_popupwin_with_buffer_and_filter()
0bf8cb0258be patch 8.1.1963: popup window filter may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 17926
diff changeset
2247 new Xwithfilter
0bf8cb0258be patch 8.1.1963: popup window filter may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 17926
diff changeset
2248 call setline(1, range(100))
0bf8cb0258be patch 8.1.1963: popup window filter may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 17926
diff changeset
2249 let bufnr = bufnr()
0bf8cb0258be patch 8.1.1963: popup window filter may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 17926
diff changeset
2250 hide
0bf8cb0258be patch 8.1.1963: popup window filter may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 17926
diff changeset
2251
0bf8cb0258be patch 8.1.1963: popup window filter may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 17926
diff changeset
2252 func BufferFilter(win, key)
0bf8cb0258be patch 8.1.1963: popup window filter may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 17926
diff changeset
2253 if a:key == 'G'
0bf8cb0258be patch 8.1.1963: popup window filter may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 17926
diff changeset
2254 " recursive use of "G" does not cause problems.
0bf8cb0258be patch 8.1.1963: popup window filter may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 17926
diff changeset
2255 call win_execute(a:win, 'normal! G')
0bf8cb0258be patch 8.1.1963: popup window filter may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 17926
diff changeset
2256 return 1
0bf8cb0258be patch 8.1.1963: popup window filter may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 17926
diff changeset
2257 endif
0bf8cb0258be patch 8.1.1963: popup window filter may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 17926
diff changeset
2258 return 0
0bf8cb0258be patch 8.1.1963: popup window filter may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 17926
diff changeset
2259 endfunc
0bf8cb0258be patch 8.1.1963: popup window filter may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 17926
diff changeset
2260
0bf8cb0258be patch 8.1.1963: popup window filter may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 17926
diff changeset
2261 let winid = popup_create(bufnr, #{maxheight: 5, filter: 'BufferFilter'})
0bf8cb0258be patch 8.1.1963: popup window filter may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 17926
diff changeset
2262 call assert_equal(1, popup_getpos(winid).firstline)
0bf8cb0258be patch 8.1.1963: popup window filter may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 17926
diff changeset
2263 redraw
0bf8cb0258be patch 8.1.1963: popup window filter may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 17926
diff changeset
2264 call feedkeys("G", 'xt')
0bf8cb0258be patch 8.1.1963: popup window filter may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 17926
diff changeset
2265 call assert_equal(99, popup_getpos(winid).firstline)
0bf8cb0258be patch 8.1.1963: popup window filter may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 17926
diff changeset
2266
0bf8cb0258be patch 8.1.1963: popup window filter may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 17926
diff changeset
2267 call popup_close(winid)
0bf8cb0258be patch 8.1.1963: popup window filter may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 17926
diff changeset
2268 exe 'bwipe! ' .. bufnr
0bf8cb0258be patch 8.1.1963: popup window filter may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 17926
diff changeset
2269 endfunc
0bf8cb0258be patch 8.1.1963: popup window filter may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 17926
diff changeset
2270
17245
13a2d3364b3f patch 8.1.1622: wrong width if displaying a lot of lines in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17241
diff changeset
2271 func Test_popupwin_width()
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
2272 let winid = popup_create(repeat(['short', 'long long long line', 'medium width'], 50), #{
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
2273 \ maxwidth: 40,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
2274 \ maxheight: 10,
17245
13a2d3364b3f patch 8.1.1622: wrong width if displaying a lot of lines in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17241
diff changeset
2275 \ })
13a2d3364b3f patch 8.1.1622: wrong width if displaying a lot of lines in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17241
diff changeset
2276 for top in range(1, 20)
17972
a170c48e0f91 patch 8.1.1982: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17946
diff changeset
2277 eval winid->popup_setoptions(#{firstline: top})
17245
13a2d3364b3f patch 8.1.1622: wrong width if displaying a lot of lines in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17241
diff changeset
2278 redraw
13a2d3364b3f patch 8.1.1622: wrong width if displaying a lot of lines in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17241
diff changeset
2279 call assert_equal(19, popup_getpos(winid).width)
13a2d3364b3f patch 8.1.1622: wrong width if displaying a lot of lines in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17241
diff changeset
2280 endfor
13a2d3364b3f patch 8.1.1622: wrong width if displaying a lot of lines in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17241
diff changeset
2281 call popup_clear()
13a2d3364b3f patch 8.1.1622: wrong width if displaying a lot of lines in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17241
diff changeset
2282 endfunc
17253
26e0352613ec patch 8.1.1626: no test for closing a popup window with a modified buffer
Bram Moolenaar <Bram@vim.org>
parents: 17245
diff changeset
2283
26e0352613ec patch 8.1.1626: no test for closing a popup window with a modified buffer
Bram Moolenaar <Bram@vim.org>
parents: 17245
diff changeset
2284 func Test_popupwin_buf_close()
26e0352613ec patch 8.1.1626: no test for closing a popup window with a modified buffer
Bram Moolenaar <Bram@vim.org>
parents: 17245
diff changeset
2285 let buf = bufadd('Xtestbuf')
26e0352613ec patch 8.1.1626: no test for closing a popup window with a modified buffer
Bram Moolenaar <Bram@vim.org>
parents: 17245
diff changeset
2286 call bufload(buf)
26e0352613ec patch 8.1.1626: no test for closing a popup window with a modified buffer
Bram Moolenaar <Bram@vim.org>
parents: 17245
diff changeset
2287 call setbufline(buf, 1, ['just', 'some', 'lines'])
26e0352613ec patch 8.1.1626: no test for closing a popup window with a modified buffer
Bram Moolenaar <Bram@vim.org>
parents: 17245
diff changeset
2288 let winid = popup_create(buf, {})
26e0352613ec patch 8.1.1626: no test for closing a popup window with a modified buffer
Bram Moolenaar <Bram@vim.org>
parents: 17245
diff changeset
2289 redraw
26e0352613ec patch 8.1.1626: no test for closing a popup window with a modified buffer
Bram Moolenaar <Bram@vim.org>
parents: 17245
diff changeset
2290 call assert_equal(3, popup_getpos(winid).height)
26e0352613ec patch 8.1.1626: no test for closing a popup window with a modified buffer
Bram Moolenaar <Bram@vim.org>
parents: 17245
diff changeset
2291 let bufinfo = getbufinfo(buf)[0]
26e0352613ec patch 8.1.1626: no test for closing a popup window with a modified buffer
Bram Moolenaar <Bram@vim.org>
parents: 17245
diff changeset
2292 call assert_equal(1, bufinfo.changed)
26e0352613ec patch 8.1.1626: no test for closing a popup window with a modified buffer
Bram Moolenaar <Bram@vim.org>
parents: 17245
diff changeset
2293 call assert_equal(0, bufinfo.hidden)
26e0352613ec patch 8.1.1626: no test for closing a popup window with a modified buffer
Bram Moolenaar <Bram@vim.org>
parents: 17245
diff changeset
2294 call assert_equal(0, bufinfo.listed)
26e0352613ec patch 8.1.1626: no test for closing a popup window with a modified buffer
Bram Moolenaar <Bram@vim.org>
parents: 17245
diff changeset
2295 call assert_equal(1, bufinfo.loaded)
26e0352613ec patch 8.1.1626: no test for closing a popup window with a modified buffer
Bram Moolenaar <Bram@vim.org>
parents: 17245
diff changeset
2296 call assert_equal([], bufinfo.windows)
26e0352613ec patch 8.1.1626: no test for closing a popup window with a modified buffer
Bram Moolenaar <Bram@vim.org>
parents: 17245
diff changeset
2297 call assert_equal([winid], bufinfo.popups)
26e0352613ec patch 8.1.1626: no test for closing a popup window with a modified buffer
Bram Moolenaar <Bram@vim.org>
parents: 17245
diff changeset
2298
26e0352613ec patch 8.1.1626: no test for closing a popup window with a modified buffer
Bram Moolenaar <Bram@vim.org>
parents: 17245
diff changeset
2299 call popup_close(winid)
26e0352613ec patch 8.1.1626: no test for closing a popup window with a modified buffer
Bram Moolenaar <Bram@vim.org>
parents: 17245
diff changeset
2300 call assert_equal({}, popup_getpos(winid))
26e0352613ec patch 8.1.1626: no test for closing a popup window with a modified buffer
Bram Moolenaar <Bram@vim.org>
parents: 17245
diff changeset
2301 let bufinfo = getbufinfo(buf)[0]
26e0352613ec patch 8.1.1626: no test for closing a popup window with a modified buffer
Bram Moolenaar <Bram@vim.org>
parents: 17245
diff changeset
2302 call assert_equal(1, bufinfo.changed)
26e0352613ec patch 8.1.1626: no test for closing a popup window with a modified buffer
Bram Moolenaar <Bram@vim.org>
parents: 17245
diff changeset
2303 call assert_equal(1, bufinfo.hidden)
26e0352613ec patch 8.1.1626: no test for closing a popup window with a modified buffer
Bram Moolenaar <Bram@vim.org>
parents: 17245
diff changeset
2304 call assert_equal(0, bufinfo.listed)
26e0352613ec patch 8.1.1626: no test for closing a popup window with a modified buffer
Bram Moolenaar <Bram@vim.org>
parents: 17245
diff changeset
2305 call assert_equal(1, bufinfo.loaded)
26e0352613ec patch 8.1.1626: no test for closing a popup window with a modified buffer
Bram Moolenaar <Bram@vim.org>
parents: 17245
diff changeset
2306 call assert_equal([], bufinfo.windows)
26e0352613ec patch 8.1.1626: no test for closing a popup window with a modified buffer
Bram Moolenaar <Bram@vim.org>
parents: 17245
diff changeset
2307 call assert_equal([], bufinfo.popups)
26e0352613ec patch 8.1.1626: no test for closing a popup window with a modified buffer
Bram Moolenaar <Bram@vim.org>
parents: 17245
diff changeset
2308 exe 'bwipe! ' .. buf
26e0352613ec patch 8.1.1626: no test for closing a popup window with a modified buffer
Bram Moolenaar <Bram@vim.org>
parents: 17245
diff changeset
2309 endfunc
17354
102ed3a26a5d patch 8.1.1676: "maxwidth" of popup window does not always work properly
Bram Moolenaar <Bram@vim.org>
parents: 17348
diff changeset
2310
102ed3a26a5d patch 8.1.1676: "maxwidth" of popup window does not always work properly
Bram Moolenaar <Bram@vim.org>
parents: 17348
diff changeset
2311 func Test_popup_menu_with_maxwidth()
17680
55704f587945 patch 8.1.1837: popup test fails if clipboard is supported but not working
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
2312 CheckScreendump
17354
102ed3a26a5d patch 8.1.1676: "maxwidth" of popup window does not always work properly
Bram Moolenaar <Bram@vim.org>
parents: 17348
diff changeset
2313
102ed3a26a5d patch 8.1.1676: "maxwidth" of popup window does not always work properly
Bram Moolenaar <Bram@vim.org>
parents: 17348
diff changeset
2314 let lines =<< trim END
102ed3a26a5d patch 8.1.1676: "maxwidth" of popup window does not always work properly
Bram Moolenaar <Bram@vim.org>
parents: 17348
diff changeset
2315 call setline(1, range(1, 10))
102ed3a26a5d patch 8.1.1676: "maxwidth" of popup window does not always work properly
Bram Moolenaar <Bram@vim.org>
parents: 17348
diff changeset
2316 hi ScrollThumb ctermbg=blue
102ed3a26a5d patch 8.1.1676: "maxwidth" of popup window does not always work properly
Bram Moolenaar <Bram@vim.org>
parents: 17348
diff changeset
2317 hi ScrollBar ctermbg=red
102ed3a26a5d patch 8.1.1676: "maxwidth" of popup window does not always work properly
Bram Moolenaar <Bram@vim.org>
parents: 17348
diff changeset
2318 func PopupMenu(lines, line, col, scrollbar = 0)
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
2319 return popup_menu(a:lines, #{
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
2320 \ maxwidth: 10,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
2321 \ maxheight: 3,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
2322 \ pos : 'topleft',
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
2323 \ col : a:col,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
2324 \ line : a:line,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
2325 \ scrollbar : a:scrollbar,
17354
102ed3a26a5d patch 8.1.1676: "maxwidth" of popup window does not always work properly
Bram Moolenaar <Bram@vim.org>
parents: 17348
diff changeset
2326 \ })
102ed3a26a5d patch 8.1.1676: "maxwidth" of popup window does not always work properly
Bram Moolenaar <Bram@vim.org>
parents: 17348
diff changeset
2327 endfunc
102ed3a26a5d patch 8.1.1676: "maxwidth" of popup window does not always work properly
Bram Moolenaar <Bram@vim.org>
parents: 17348
diff changeset
2328 call PopupMenu(['x'], 1, 1)
102ed3a26a5d patch 8.1.1676: "maxwidth" of popup window does not always work properly
Bram Moolenaar <Bram@vim.org>
parents: 17348
diff changeset
2329 call PopupMenu(['123456789|'], 1, 16)
102ed3a26a5d patch 8.1.1676: "maxwidth" of popup window does not always work properly
Bram Moolenaar <Bram@vim.org>
parents: 17348
diff changeset
2330 call PopupMenu(['123456789|' .. ' '], 7, 1)
102ed3a26a5d patch 8.1.1676: "maxwidth" of popup window does not always work properly
Bram Moolenaar <Bram@vim.org>
parents: 17348
diff changeset
2331 call PopupMenu([repeat('123456789|', 100)], 7, 16)
102ed3a26a5d patch 8.1.1676: "maxwidth" of popup window does not always work properly
Bram Moolenaar <Bram@vim.org>
parents: 17348
diff changeset
2332 call PopupMenu(repeat(['123456789|' .. ' '], 5), 1, 33, 1)
102ed3a26a5d patch 8.1.1676: "maxwidth" of popup window does not always work properly
Bram Moolenaar <Bram@vim.org>
parents: 17348
diff changeset
2333 END
102ed3a26a5d patch 8.1.1676: "maxwidth" of popup window does not always work properly
Bram Moolenaar <Bram@vim.org>
parents: 17348
diff changeset
2334 call writefile(lines, 'XtestPopupMenuMaxWidth')
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
2335 let buf = RunVimInTerminal('-S XtestPopupMenuMaxWidth', #{rows: 13})
17354
102ed3a26a5d patch 8.1.1676: "maxwidth" of popup window does not always work properly
Bram Moolenaar <Bram@vim.org>
parents: 17348
diff changeset
2336 call VerifyScreenDump(buf, 'Test_popupwin_menu_maxwidth_1', {})
102ed3a26a5d patch 8.1.1676: "maxwidth" of popup window does not always work properly
Bram Moolenaar <Bram@vim.org>
parents: 17348
diff changeset
2337
102ed3a26a5d patch 8.1.1676: "maxwidth" of popup window does not always work properly
Bram Moolenaar <Bram@vim.org>
parents: 17348
diff changeset
2338 " close the menu popupwin.
102ed3a26a5d patch 8.1.1676: "maxwidth" of popup window does not always work properly
Bram Moolenaar <Bram@vim.org>
parents: 17348
diff changeset
2339 call term_sendkeys(buf, " ")
102ed3a26a5d patch 8.1.1676: "maxwidth" of popup window does not always work properly
Bram Moolenaar <Bram@vim.org>
parents: 17348
diff changeset
2340 call term_sendkeys(buf, " ")
102ed3a26a5d patch 8.1.1676: "maxwidth" of popup window does not always work properly
Bram Moolenaar <Bram@vim.org>
parents: 17348
diff changeset
2341 call term_sendkeys(buf, " ")
102ed3a26a5d patch 8.1.1676: "maxwidth" of popup window does not always work properly
Bram Moolenaar <Bram@vim.org>
parents: 17348
diff changeset
2342 call term_sendkeys(buf, " ")
102ed3a26a5d patch 8.1.1676: "maxwidth" of popup window does not always work properly
Bram Moolenaar <Bram@vim.org>
parents: 17348
diff changeset
2343 call term_sendkeys(buf, " ")
102ed3a26a5d patch 8.1.1676: "maxwidth" of popup window does not always work properly
Bram Moolenaar <Bram@vim.org>
parents: 17348
diff changeset
2344
102ed3a26a5d patch 8.1.1676: "maxwidth" of popup window does not always work properly
Bram Moolenaar <Bram@vim.org>
parents: 17348
diff changeset
2345 " clean up
102ed3a26a5d patch 8.1.1676: "maxwidth" of popup window does not always work properly
Bram Moolenaar <Bram@vim.org>
parents: 17348
diff changeset
2346 call StopVimInTerminal(buf)
102ed3a26a5d patch 8.1.1676: "maxwidth" of popup window does not always work properly
Bram Moolenaar <Bram@vim.org>
parents: 17348
diff changeset
2347 call delete('XtestPopupMenuMaxWidth')
102ed3a26a5d patch 8.1.1676: "maxwidth" of popup window does not always work properly
Bram Moolenaar <Bram@vim.org>
parents: 17348
diff changeset
2348 endfunc
102ed3a26a5d patch 8.1.1676: "maxwidth" of popup window does not always work properly
Bram Moolenaar <Bram@vim.org>
parents: 17348
diff changeset
2349
17358
d1ea88736ebd patch 8.1.1678: using popup_menu() does not scroll to show the selected line
Bram Moolenaar <Bram@vim.org>
parents: 17354
diff changeset
2350 func Test_popup_menu_with_scrollbar()
17680
55704f587945 patch 8.1.1837: popup test fails if clipboard is supported but not working
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
2351 CheckScreendump
17358
d1ea88736ebd patch 8.1.1678: using popup_menu() does not scroll to show the selected line
Bram Moolenaar <Bram@vim.org>
parents: 17354
diff changeset
2352
d1ea88736ebd patch 8.1.1678: using popup_menu() does not scroll to show the selected line
Bram Moolenaar <Bram@vim.org>
parents: 17354
diff changeset
2353 let lines =<< trim END
d1ea88736ebd patch 8.1.1678: using popup_menu() does not scroll to show the selected line
Bram Moolenaar <Bram@vim.org>
parents: 17354
diff changeset
2354 call setline(1, range(1, 20))
d1ea88736ebd patch 8.1.1678: using popup_menu() does not scroll to show the selected line
Bram Moolenaar <Bram@vim.org>
parents: 17354
diff changeset
2355 hi ScrollThumb ctermbg=blue
d1ea88736ebd patch 8.1.1678: using popup_menu() does not scroll to show the selected line
Bram Moolenaar <Bram@vim.org>
parents: 17354
diff changeset
2356 hi ScrollBar ctermbg=red
17972
a170c48e0f91 patch 8.1.1982: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17946
diff changeset
2357 eval ['one', 'two', 'three', 'four', 'five',
a170c48e0f91 patch 8.1.1982: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17946
diff changeset
2358 \ 'six', 'seven', 'eight', 'nine']
a170c48e0f91 patch 8.1.1982: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17946
diff changeset
2359 \ ->popup_menu(#{
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
2360 \ minwidth: 8,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
2361 \ maxheight: 3,
17358
d1ea88736ebd patch 8.1.1678: using popup_menu() does not scroll to show the selected line
Bram Moolenaar <Bram@vim.org>
parents: 17354
diff changeset
2362 \ })
d1ea88736ebd patch 8.1.1678: using popup_menu() does not scroll to show the selected line
Bram Moolenaar <Bram@vim.org>
parents: 17354
diff changeset
2363 END
d1ea88736ebd patch 8.1.1678: using popup_menu() does not scroll to show the selected line
Bram Moolenaar <Bram@vim.org>
parents: 17354
diff changeset
2364 call writefile(lines, 'XtestPopupMenuScroll')
17413
40417757dffd patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents: 17387
diff changeset
2365 let buf = RunVimInTerminal('-S XtestPopupMenuScroll', #{rows: 10})
17358
d1ea88736ebd patch 8.1.1678: using popup_menu() does not scroll to show the selected line
Bram Moolenaar <Bram@vim.org>
parents: 17354
diff changeset
2366
d1ea88736ebd patch 8.1.1678: using popup_menu() does not scroll to show the selected line
Bram Moolenaar <Bram@vim.org>
parents: 17354
diff changeset
2367 call term_sendkeys(buf, "j")
d1ea88736ebd patch 8.1.1678: using popup_menu() does not scroll to show the selected line
Bram Moolenaar <Bram@vim.org>
parents: 17354
diff changeset
2368 call VerifyScreenDump(buf, 'Test_popupwin_menu_scroll_1', {})
d1ea88736ebd patch 8.1.1678: using popup_menu() does not scroll to show the selected line
Bram Moolenaar <Bram@vim.org>
parents: 17354
diff changeset
2369
d1ea88736ebd patch 8.1.1678: using popup_menu() does not scroll to show the selected line
Bram Moolenaar <Bram@vim.org>
parents: 17354
diff changeset
2370 call term_sendkeys(buf, "jjj")
d1ea88736ebd patch 8.1.1678: using popup_menu() does not scroll to show the selected line
Bram Moolenaar <Bram@vim.org>
parents: 17354
diff changeset
2371 call VerifyScreenDump(buf, 'Test_popupwin_menu_scroll_2', {})
d1ea88736ebd patch 8.1.1678: using popup_menu() does not scroll to show the selected line
Bram Moolenaar <Bram@vim.org>
parents: 17354
diff changeset
2372
d1ea88736ebd patch 8.1.1678: using popup_menu() does not scroll to show the selected line
Bram Moolenaar <Bram@vim.org>
parents: 17354
diff changeset
2373 " if the cursor is the bottom line, it stays at the bottom line.
d1ea88736ebd patch 8.1.1678: using popup_menu() does not scroll to show the selected line
Bram Moolenaar <Bram@vim.org>
parents: 17354
diff changeset
2374 call term_sendkeys(buf, repeat("j", 20))
d1ea88736ebd patch 8.1.1678: using popup_menu() does not scroll to show the selected line
Bram Moolenaar <Bram@vim.org>
parents: 17354
diff changeset
2375 call VerifyScreenDump(buf, 'Test_popupwin_menu_scroll_3', {})
d1ea88736ebd patch 8.1.1678: using popup_menu() does not scroll to show the selected line
Bram Moolenaar <Bram@vim.org>
parents: 17354
diff changeset
2376
d1ea88736ebd patch 8.1.1678: using popup_menu() does not scroll to show the selected line
Bram Moolenaar <Bram@vim.org>
parents: 17354
diff changeset
2377 call term_sendkeys(buf, "kk")
d1ea88736ebd patch 8.1.1678: using popup_menu() does not scroll to show the selected line
Bram Moolenaar <Bram@vim.org>
parents: 17354
diff changeset
2378 call VerifyScreenDump(buf, 'Test_popupwin_menu_scroll_4', {})
d1ea88736ebd patch 8.1.1678: using popup_menu() does not scroll to show the selected line
Bram Moolenaar <Bram@vim.org>
parents: 17354
diff changeset
2379
d1ea88736ebd patch 8.1.1678: using popup_menu() does not scroll to show the selected line
Bram Moolenaar <Bram@vim.org>
parents: 17354
diff changeset
2380 call term_sendkeys(buf, "k")
d1ea88736ebd patch 8.1.1678: using popup_menu() does not scroll to show the selected line
Bram Moolenaar <Bram@vim.org>
parents: 17354
diff changeset
2381 call VerifyScreenDump(buf, 'Test_popupwin_menu_scroll_5', {})
d1ea88736ebd patch 8.1.1678: using popup_menu() does not scroll to show the selected line
Bram Moolenaar <Bram@vim.org>
parents: 17354
diff changeset
2382
d1ea88736ebd patch 8.1.1678: using popup_menu() does not scroll to show the selected line
Bram Moolenaar <Bram@vim.org>
parents: 17354
diff changeset
2383 " if the cursor is in the top line, it stays in the top line.
d1ea88736ebd patch 8.1.1678: using popup_menu() does not scroll to show the selected line
Bram Moolenaar <Bram@vim.org>
parents: 17354
diff changeset
2384 call term_sendkeys(buf, repeat("k", 20))
d1ea88736ebd patch 8.1.1678: using popup_menu() does not scroll to show the selected line
Bram Moolenaar <Bram@vim.org>
parents: 17354
diff changeset
2385 call VerifyScreenDump(buf, 'Test_popupwin_menu_scroll_6', {})
d1ea88736ebd patch 8.1.1678: using popup_menu() does not scroll to show the selected line
Bram Moolenaar <Bram@vim.org>
parents: 17354
diff changeset
2386
d1ea88736ebd patch 8.1.1678: using popup_menu() does not scroll to show the selected line
Bram Moolenaar <Bram@vim.org>
parents: 17354
diff changeset
2387 " close the menu popupwin.
d1ea88736ebd patch 8.1.1678: using popup_menu() does not scroll to show the selected line
Bram Moolenaar <Bram@vim.org>
parents: 17354
diff changeset
2388 call term_sendkeys(buf, " ")
d1ea88736ebd patch 8.1.1678: using popup_menu() does not scroll to show the selected line
Bram Moolenaar <Bram@vim.org>
parents: 17354
diff changeset
2389
d1ea88736ebd patch 8.1.1678: using popup_menu() does not scroll to show the selected line
Bram Moolenaar <Bram@vim.org>
parents: 17354
diff changeset
2390 " clean up
d1ea88736ebd patch 8.1.1678: using popup_menu() does not scroll to show the selected line
Bram Moolenaar <Bram@vim.org>
parents: 17354
diff changeset
2391 call StopVimInTerminal(buf)
d1ea88736ebd patch 8.1.1678: using popup_menu() does not scroll to show the selected line
Bram Moolenaar <Bram@vim.org>
parents: 17354
diff changeset
2392 call delete('XtestPopupMenuScroll')
d1ea88736ebd patch 8.1.1678: using popup_menu() does not scroll to show the selected line
Bram Moolenaar <Bram@vim.org>
parents: 17354
diff changeset
2393 endfunc
d1ea88736ebd patch 8.1.1678: using popup_menu() does not scroll to show the selected line
Bram Moolenaar <Bram@vim.org>
parents: 17354
diff changeset
2394
17429
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2395 func Test_popup_menu_filter()
17680
55704f587945 patch 8.1.1837: popup test fails if clipboard is supported but not working
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
2396 CheckScreendump
17429
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2397
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2398 let lines =<< trim END
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2399 function! MyFilter(winid, key) abort
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2400 if a:key == "0"
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2401 call win_execute(a:winid, "call setpos('.', [0, 1, 1, 0])")
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2402 return 1
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2403 endif
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2404 if a:key == "G"
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2405 call win_execute(a:winid, "call setpos('.', [0, line('$'), 1, 0])")
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2406 return 1
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2407 endif
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2408 if a:key == "j"
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2409 call win_execute(a:winid, "call setpos('.', [0, line('.') + 1, 1, 0])")
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2410 return 1
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2411 endif
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2412 if a:key == "k"
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2413 call win_execute(a:winid, "call setpos('.', [0, line('.') - 1, 1, 0])")
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2414 return 1
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2415 endif
18002
2fdbcecab216 patch 8.1.1997: no redraw after a popup window filter is invoked
Bram Moolenaar <Bram@vim.org>
parents: 17994
diff changeset
2416 if a:key == ':'
17429
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2417 call popup_close(a:winid)
18002
2fdbcecab216 patch 8.1.1997: no redraw after a popup window filter is invoked
Bram Moolenaar <Bram@vim.org>
parents: 17994
diff changeset
2418 return 0
17429
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2419 endif
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2420 return 0
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2421 endfunction
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2422 call popup_menu(['111', '222', '333', '444', '555', '666', '777', '888', '999'], #{
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2423 \ maxheight : 3,
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2424 \ filter : 'MyFilter'
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2425 \ })
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2426 END
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2427 call writefile(lines, 'XtestPopupMenuFilter')
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2428 let buf = RunVimInTerminal('-S XtestPopupMenuFilter', #{rows: 10})
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2429
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2430 call term_sendkeys(buf, "j")
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2431 call VerifyScreenDump(buf, 'Test_popupwin_menu_filter_1', {})
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2432
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2433 call term_sendkeys(buf, "k")
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2434 call VerifyScreenDump(buf, 'Test_popupwin_menu_filter_2', {})
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2435
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2436 call term_sendkeys(buf, "G")
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2437 call VerifyScreenDump(buf, 'Test_popupwin_menu_filter_3', {})
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2438
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2439 call term_sendkeys(buf, "0")
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2440 call VerifyScreenDump(buf, 'Test_popupwin_menu_filter_4', {})
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2441
18002
2fdbcecab216 patch 8.1.1997: no redraw after a popup window filter is invoked
Bram Moolenaar <Bram@vim.org>
parents: 17994
diff changeset
2442 " check that when the popup is closed in the filter the screen is redrawn
2fdbcecab216 patch 8.1.1997: no redraw after a popup window filter is invoked
Bram Moolenaar <Bram@vim.org>
parents: 17994
diff changeset
2443 call term_sendkeys(buf, ":")
2fdbcecab216 patch 8.1.1997: no redraw after a popup window filter is invoked
Bram Moolenaar <Bram@vim.org>
parents: 17994
diff changeset
2444 call VerifyScreenDump(buf, 'Test_popupwin_menu_filter_5', {})
2fdbcecab216 patch 8.1.1997: no redraw after a popup window filter is invoked
Bram Moolenaar <Bram@vim.org>
parents: 17994
diff changeset
2445 call term_sendkeys(buf, "\<CR>")
17429
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2446
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2447 " clean up
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2448 call StopVimInTerminal(buf)
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2449 call delete('XtestPopupMenuFilter')
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2450 endfunc
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2451
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2452 func Test_popup_cursorline()
17680
55704f587945 patch 8.1.1837: popup test fails if clipboard is supported but not working
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
2453 CheckScreendump
17429
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2454
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2455 let winid = popup_create('some text', {})
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2456 call assert_equal(0, popup_getoptions(winid).cursorline)
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2457 call popup_close(winid)
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2458
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2459 let winid = popup_create('some text', #{ cursorline: 1, })
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2460 call assert_equal(1, popup_getoptions(winid).cursorline)
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2461 call popup_close(winid)
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2462
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2463 let winid = popup_create('some text', #{ cursorline: 0, })
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2464 call assert_equal(0, popup_getoptions(winid).cursorline)
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2465 call popup_close(winid)
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2466
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2467 let winid = popup_menu('some text', {})
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2468 call assert_equal(1, popup_getoptions(winid).cursorline)
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2469 call popup_close(winid)
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2470
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2471 let winid = popup_menu('some text', #{ cursorline: 1, })
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2472 call assert_equal(1, popup_getoptions(winid).cursorline)
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2473 call popup_close(winid)
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2474
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2475 let winid = popup_menu('some text', #{ cursorline: 0, })
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2476 call assert_equal(0, popup_getoptions(winid).cursorline)
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2477 call popup_close(winid)
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2478
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2479 " ---------
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2480 " Pattern 1
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2481 " ---------
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2482 let lines =<< trim END
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2483 call popup_create(['111', '222', '333'], #{ cursorline : 0 })
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2484 END
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2485 call writefile(lines, 'XtestPopupCursorLine')
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2486 let buf = RunVimInTerminal('-S XtestPopupCursorLine', #{rows: 10})
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2487 call VerifyScreenDump(buf, 'Test_popupwin_cursorline_1', {})
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2488 call term_sendkeys(buf, ":call popup_clear()\<cr>")
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2489 call StopVimInTerminal(buf)
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2490
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2491 " ---------
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2492 " Pattern 2
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2493 " ---------
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2494 let lines =<< trim END
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2495 call popup_create(['111', '222', '333'], #{ cursorline : 1 })
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2496 END
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2497 call writefile(lines, 'XtestPopupCursorLine')
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2498 let buf = RunVimInTerminal('-S XtestPopupCursorLine', #{rows: 10})
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2499 call VerifyScreenDump(buf, 'Test_popupwin_cursorline_2', {})
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2500 call term_sendkeys(buf, ":call popup_clear()\<cr>")
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2501 call StopVimInTerminal(buf)
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2502
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2503 " ---------
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2504 " Pattern 3
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2505 " ---------
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2506 let lines =<< trim END
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2507 function! MyFilter(winid, key) abort
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2508 if a:key == "j"
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2509 call win_execute(a:winid, "call setpos('.', [0, line('.') + 1, 1, 0]) | redraw")
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2510 return 1
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2511 endif
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2512 if a:key == 'x'
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2513 call popup_close(a:winid)
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2514 return 1
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2515 endif
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2516 return 0
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2517 endfunction
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2518 call popup_menu(['111', '222', '333'], #{
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2519 \ cursorline : 0,
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2520 \ maxheight : 2,
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2521 \ filter : 'MyFilter',
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2522 \ })
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2523 END
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2524 call writefile(lines, 'XtestPopupCursorLine')
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2525 let buf = RunVimInTerminal('-S XtestPopupCursorLine', #{rows: 10})
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2526 call VerifyScreenDump(buf, 'Test_popupwin_cursorline_3', {})
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2527 call term_sendkeys(buf, "j")
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2528 call term_sendkeys(buf, "j")
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2529 call VerifyScreenDump(buf, 'Test_popupwin_cursorline_4', {})
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2530 call term_sendkeys(buf, "x")
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2531 call StopVimInTerminal(buf)
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2532
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2533 " ---------
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2534 " Pattern 4
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2535 " ---------
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2536 let lines =<< trim END
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2537 function! MyFilter(winid, key) abort
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2538 if a:key == "j"
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2539 call win_execute(a:winid, "call setpos('.', [0, line('.') + 1, 1, 0]) | redraw")
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2540 return 1
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2541 endif
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2542 if a:key == 'x'
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2543 call popup_close(a:winid)
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2544 return 1
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2545 endif
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2546 return 0
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2547 endfunction
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2548 call popup_menu(['111', '222', '333'], #{
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2549 \ cursorline : 1,
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2550 \ maxheight : 2,
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2551 \ filter : 'MyFilter',
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2552 \ })
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2553 END
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2554 call writefile(lines, 'XtestPopupCursorLine')
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2555 let buf = RunVimInTerminal('-S XtestPopupCursorLine', #{rows: 10})
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2556 call VerifyScreenDump(buf, 'Test_popupwin_cursorline_5', {})
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2557 call term_sendkeys(buf, "j")
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2558 call term_sendkeys(buf, "j")
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2559 call VerifyScreenDump(buf, 'Test_popupwin_cursorline_6', {})
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2560 call term_sendkeys(buf, "x")
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2561 call StopVimInTerminal(buf)
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2562
18027
56032a704448 patch 8.1.2009: cursorline highlighting not updated in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18002
diff changeset
2563 " ---------
56032a704448 patch 8.1.2009: cursorline highlighting not updated in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18002
diff changeset
2564 " Cursor in second line when creating the popup
56032a704448 patch 8.1.2009: cursorline highlighting not updated in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18002
diff changeset
2565 " ---------
56032a704448 patch 8.1.2009: cursorline highlighting not updated in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18002
diff changeset
2566 let lines =<< trim END
56032a704448 patch 8.1.2009: cursorline highlighting not updated in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18002
diff changeset
2567 let winid = popup_create(['111', '222', '333'], #{
56032a704448 patch 8.1.2009: cursorline highlighting not updated in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18002
diff changeset
2568 \ cursorline : 1,
56032a704448 patch 8.1.2009: cursorline highlighting not updated in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18002
diff changeset
2569 \ })
56032a704448 patch 8.1.2009: cursorline highlighting not updated in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18002
diff changeset
2570 call win_execute(winid, "2")
56032a704448 patch 8.1.2009: cursorline highlighting not updated in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18002
diff changeset
2571 END
56032a704448 patch 8.1.2009: cursorline highlighting not updated in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18002
diff changeset
2572 call writefile(lines, 'XtestPopupCursorLine')
56032a704448 patch 8.1.2009: cursorline highlighting not updated in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18002
diff changeset
2573 let buf = RunVimInTerminal('-S XtestPopupCursorLine', #{rows: 10})
56032a704448 patch 8.1.2009: cursorline highlighting not updated in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18002
diff changeset
2574 call VerifyScreenDump(buf, 'Test_popupwin_cursorline_7', {})
56032a704448 patch 8.1.2009: cursorline highlighting not updated in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18002
diff changeset
2575 call StopVimInTerminal(buf)
56032a704448 patch 8.1.2009: cursorline highlighting not updated in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18002
diff changeset
2576
17429
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2577 call delete('XtestPopupCursorLine')
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2578 endfunc
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2579
17438
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
2580 func Test_previewpopup()
17680
55704f587945 patch 8.1.1837: popup test fails if clipboard is supported but not working
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
2581 CheckScreendump
55704f587945 patch 8.1.1837: popup test fails if clipboard is supported but not working
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
2582
17438
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
2583 call writefile([
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
2584 \ "!_TAG_FILE_ENCODING\tutf-8\t//",
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
2585 \ "another\tXtagfile\t/^this is another",
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
2586 \ "theword\tXtagfile\t/^theword"],
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
2587 \ 'Xtags')
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
2588 call writefile(range(1,20)
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
2589 \ + ['theword is here']
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
2590 \ + range(22, 27)
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
2591 \ + ['this is another place']
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
2592 \ + range(29, 40),
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
2593 \ "Xtagfile")
17644
daa1dea1c1b3 patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
2594 call writefile(range(1,10)
daa1dea1c1b3 patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
2595 \ + ['searched word is here']
daa1dea1c1b3 patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
2596 \ + range(12, 20),
daa1dea1c1b3 patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
2597 \ "Xheader.h")
17438
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
2598 let lines =<< trim END
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
2599 set tags=Xtags
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
2600 call setline(1, [
17551
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
2601 \ 'one',
17644
daa1dea1c1b3 patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
2602 \ '#include "Xheader.h"',
17551
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
2603 \ 'three',
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
2604 \ 'four',
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
2605 \ 'five',
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
2606 \ 'six',
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
2607 \ 'seven',
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
2608 \ 'find theword somewhere',
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
2609 \ 'nine',
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
2610 \ 'this is another word',
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
2611 \ 'very long line where the word is also another'])
17438
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
2612 set previewpopup=height:4,width:40
17644
daa1dea1c1b3 patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
2613 set path=.
17438
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
2614 END
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
2615 call writefile(lines, 'XtestPreviewPopup')
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
2616 let buf = RunVimInTerminal('-S XtestPreviewPopup', #{rows: 14})
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
2617
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
2618 call term_sendkeys(buf, "/theword\<CR>\<C-W>}")
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
2619 call term_sendkeys(buf, ":\<CR>")
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
2620 call VerifyScreenDump(buf, 'Test_popupwin_previewpopup_1', {})
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
2621
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
2622 call term_sendkeys(buf, "/another\<CR>\<C-W>}")
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
2623 call VerifyScreenDump(buf, 'Test_popupwin_previewpopup_2', {})
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
2624
17817
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
2625 call term_sendkeys(buf, ":call popup_move(popup_findpreview(), #{col: 15})\<CR>")
17551
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
2626 call term_sendkeys(buf, ":\<CR>")
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
2627 call VerifyScreenDump(buf, 'Test_popupwin_previewpopup_3', {})
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
2628
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
2629 call term_sendkeys(buf, "/another\<CR>\<C-W>}")
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
2630 call VerifyScreenDump(buf, 'Test_popupwin_previewpopup_4', {})
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
2631
17604
506dd2efcbb2 patch 8.1.1799: cannot avoid mapping for a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
2632 call term_sendkeys(buf, ":cd ..\<CR>:\<CR>")
506dd2efcbb2 patch 8.1.1799: cannot avoid mapping for a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
2633 call VerifyScreenDump(buf, 'Test_popupwin_previewpopup_5', {})
17644
daa1dea1c1b3 patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
2634 call term_sendkeys(buf, ":cd testdir\<CR>")
daa1dea1c1b3 patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
2635
daa1dea1c1b3 patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
2636 call term_sendkeys(buf, ":pclose\<CR>")
17718
6a73e3bd0ff8 patch 8.1.1856: popup preview test fails sometimes
Bram Moolenaar <Bram@vim.org>
parents: 17680
diff changeset
2637 call term_sendkeys(buf, ":\<BS>")
17644
daa1dea1c1b3 patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
2638 call VerifyScreenDump(buf, 'Test_popupwin_previewpopup_6', {})
daa1dea1c1b3 patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
2639
daa1dea1c1b3 patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
2640 call term_sendkeys(buf, ":pedit +/theword Xtagfile\<CR>")
daa1dea1c1b3 patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
2641 call term_sendkeys(buf, ":\<CR>")
daa1dea1c1b3 patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
2642 call VerifyScreenDump(buf, 'Test_popupwin_previewpopup_7', {})
daa1dea1c1b3 patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
2643
daa1dea1c1b3 patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
2644 call term_sendkeys(buf, ":pclose\<CR>")
daa1dea1c1b3 patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
2645 call term_sendkeys(buf, ":psearch searched\<CR>")
daa1dea1c1b3 patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
2646 call term_sendkeys(buf, ":\<CR>")
daa1dea1c1b3 patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
2647 call VerifyScreenDump(buf, 'Test_popupwin_previewpopup_8', {})
17604
506dd2efcbb2 patch 8.1.1799: cannot avoid mapping for a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
2648
17438
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
2649 call StopVimInTerminal(buf)
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
2650 call delete('Xtags')
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
2651 call delete('Xtagfile')
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
2652 call delete('XtestPreviewPopup')
17644
daa1dea1c1b3 patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
2653 call delete('Xheader.h')
17438
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
2654 endfunc
967e2ee9b656 patch 8.1.1717: last char in menu popup window highlighted
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
2655
17811
b5499bf22a97 patch 8.1.1902: cannot have an info popup without a border
Bram Moolenaar <Bram@vim.org>
parents: 17771
diff changeset
2656 func Get_popupmenu_lines()
17767
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2657 let lines =<< trim END
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2658 set completeopt+=preview,popup
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2659 set completefunc=CompleteFuncDict
17771
4bd21046902b patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents: 17769
diff changeset
2660 hi InfoPopup ctermbg=yellow
17767
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2661
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2662 func CompleteFuncDict(findstart, base)
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2663 if a:findstart
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2664 if col('.') > 10
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2665 return col('.') - 10
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2666 endif
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2667 return 0
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2668 endif
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2669
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2670 return {
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2671 \ 'words': [
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2672 \ {
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2673 \ 'word': 'aword',
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2674 \ 'abbr': 'wrd',
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2675 \ 'menu': 'extra text',
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2676 \ 'info': 'words are cool',
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2677 \ 'kind': 'W',
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2678 \ 'user_data': 'test'
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2679 \ },
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2680 \ {
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2681 \ 'word': 'anotherword',
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2682 \ 'abbr': 'anotwrd',
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2683 \ 'menu': 'extra text',
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2684 \ 'info': "other words are\ncooler than this and some more text\nto make wrap",
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2685 \ 'kind': 'W',
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2686 \ 'user_data': 'notest'
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2687 \ },
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2688 \ {
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2689 \ 'word': 'noinfo',
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2690 \ 'abbr': 'noawrd',
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2691 \ 'menu': 'extra text',
17771
4bd21046902b patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents: 17769
diff changeset
2692 \ 'info': "lets\nshow\na\nscrollbar\nhere",
17767
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2693 \ 'kind': 'W',
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2694 \ 'user_data': 'notest'
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2695 \ },
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2696 \ {
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2697 \ 'word': 'thatword',
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2698 \ 'abbr': 'thatwrd',
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2699 \ 'menu': 'extra text',
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2700 \ 'info': 'that word is cool',
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2701 \ 'kind': 'W',
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2702 \ 'user_data': 'notest'
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2703 \ },
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2704 \ ]
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2705 \ }
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2706 endfunc
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2707 call setline(1, 'text text text text text text text ')
17817
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
2708 func ChangeColor()
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
2709 let id = popup_findinfo()
17972
a170c48e0f91 patch 8.1.1982: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17946
diff changeset
2710 eval id->popup_setoptions(#{highlight: 'InfoPopup'})
17817
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
2711 endfunc
18396
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2712
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2713 func InfoHidden()
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2714 set completepopup=height:4,border:off,align:menu
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2715 set completeopt-=popup completeopt+=popuphidden
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2716 au CompleteChanged * call HandleChange()
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2717 endfunc
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2718
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2719 let s:counter = 0
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2720 func HandleChange()
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2721 let s:counter += 1
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2722 let selected = complete_info(['selected']).selected
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2723 if selected <= 0
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2724 " First time: do nothing, info remains hidden
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2725 return
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2726 endif
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2727 if selected == 1
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2728 " Second time: show info right away
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2729 let id = popup_findinfo()
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2730 if id
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2731 call popup_settext(id, 'immediate info ' .. s:counter)
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2732 call popup_show(id)
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2733 endif
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2734 else
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2735 " Third time: show info after a short delay
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2736 call timer_start(100, 'ShowInfo')
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2737 endif
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2738 endfunc
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2739
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2740 func ShowInfo(...)
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2741 let id = popup_findinfo()
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2742 if id
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2743 call popup_settext(id, 'async info ' .. s:counter)
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2744 call popup_show(id)
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2745 endif
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2746 endfunc
17767
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2747 END
17811
b5499bf22a97 patch 8.1.1902: cannot have an info popup without a border
Bram Moolenaar <Bram@vim.org>
parents: 17771
diff changeset
2748 return lines
b5499bf22a97 patch 8.1.1902: cannot have an info popup without a border
Bram Moolenaar <Bram@vim.org>
parents: 17771
diff changeset
2749 endfunc
b5499bf22a97 patch 8.1.1902: cannot have an info popup without a border
Bram Moolenaar <Bram@vim.org>
parents: 17771
diff changeset
2750
b5499bf22a97 patch 8.1.1902: cannot have an info popup without a border
Bram Moolenaar <Bram@vim.org>
parents: 17771
diff changeset
2751 func Test_popupmenu_info_border()
b5499bf22a97 patch 8.1.1902: cannot have an info popup without a border
Bram Moolenaar <Bram@vim.org>
parents: 17771
diff changeset
2752 CheckScreendump
b5499bf22a97 patch 8.1.1902: cannot have an info popup without a border
Bram Moolenaar <Bram@vim.org>
parents: 17771
diff changeset
2753
b5499bf22a97 patch 8.1.1902: cannot have an info popup without a border
Bram Moolenaar <Bram@vim.org>
parents: 17771
diff changeset
2754 let lines = Get_popupmenu_lines()
b5499bf22a97 patch 8.1.1902: cannot have an info popup without a border
Bram Moolenaar <Bram@vim.org>
parents: 17771
diff changeset
2755 call add(lines, 'set completepopup=height:4,highlight:InfoPopup')
17767
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2756 call writefile(lines, 'XtestInfoPopup')
17811
b5499bf22a97 patch 8.1.1902: cannot have an info popup without a border
Bram Moolenaar <Bram@vim.org>
parents: 17771
diff changeset
2757
17767
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2758 let buf = RunVimInTerminal('-S XtestInfoPopup', #{rows: 14})
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2759 call term_wait(buf, 50)
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2760
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2761 call term_sendkeys(buf, "A\<C-X>\<C-U>")
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2762 call VerifyScreenDump(buf, 'Test_popupwin_infopopup_1', {})
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2763
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2764 call term_sendkeys(buf, "\<C-N>")
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2765 call VerifyScreenDump(buf, 'Test_popupwin_infopopup_2', {})
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2766
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2767 call term_sendkeys(buf, "\<C-N>")
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2768 call VerifyScreenDump(buf, 'Test_popupwin_infopopup_3', {})
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2769
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2770 call term_sendkeys(buf, "\<C-N>\<C-N>")
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2771 call VerifyScreenDump(buf, 'Test_popupwin_infopopup_4', {})
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2772
17821
fe92aaf166c1 patch 8.1.1907: wrong position for info popup with scrollbar on the left
Bram Moolenaar <Bram@vim.org>
parents: 17817
diff changeset
2773 " info on the left with scrollbar
fe92aaf166c1 patch 8.1.1907: wrong position for info popup with scrollbar on the left
Bram Moolenaar <Bram@vim.org>
parents: 17817
diff changeset
2774 call term_sendkeys(buf, "test text test text\<C-X>\<C-U>")
fe92aaf166c1 patch 8.1.1907: wrong position for info popup with scrollbar on the left
Bram Moolenaar <Bram@vim.org>
parents: 17817
diff changeset
2775 call term_sendkeys(buf, "\<C-N>\<C-N>")
fe92aaf166c1 patch 8.1.1907: wrong position for info popup with scrollbar on the left
Bram Moolenaar <Bram@vim.org>
parents: 17817
diff changeset
2776 call VerifyScreenDump(buf, 'Test_popupwin_infopopup_5', {})
fe92aaf166c1 patch 8.1.1907: wrong position for info popup with scrollbar on the left
Bram Moolenaar <Bram@vim.org>
parents: 17817
diff changeset
2777
17767
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2778 call StopVimInTerminal(buf)
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2779 call delete('XtestInfoPopup')
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2780 endfunc
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17754
diff changeset
2781
17811
b5499bf22a97 patch 8.1.1902: cannot have an info popup without a border
Bram Moolenaar <Bram@vim.org>
parents: 17771
diff changeset
2782 func Test_popupmenu_info_noborder()
b5499bf22a97 patch 8.1.1902: cannot have an info popup without a border
Bram Moolenaar <Bram@vim.org>
parents: 17771
diff changeset
2783 CheckScreendump
b5499bf22a97 patch 8.1.1902: cannot have an info popup without a border
Bram Moolenaar <Bram@vim.org>
parents: 17771
diff changeset
2784
b5499bf22a97 patch 8.1.1902: cannot have an info popup without a border
Bram Moolenaar <Bram@vim.org>
parents: 17771
diff changeset
2785 let lines = Get_popupmenu_lines()
b5499bf22a97 patch 8.1.1902: cannot have an info popup without a border
Bram Moolenaar <Bram@vim.org>
parents: 17771
diff changeset
2786 call add(lines, 'set completepopup=height:4,border:off')
b5499bf22a97 patch 8.1.1902: cannot have an info popup without a border
Bram Moolenaar <Bram@vim.org>
parents: 17771
diff changeset
2787 call writefile(lines, 'XtestInfoPopupNb')
b5499bf22a97 patch 8.1.1902: cannot have an info popup without a border
Bram Moolenaar <Bram@vim.org>
parents: 17771
diff changeset
2788
b5499bf22a97 patch 8.1.1902: cannot have an info popup without a border
Bram Moolenaar <Bram@vim.org>
parents: 17771
diff changeset
2789 let buf = RunVimInTerminal('-S XtestInfoPopupNb', #{rows: 14})
b5499bf22a97 patch 8.1.1902: cannot have an info popup without a border
Bram Moolenaar <Bram@vim.org>
parents: 17771
diff changeset
2790 call term_wait(buf, 50)
b5499bf22a97 patch 8.1.1902: cannot have an info popup without a border
Bram Moolenaar <Bram@vim.org>
parents: 17771
diff changeset
2791
b5499bf22a97 patch 8.1.1902: cannot have an info popup without a border
Bram Moolenaar <Bram@vim.org>
parents: 17771
diff changeset
2792 call term_sendkeys(buf, "A\<C-X>\<C-U>")
b5499bf22a97 patch 8.1.1902: cannot have an info popup without a border
Bram Moolenaar <Bram@vim.org>
parents: 17771
diff changeset
2793 call VerifyScreenDump(buf, 'Test_popupwin_infopopup_nb_1', {})
b5499bf22a97 patch 8.1.1902: cannot have an info popup without a border
Bram Moolenaar <Bram@vim.org>
parents: 17771
diff changeset
2794
b5499bf22a97 patch 8.1.1902: cannot have an info popup without a border
Bram Moolenaar <Bram@vim.org>
parents: 17771
diff changeset
2795 call StopVimInTerminal(buf)
b5499bf22a97 patch 8.1.1902: cannot have an info popup without a border
Bram Moolenaar <Bram@vim.org>
parents: 17771
diff changeset
2796 call delete('XtestInfoPopupNb')
b5499bf22a97 patch 8.1.1902: cannot have an info popup without a border
Bram Moolenaar <Bram@vim.org>
parents: 17771
diff changeset
2797 endfunc
b5499bf22a97 patch 8.1.1902: cannot have an info popup without a border
Bram Moolenaar <Bram@vim.org>
parents: 17771
diff changeset
2798
17815
9ec2526c04c5 patch 8.1.1904: cannot have an info popup align with the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17811
diff changeset
2799 func Test_popupmenu_info_align_menu()
9ec2526c04c5 patch 8.1.1904: cannot have an info popup align with the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17811
diff changeset
2800 CheckScreendump
9ec2526c04c5 patch 8.1.1904: cannot have an info popup align with the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17811
diff changeset
2801
9ec2526c04c5 patch 8.1.1904: cannot have an info popup align with the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17811
diff changeset
2802 let lines = Get_popupmenu_lines()
9ec2526c04c5 patch 8.1.1904: cannot have an info popup align with the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17811
diff changeset
2803 call add(lines, 'set completepopup=height:4,border:off,align:menu')
9ec2526c04c5 patch 8.1.1904: cannot have an info popup align with the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17811
diff changeset
2804 call writefile(lines, 'XtestInfoPopupNb')
9ec2526c04c5 patch 8.1.1904: cannot have an info popup align with the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17811
diff changeset
2805
9ec2526c04c5 patch 8.1.1904: cannot have an info popup align with the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17811
diff changeset
2806 let buf = RunVimInTerminal('-S XtestInfoPopupNb', #{rows: 14})
9ec2526c04c5 patch 8.1.1904: cannot have an info popup align with the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17811
diff changeset
2807 call term_wait(buf, 50)
9ec2526c04c5 patch 8.1.1904: cannot have an info popup align with the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17811
diff changeset
2808
9ec2526c04c5 patch 8.1.1904: cannot have an info popup align with the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17811
diff changeset
2809 call term_sendkeys(buf, "A\<C-X>\<C-U>")
9ec2526c04c5 patch 8.1.1904: cannot have an info popup align with the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17811
diff changeset
2810 call term_sendkeys(buf, "\<C-N>")
9ec2526c04c5 patch 8.1.1904: cannot have an info popup align with the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17811
diff changeset
2811 call term_sendkeys(buf, "\<C-N>")
9ec2526c04c5 patch 8.1.1904: cannot have an info popup align with the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17811
diff changeset
2812 call term_sendkeys(buf, "\<C-N>")
9ec2526c04c5 patch 8.1.1904: cannot have an info popup align with the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17811
diff changeset
2813 call VerifyScreenDump(buf, 'Test_popupwin_infopopup_align_1', {})
9ec2526c04c5 patch 8.1.1904: cannot have an info popup align with the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17811
diff changeset
2814
9ec2526c04c5 patch 8.1.1904: cannot have an info popup align with the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17811
diff changeset
2815 call term_sendkeys(buf, "test text test text test\<C-X>\<C-U>")
9ec2526c04c5 patch 8.1.1904: cannot have an info popup align with the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17811
diff changeset
2816 call term_sendkeys(buf, "\<C-N>")
9ec2526c04c5 patch 8.1.1904: cannot have an info popup align with the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17811
diff changeset
2817 call VerifyScreenDump(buf, 'Test_popupwin_infopopup_align_2', {})
9ec2526c04c5 patch 8.1.1904: cannot have an info popup align with the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17811
diff changeset
2818
9ec2526c04c5 patch 8.1.1904: cannot have an info popup align with the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17811
diff changeset
2819 call term_sendkeys(buf, "\<Esc>")
17817
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
2820 call term_sendkeys(buf, ":call ChangeColor()\<CR>")
17815
9ec2526c04c5 patch 8.1.1904: cannot have an info popup align with the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17811
diff changeset
2821 call term_sendkeys(buf, ":call setline(2, ['x']->repeat(10))\<CR>")
9ec2526c04c5 patch 8.1.1904: cannot have an info popup align with the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17811
diff changeset
2822 call term_sendkeys(buf, "Gotest text test text\<C-X>\<C-U>")
9ec2526c04c5 patch 8.1.1904: cannot have an info popup align with the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17811
diff changeset
2823 call VerifyScreenDump(buf, 'Test_popupwin_infopopup_align_3', {})
9ec2526c04c5 patch 8.1.1904: cannot have an info popup align with the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17811
diff changeset
2824
9ec2526c04c5 patch 8.1.1904: cannot have an info popup align with the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17811
diff changeset
2825 call StopVimInTerminal(buf)
9ec2526c04c5 patch 8.1.1904: cannot have an info popup align with the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17811
diff changeset
2826 call delete('XtestInfoPopupNb')
9ec2526c04c5 patch 8.1.1904: cannot have an info popup align with the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17811
diff changeset
2827 endfunc
9ec2526c04c5 patch 8.1.1904: cannot have an info popup align with the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17811
diff changeset
2828
18396
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2829 func Test_popupmenu_info_hidden()
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2830 CheckScreendump
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2831
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2832 let lines = Get_popupmenu_lines()
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2833 call add(lines, 'call InfoHidden()')
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2834 call writefile(lines, 'XtestInfoPopupHidden')
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2835
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2836 let buf = RunVimInTerminal('-S XtestInfoPopupHidden', #{rows: 14})
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2837 call term_wait(buf, 50)
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2838
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2839 call term_sendkeys(buf, "A\<C-X>\<C-U>")
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2840 call VerifyScreenDump(buf, 'Test_popupwin_infopopup_hidden_1', {})
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2841
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2842 call term_sendkeys(buf, "\<C-N>")
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2843 call VerifyScreenDump(buf, 'Test_popupwin_infopopup_hidden_2', {})
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2844
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2845 call term_sendkeys(buf, "\<C-N>")
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2846 call VerifyScreenDump(buf, 'Test_popupwin_infopopup_hidden_3', {})
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2847
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2848 call term_sendkeys(buf, "\<Esc>")
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2849 call StopVimInTerminal(buf)
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2850 call delete('XtestInfoPopupHidden')
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2851 endfunc
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2852
17823
7e6b7a4f13bc patch 8.1.1908: every popup window consumes a buffer number
Bram Moolenaar <Bram@vim.org>
parents: 17821
diff changeset
2853 func Test_popupwin_recycle_bnr()
17825
ce993ba17adb patch 8.1.1909: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17823
diff changeset
2854 let bufnr = popup_notification('nothing wrong', {})->winbufnr()
17823
7e6b7a4f13bc patch 8.1.1908: every popup window consumes a buffer number
Bram Moolenaar <Bram@vim.org>
parents: 17821
diff changeset
2855 call popup_clear()
17972
a170c48e0f91 patch 8.1.1982: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17946
diff changeset
2856 let winid = 'nothing wrong'->popup_notification({})
17823
7e6b7a4f13bc patch 8.1.1908: every popup window consumes a buffer number
Bram Moolenaar <Bram@vim.org>
parents: 17821
diff changeset
2857 call assert_equal(bufnr, winbufnr(winid))
7e6b7a4f13bc patch 8.1.1908: every popup window consumes a buffer number
Bram Moolenaar <Bram@vim.org>
parents: 17821
diff changeset
2858 call popup_clear()
7e6b7a4f13bc patch 8.1.1908: every popup window consumes a buffer number
Bram Moolenaar <Bram@vim.org>
parents: 17821
diff changeset
2859 endfunc
7e6b7a4f13bc patch 8.1.1908: every popup window consumes a buffer number
Bram Moolenaar <Bram@vim.org>
parents: 17821
diff changeset
2860
18229
e6c83ae0c4d0 patch 8.1.2109: popup_getoptions() hangs with tab-local popup
Bram Moolenaar <Bram@vim.org>
parents: 18168
diff changeset
2861 func Test_popupwin_getoptions_tablocal()
e6c83ae0c4d0 patch 8.1.2109: popup_getoptions() hangs with tab-local popup
Bram Moolenaar <Bram@vim.org>
parents: 18168
diff changeset
2862 topleft split
e6c83ae0c4d0 patch 8.1.2109: popup_getoptions() hangs with tab-local popup
Bram Moolenaar <Bram@vim.org>
parents: 18168
diff changeset
2863 let win1 = popup_create('nothing', #{maxheight: 8})
e6c83ae0c4d0 patch 8.1.2109: popup_getoptions() hangs with tab-local popup
Bram Moolenaar <Bram@vim.org>
parents: 18168
diff changeset
2864 let win2 = popup_create('something', #{maxheight: 10})
e6c83ae0c4d0 patch 8.1.2109: popup_getoptions() hangs with tab-local popup
Bram Moolenaar <Bram@vim.org>
parents: 18168
diff changeset
2865 let win3 = popup_create('something', #{maxheight: 15})
e6c83ae0c4d0 patch 8.1.2109: popup_getoptions() hangs with tab-local popup
Bram Moolenaar <Bram@vim.org>
parents: 18168
diff changeset
2866 call assert_equal(8, popup_getoptions(win1).maxheight)
e6c83ae0c4d0 patch 8.1.2109: popup_getoptions() hangs with tab-local popup
Bram Moolenaar <Bram@vim.org>
parents: 18168
diff changeset
2867 call assert_equal(10, popup_getoptions(win2).maxheight)
e6c83ae0c4d0 patch 8.1.2109: popup_getoptions() hangs with tab-local popup
Bram Moolenaar <Bram@vim.org>
parents: 18168
diff changeset
2868 call assert_equal(15, popup_getoptions(win3).maxheight)
e6c83ae0c4d0 patch 8.1.2109: popup_getoptions() hangs with tab-local popup
Bram Moolenaar <Bram@vim.org>
parents: 18168
diff changeset
2869 call popup_clear()
e6c83ae0c4d0 patch 8.1.2109: popup_getoptions() hangs with tab-local popup
Bram Moolenaar <Bram@vim.org>
parents: 18168
diff changeset
2870 quit
e6c83ae0c4d0 patch 8.1.2109: popup_getoptions() hangs with tab-local popup
Bram Moolenaar <Bram@vim.org>
parents: 18168
diff changeset
2871 endfunc
e6c83ae0c4d0 patch 8.1.2109: popup_getoptions() hangs with tab-local popup
Bram Moolenaar <Bram@vim.org>
parents: 18168
diff changeset
2872
18231
25535ef50842 patch 8.1.2110: CTRL-C closes two popups instead of one
Bram Moolenaar <Bram@vim.org>
parents: 18229
diff changeset
2873 func Test_popupwin_cancel()
25535ef50842 patch 8.1.2110: CTRL-C closes two popups instead of one
Bram Moolenaar <Bram@vim.org>
parents: 18229
diff changeset
2874 let win1 = popup_create('one', #{line: 5, filter: {... -> 0}})
25535ef50842 patch 8.1.2110: CTRL-C closes two popups instead of one
Bram Moolenaar <Bram@vim.org>
parents: 18229
diff changeset
2875 let win2 = popup_create('two', #{line: 10, filter: {... -> 0}})
25535ef50842 patch 8.1.2110: CTRL-C closes two popups instead of one
Bram Moolenaar <Bram@vim.org>
parents: 18229
diff changeset
2876 let win3 = popup_create('three', #{line: 15, filter: {... -> 0}})
25535ef50842 patch 8.1.2110: CTRL-C closes two popups instead of one
Bram Moolenaar <Bram@vim.org>
parents: 18229
diff changeset
2877 call assert_equal(5, popup_getpos(win1).line)
25535ef50842 patch 8.1.2110: CTRL-C closes two popups instead of one
Bram Moolenaar <Bram@vim.org>
parents: 18229
diff changeset
2878 call assert_equal(10, popup_getpos(win2).line)
25535ef50842 patch 8.1.2110: CTRL-C closes two popups instead of one
Bram Moolenaar <Bram@vim.org>
parents: 18229
diff changeset
2879 call assert_equal(15, popup_getpos(win3).line)
25535ef50842 patch 8.1.2110: CTRL-C closes two popups instead of one
Bram Moolenaar <Bram@vim.org>
parents: 18229
diff changeset
2880 " TODO: this also works without patch 8.1.2110
25535ef50842 patch 8.1.2110: CTRL-C closes two popups instead of one
Bram Moolenaar <Bram@vim.org>
parents: 18229
diff changeset
2881 call feedkeys("\<C-C>", 'xt')
25535ef50842 patch 8.1.2110: CTRL-C closes two popups instead of one
Bram Moolenaar <Bram@vim.org>
parents: 18229
diff changeset
2882 call assert_equal(5, popup_getpos(win1).line)
25535ef50842 patch 8.1.2110: CTRL-C closes two popups instead of one
Bram Moolenaar <Bram@vim.org>
parents: 18229
diff changeset
2883 call assert_equal(10, popup_getpos(win2).line)
25535ef50842 patch 8.1.2110: CTRL-C closes two popups instead of one
Bram Moolenaar <Bram@vim.org>
parents: 18229
diff changeset
2884 call assert_equal({}, popup_getpos(win3))
25535ef50842 patch 8.1.2110: CTRL-C closes two popups instead of one
Bram Moolenaar <Bram@vim.org>
parents: 18229
diff changeset
2885 call feedkeys("\<C-C>", 'xt')
25535ef50842 patch 8.1.2110: CTRL-C closes two popups instead of one
Bram Moolenaar <Bram@vim.org>
parents: 18229
diff changeset
2886 call assert_equal(5, popup_getpos(win1).line)
25535ef50842 patch 8.1.2110: CTRL-C closes two popups instead of one
Bram Moolenaar <Bram@vim.org>
parents: 18229
diff changeset
2887 call assert_equal({}, popup_getpos(win2))
25535ef50842 patch 8.1.2110: CTRL-C closes two popups instead of one
Bram Moolenaar <Bram@vim.org>
parents: 18229
diff changeset
2888 call assert_equal({}, popup_getpos(win3))
25535ef50842 patch 8.1.2110: CTRL-C closes two popups instead of one
Bram Moolenaar <Bram@vim.org>
parents: 18229
diff changeset
2889 call feedkeys("\<C-C>", 'xt')
25535ef50842 patch 8.1.2110: CTRL-C closes two popups instead of one
Bram Moolenaar <Bram@vim.org>
parents: 18229
diff changeset
2890 call assert_equal({}, popup_getpos(win1))
25535ef50842 patch 8.1.2110: CTRL-C closes two popups instead of one
Bram Moolenaar <Bram@vim.org>
parents: 18229
diff changeset
2891 call assert_equal({}, popup_getpos(win2))
25535ef50842 patch 8.1.2110: CTRL-C closes two popups instead of one
Bram Moolenaar <Bram@vim.org>
parents: 18229
diff changeset
2892 call assert_equal({}, popup_getpos(win3))
25535ef50842 patch 8.1.2110: CTRL-C closes two popups instead of one
Bram Moolenaar <Bram@vim.org>
parents: 18229
diff changeset
2893 endfunc
25535ef50842 patch 8.1.2110: CTRL-C closes two popups instead of one
Bram Moolenaar <Bram@vim.org>
parents: 18229
diff changeset
2894
17442
57b9fca8c7d2 patch 8.1.1719: popup too wide when 'showbreak' is set
Bram Moolenaar <Bram@vim.org>
parents: 17438
diff changeset
2895 " vim: shiftwidth=2 sts=2