annotate src/testdir/test_popupwin.vim @ 17387:2558f90045e5 v8.1.1692

patch 8.1.1692: using *{} for literal dict is not backwards compatible commit https://github.com/vim/vim/commit/b8be54dcc517c9d57b62409945b7d4b90b6c3071 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jul 14 18:22:59 2019 +0200 patch 8.1.1692: using *{} for literal dict is not backwards compatible Problem: Using *{} for literal dict is not backwards compatible. (Yasuhiro Matsumoto) Solution: Use ~{} instead.
author Bram Moolenaar <Bram@vim.org>
date Sun, 14 Jul 2019 18:30:04 +0200
parents 6604ecb7a615
children 40417757dffd
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()
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
9 if !CanRunVimInTerminal()
16965
ba7727889385 patch 8.1.1483: skipped tests are not properly listed
Bram Moolenaar <Bram@vim.org>
parents: 16908
diff changeset
10 throw 'Skipped: cannot make screendumps'
16778
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
11 endif
17172
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
12 let lines =<< trim END
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
13 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
14 hi PopupColor1 ctermbg=lightblue
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
15 hi PopupColor2 ctermbg=lightcyan
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
16 hi Comment ctermfg=red
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
17 call prop_type_add('comment', ~{highlight: 'Comment'})
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
18 let winid = popup_create('hello there', ~{line: 3, col: 11, minwidth: 20, highlight: 'PopupColor1'})
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
19 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
20 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
21 END
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
22 call writefile(lines, 'XtestPopup')
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
23 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
24 call VerifyScreenDump(buf, 'Test_popupwin_01', {})
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
25
16794
ddfa924df50d patch 8.1.1399: popup windows not adjusted when switching tabs
Bram Moolenaar <Bram@vim.org>
parents: 16778
diff changeset
26 " Add a tabpage
ddfa924df50d patch 8.1.1399: popup windows not adjusted when switching tabs
Bram Moolenaar <Bram@vim.org>
parents: 16778
diff changeset
27 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
28 call term_sendkeys(buf, ":let popupwin = popup_create(["
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
29 \ .. "~{text: 'other tab'},"
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
30 \ .. "~{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
31 \ .. "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
32 \ .. "}]},"
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
33 \ .. "], ~{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
34 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
35
ddfa924df50d patch 8.1.1399: popup windows not adjusted when switching tabs
Bram Moolenaar <Bram@vim.org>
parents: 16778
diff changeset
36 " 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
37 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
38 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
39
ddfa924df50d patch 8.1.1399: popup windows not adjusted when switching tabs
Bram Moolenaar <Bram@vim.org>
parents: 16778
diff changeset
40 " close that tabpage
ddfa924df50d patch 8.1.1399: popup windows not adjusted when switching tabs
Bram Moolenaar <Bram@vim.org>
parents: 16778
diff changeset
41 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
42 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
43
17037
9297877074a3 patch 8.1.1518: crash when setting 'columns' while a popup is visible
Bram Moolenaar <Bram@vim.org>
parents: 17026
diff changeset
44 " 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
45 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
46 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
47 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
48 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
49
16839
032d5335987e patch 8.1.1421: drawing "~" line in popup window
Bram Moolenaar <Bram@vim.org>
parents: 16837
diff changeset
50 " resize popup, show empty line at bottom
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
51 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
52 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
53 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
54
16839
032d5335987e patch 8.1.1421: drawing "~" line in popup window
Bram Moolenaar <Bram@vim.org>
parents: 16837
diff changeset
55 " 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
56 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
57 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
58 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
59
16998
2ec0f953ec3f patch 8.1.1499: ruler not updated after popup window was removed
Bram Moolenaar <Bram@vim.org>
parents: 16965
diff changeset
60 " 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
61 call term_sendkeys(buf, ":set cmdheight=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
62 call term_sendkeys(buf, ":call popup_move(popupwin, ~{line: 7, col: 55})\<CR>")
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
63 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
64 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
65
2ec0f953ec3f patch 8.1.1499: ruler not updated after popup window was removed
Bram Moolenaar <Bram@vim.org>
parents: 16965
diff changeset
66 " 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
67 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
68 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
69 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
70 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
71 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
72 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
73
16778
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
74 " clean up
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
75 call StopVimInTerminal(buf)
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
76 call delete('XtestPopup')
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
77 endfunc
16800
12e3a3afdb6a patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents: 16794
diff changeset
78
16884
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
79 func Test_popup_with_border_and_padding()
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
80 if !CanRunVimInTerminal()
16965
ba7727889385 patch 8.1.1483: skipped tests are not properly listed
Bram Moolenaar <Bram@vim.org>
parents: 16908
diff changeset
81 throw 'Skipped: cannot make screendumps'
16884
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
82 endif
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
83
16886
2bd51fdcc793 patch 8.1.1444: not using double line characters for popup border
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
84 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
85 let lines =<< trim END
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
86 call setline(1, range(1, 100))
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
87 call popup_create('hello border', ~{line: 2, col: 3, border: []})
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
88 call popup_create('hello padding', ~{line: 2, col: 23, padding: []})
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
89 call popup_create('hello both', ~{line: 2, col: 43, border: [], padding: []})
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
90 call popup_create('border TL', ~{line: 6, col: 3, border: [1, 0, 0, 4]})
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
91 call popup_create('paddings', ~{line: 6, col: 23, padding: [1, 3, 2, 4]})
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
92 call popup_create('wrapped longer text', ~{line: 8, col: 55, padding: [0, 3, 0, 3], border: [0, 1, 0, 1]})
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
93 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
94 END
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
95 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
96 call writefile(lines, 'XtestPopupBorder')
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
97 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
98 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
99
2bd51fdcc793 patch 8.1.1444: not using double line characters for popup border
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
100 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
101 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
102 endfor
16884
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
103
17172
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
104 let lines =<< trim END
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
105 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
106 hi BlueColor ctermbg=lightblue
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
107 hi TopColor ctermbg=253
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
108 hi RightColor ctermbg=245
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
109 hi BottomColor ctermbg=240
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
110 hi LeftColor ctermbg=248
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
111 call popup_create('hello border', ~{line: 2, col: 3, border: [], borderhighlight: ['BlueColor']})
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
112 call popup_create(['hello border', 'and more'], ~{line: 2, col: 23, border: [], borderhighlight: ['TopColor', 'RightColor', 'BottomColor', 'LeftColor']})
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
113 call popup_create(['hello border', 'lines only'], ~{line: 2, col: 43, border: [], borderhighlight: ['BlueColor'], borderchars: ['x']})
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
114 call popup_create(['hello border', 'with corners'], ~{line: 2, col: 60, border: [], borderhighlight: ['BlueColor'], borderchars: ['x', '#']})
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
115 let winid = popup_create(['hello border', 'with numbers'], ~{line: 6, col: 3, border: [], borderhighlight: ['BlueColor'], borderchars: ['0', '1', '2', '3', '4', '5', '6', '7']})
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
116 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
117 func MultiByte()
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
118 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
119 endfunc
17172
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
120 END
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
121 call writefile(lines, 'XtestPopupBorder')
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
122 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
123 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
124
17125
b4eb06233448 patch 8.1.1562: popup window not always redrawn after popup_setoptions()
Bram Moolenaar <Bram@vim.org>
parents: 17123
diff changeset
125 " check that changing borderchars triggers a redraw
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
126 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
127 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
128
17312
484424955bfa patch 8.1.1655: popup window border drawn wrong with multi-byte char
Bram Moolenaar <Bram@vim.org>
parents: 17292
diff changeset
129 " 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
130 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
131 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
132 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
133 endif
484424955bfa patch 8.1.1655: popup window border drawn wrong with multi-byte char
Bram Moolenaar <Bram@vim.org>
parents: 17292
diff changeset
134
16888
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16886
diff changeset
135 call StopVimInTerminal(buf)
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16886
diff changeset
136 call delete('XtestPopupBorder')
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16886
diff changeset
137
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
138 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
139 \ line: 2,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
140 \ 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
141 \ col: 3,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
142 \ 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
143 \ width: 14,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
144 \ 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
145 \ height: 3,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
146 \ 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
147 \ firstline: 1,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
148 \ scrollbar: 0,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
149 \ visible: 1}
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
150 let winid = popup_create('hello border', ~{line: 2, col: 3, border: []})",
16884
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
151 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
152 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
153 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
154 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
155
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
156 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
157 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
158 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
159 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
160 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
161 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
162 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
163
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
164 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
165 \ 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
166 \ 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
167 \ 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
168 \ 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
169 \ })
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
170 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
171 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
172 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
173 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
174 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
175
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
176 let winid = popup_create('hello both', ~{line: 3, col: 8, border: [], padding: []})
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
177 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
178 \ line: 3,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
179 \ 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
180 \ col: 8,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
181 \ 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
182 \ width: 14,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
183 \ 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
184 \ height: 5,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
185 \ scrollbar: 0,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
186 \ 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
187 \ firstline: 1,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
188 \ 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
189
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
190 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
191 endfunc
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
192
16849
629f3d3b6886 patch 8.1.1426: no test for syntax highlight in popup window
Bram Moolenaar <Bram@vim.org>
parents: 16843
diff changeset
193 func Test_popup_with_syntax_win_execute()
629f3d3b6886 patch 8.1.1426: no test for syntax highlight in popup window
Bram Moolenaar <Bram@vim.org>
parents: 16843
diff changeset
194 if !CanRunVimInTerminal()
16965
ba7727889385 patch 8.1.1483: skipped tests are not properly listed
Bram Moolenaar <Bram@vim.org>
parents: 16908
diff changeset
195 throw 'Skipped: cannot make screendumps'
16849
629f3d3b6886 patch 8.1.1426: no test for syntax highlight in popup window
Bram Moolenaar <Bram@vim.org>
parents: 16843
diff changeset
196 endif
17172
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
197 let lines =<< trim END
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
198 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
199 hi PopupColor ctermbg=lightblue
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
200 let winid = popup_create([
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
201 \ '#include <stdio.h>',
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
202 \ 'int main(void)',
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
203 \ '{',
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
204 \ ' printf(123);',
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
205 \ '}',
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
206 \], ~{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
207 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
208 END
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
209 call writefile(lines, 'XtestPopup')
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
210 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
211 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
212
629f3d3b6886 patch 8.1.1426: no test for syntax highlight in popup window
Bram Moolenaar <Bram@vim.org>
parents: 16843
diff changeset
213 " clean up
629f3d3b6886 patch 8.1.1426: no test for syntax highlight in popup window
Bram Moolenaar <Bram@vim.org>
parents: 16843
diff changeset
214 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
215 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
216 endfunc
629f3d3b6886 patch 8.1.1426: no test for syntax highlight in popup window
Bram Moolenaar <Bram@vim.org>
parents: 16843
diff changeset
217
629f3d3b6886 patch 8.1.1426: no test for syntax highlight in popup window
Bram Moolenaar <Bram@vim.org>
parents: 16843
diff changeset
218 func Test_popup_with_syntax_setbufvar()
629f3d3b6886 patch 8.1.1426: no test for syntax highlight in popup window
Bram Moolenaar <Bram@vim.org>
parents: 16843
diff changeset
219 if !CanRunVimInTerminal()
16965
ba7727889385 patch 8.1.1483: skipped tests are not properly listed
Bram Moolenaar <Bram@vim.org>
parents: 16908
diff changeset
220 throw 'Skipped: cannot make screendumps'
16849
629f3d3b6886 patch 8.1.1426: no test for syntax highlight in popup window
Bram Moolenaar <Bram@vim.org>
parents: 16843
diff changeset
221 endif
16857
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
222 let lines =<< trim END
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
223 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
224 hi PopupColor ctermbg=lightgrey
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
225 let winid = popup_create([
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
226 \ '#include <stdio.h>',
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
227 \ 'int main(void)',
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
228 \ '{',
17314
b60402471f69 patch 8.1.1656: popup window width is wrong when using Tabs
Bram Moolenaar <Bram@vim.org>
parents: 17312
diff changeset
229 \ "\tprintf(567);",
16857
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
230 \ '}',
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
231 \], ~{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
232 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
233 END
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
234 call writefile(lines, 'XtestPopup')
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
235 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
236 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
237
629f3d3b6886 patch 8.1.1426: no test for syntax highlight in popup window
Bram Moolenaar <Bram@vim.org>
parents: 16843
diff changeset
238 " clean up
629f3d3b6886 patch 8.1.1426: no test for syntax highlight in popup window
Bram Moolenaar <Bram@vim.org>
parents: 16843
diff changeset
239 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
240 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
241 endfunc
629f3d3b6886 patch 8.1.1426: no test for syntax highlight in popup window
Bram Moolenaar <Bram@vim.org>
parents: 16843
diff changeset
242
17022
79c3a52fdb07 patch 8.1.1511: matches in a popup window are not displayed properly
Bram Moolenaar <Bram@vim.org>
parents: 16998
diff changeset
243 func Test_popup_with_matches()
79c3a52fdb07 patch 8.1.1511: matches in a popup window are not displayed properly
Bram Moolenaar <Bram@vim.org>
parents: 16998
diff changeset
244 if !CanRunVimInTerminal()
79c3a52fdb07 patch 8.1.1511: matches in a popup window are not displayed properly
Bram Moolenaar <Bram@vim.org>
parents: 16998
diff changeset
245 throw 'Skipped: cannot make screendumps'
79c3a52fdb07 patch 8.1.1511: matches in a popup window are not displayed properly
Bram Moolenaar <Bram@vim.org>
parents: 16998
diff changeset
246 endif
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',
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
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
79c3a52fdb07 patch 8.1.1511: matches in a popup window are not displayed properly
Bram Moolenaar <Bram@vim.org>
parents: 16998
diff changeset
254 /666
79c3a52fdb07 patch 8.1.1511: matches in a popup window are not displayed properly
Bram Moolenaar <Bram@vim.org>
parents: 16998
diff changeset
255 call matchadd('ErrorMsg', '111')
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', '444')
79c3a52fdb07 patch 8.1.1511: matches in a popup window are not displayed properly
Bram Moolenaar <Bram@vim.org>
parents: 16998
diff changeset
257 call win_execute(winid, "call matchadd('ErrorMsg', '111')")
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', '555')")
79c3a52fdb07 patch 8.1.1511: matches in a popup window are not displayed properly
Bram Moolenaar <Bram@vim.org>
parents: 16998
diff changeset
259 END
79c3a52fdb07 patch 8.1.1511: matches in a popup window are not displayed properly
Bram Moolenaar <Bram@vim.org>
parents: 16998
diff changeset
260 call writefile(lines, 'XtestPopupMatches')
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
261 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
262 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
263
79c3a52fdb07 patch 8.1.1511: matches in a popup window are not displayed properly
Bram Moolenaar <Bram@vim.org>
parents: 16998
diff changeset
264 " 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
265 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
266 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
267 endfunc
79c3a52fdb07 patch 8.1.1511: matches in a popup window are not displayed properly
Bram Moolenaar <Bram@vim.org>
parents: 16998
diff changeset
268
16898
16fd1bb2e675 patch 8.1.1450: popup window positioning wrong when using padding or borders
Bram Moolenaar <Bram@vim.org>
parents: 16896
diff changeset
269 func Test_popup_all_corners()
16fd1bb2e675 patch 8.1.1450: popup window positioning wrong when using padding or borders
Bram Moolenaar <Bram@vim.org>
parents: 16896
diff changeset
270 if !CanRunVimInTerminal()
16965
ba7727889385 patch 8.1.1483: skipped tests are not properly listed
Bram Moolenaar <Bram@vim.org>
parents: 16908
diff changeset
271 throw 'Skipped: cannot make screendumps'
16898
16fd1bb2e675 patch 8.1.1450: popup window positioning wrong when using padding or borders
Bram Moolenaar <Bram@vim.org>
parents: 16896
diff changeset
272 endif
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#
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
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 \ })
16fd1bb2e675 patch 8.1.1450: popup window positioning wrong when using padding or borders
Bram Moolenaar <Bram@vim.org>
parents: 16896
diff changeset
284 normal 25|r@
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
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 \ })
16fd1bb2e675 patch 8.1.1450: popup window positioning wrong when using padding or borders
Bram Moolenaar <Bram@vim.org>
parents: 16896
diff changeset
292 normal 9G29|r%
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
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 \ })
16fd1bb2e675 patch 8.1.1450: popup window positioning wrong when using padding or borders
Bram Moolenaar <Bram@vim.org>
parents: 16896
diff changeset
300 normal 51|r&
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
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 \ })
16fd1bb2e675 patch 8.1.1450: popup window positioning wrong when using padding or borders
Bram Moolenaar <Bram@vim.org>
parents: 16896
diff changeset
308 END
16fd1bb2e675 patch 8.1.1450: popup window positioning wrong when using padding or borders
Bram Moolenaar <Bram@vim.org>
parents: 16896
diff changeset
309 call writefile(lines, 'XtestPopupCorners')
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
310 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
311 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
312
16fd1bb2e675 patch 8.1.1450: popup window positioning wrong when using padding or borders
Bram Moolenaar <Bram@vim.org>
parents: 16896
diff changeset
313 " 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
314 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
315 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
316 endfunc
16fd1bb2e675 patch 8.1.1450: popup window positioning wrong when using padding or borders
Bram Moolenaar <Bram@vim.org>
parents: 16896
diff changeset
317
17047
6400d1ad5e4b patch 8.1.1523: cannot show range of buffer lines in popup window
Bram Moolenaar <Bram@vim.org>
parents: 17045
diff changeset
318 func Test_popup_firstline()
6400d1ad5e4b patch 8.1.1523: cannot show range of buffer lines in popup window
Bram Moolenaar <Bram@vim.org>
parents: 17045
diff changeset
319 if !CanRunVimInTerminal()
6400d1ad5e4b patch 8.1.1523: cannot show range of buffer lines in popup window
Bram Moolenaar <Bram@vim.org>
parents: 17045
diff changeset
320 throw 'Skipped: cannot make screendumps'
6400d1ad5e4b patch 8.1.1523: cannot show range of buffer lines in popup window
Bram Moolenaar <Bram@vim.org>
parents: 17045
diff changeset
321 endif
6400d1ad5e4b patch 8.1.1523: cannot show range of buffer lines in popup window
Bram Moolenaar <Bram@vim.org>
parents: 17045
diff changeset
322 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
323 call setline(1, range(1, 20))
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
324 call 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
325 \ maxheight: 4,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
326 \ 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
327 \ })
6400d1ad5e4b patch 8.1.1523: cannot show range of buffer lines in popup window
Bram Moolenaar <Bram@vim.org>
parents: 17045
diff changeset
328 END
6400d1ad5e4b patch 8.1.1523: cannot show range of buffer lines in popup window
Bram Moolenaar <Bram@vim.org>
parents: 17045
diff changeset
329 call writefile(lines, 'XtestPopupFirstline')
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
330 let buf = RunVimInTerminal('-S XtestPopupFirstline', ~{rows: 10})
17047
6400d1ad5e4b patch 8.1.1523: cannot show range of buffer lines in popup window
Bram Moolenaar <Bram@vim.org>
parents: 17045
diff changeset
331 call VerifyScreenDump(buf, 'Test_popupwin_firstline', {})
6400d1ad5e4b patch 8.1.1523: cannot show range of buffer lines in popup window
Bram Moolenaar <Bram@vim.org>
parents: 17045
diff changeset
332
6400d1ad5e4b patch 8.1.1523: cannot show range of buffer lines in popup window
Bram Moolenaar <Bram@vim.org>
parents: 17045
diff changeset
333 " 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
334 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
335 call delete('XtestPopupFirstline')
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
336
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
337 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
338 \ maxheight: 2,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
339 \ firstline: 3,
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
340 \ })
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
341 call assert_equal(3, popup_getoptions(winid).firstline)
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
342 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
343 call assert_equal(1, popup_getoptions(winid).firstline)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
344
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
345 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
346 endfunc
6400d1ad5e4b patch 8.1.1523: cannot show range of buffer lines in popup window
Bram Moolenaar <Bram@vim.org>
parents: 17045
diff changeset
347
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
348 func Test_popup_drag()
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
349 if !CanRunVimInTerminal()
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
350 throw 'Skipped: cannot make screendumps'
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
351 endif
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
352 " 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
353 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
354 call setline(1, range(1, 20))
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
355 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
356 \ drag: 1,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
357 \ border: [],
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
358 \ 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
359 \ })
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
360 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
361 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
362 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
363 map <silent> <F3> :call test_setmouse(&lines - 4, &columns / 2)<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
364 map <silent> <F4> :call test_setmouse(&lines - 8, &columns / 2)<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
365 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
366 call writefile(lines, 'XtestPopupDrag')
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
367 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
368 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
369
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
370 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
371 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
372
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
373 " 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
374 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
375 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
376 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
377
17219
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
378 func Test_popup_close_with_mouse()
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
379 if !CanRunVimInTerminal()
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
380 throw 'Skipped: cannot make screendumps'
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
381 endif
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
382 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
383 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
384 " With border, can click on X
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
385 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
386 \ close: 'button',
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
387 \ border: [],
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
388 \ line: 1,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
389 \ 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
390 \ })
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
391 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
392 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
393 endfunc
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
394 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
395 \ close: 'click',
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
396 \ line: 3,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
397 \ col: 15,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
398 \ 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
399 \ })
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
400 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
401 \ close: 'button',
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
402 \ line: 5,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
403 \ 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
404 \ })
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
405 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
406 \ close: 'button',
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
407 \ padding: [],
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
408 \ line: 5,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
409 \ 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
410 \ })
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
411 func CloseWithX()
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
412 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
413 endfunc
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
414 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
415 func CloseWithClick()
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
416 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
417 endfunc
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
418 map <silent> <F4> :call test_setmouse(3, 17)<CR>
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
419 END
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
420 call writefile(lines, 'XtestPopupClose')
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
421 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
422 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
423
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
424 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
425 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
426
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
427 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
428 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
429
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
430 " clean up
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
431 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
432 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
433 endfunction
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
434
17172
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
435 func Test_popup_with_mask()
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
436 if !CanRunVimInTerminal()
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
437 throw 'Skipped: cannot make screendumps'
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
438 endif
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
439 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
440 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
441 hi PopupColor ctermbg=lightgrey
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
442 let winid = popup_create([
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
443 \ 'some text',
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
444 \ 'another line',
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
445 \], ~{
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
446 \ line: 1,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
447 \ col: 10,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
448 \ wrap: 0,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
449 \ fixed: 1,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
450 \ zindex: 90,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
451 \ padding: [],
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
452 \ highlight: 'PopupColor',
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
453 \ 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
454 call popup_create([
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
455 \ 'xxxxxxxxx',
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
456 \ 'yyyyyyyyy',
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
457 \], ~{
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
458 \ line: 3,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
459 \ col: 18,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
460 \ 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
461 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
462 \ 'just one line',
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
463 \], ~{
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
464 \ line: 7,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
465 \ col: 10,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
466 \ wrap: 0,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
467 \ fixed: 1,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
468 \ close: 'button',
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
469 \ zindex: 90,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
470 \ padding: [],
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
471 \ border: [],
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
472 \ 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
473 END
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
474 call writefile(lines, 'XtestPopupMask')
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
475 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
476 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
477
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
478 call term_sendkeys(buf, ":call popup_move(winid, ~{col: 11, line: 2})\<CR>")
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
479 call term_sendkeys(buf, ":call popup_move(winidb, ~{col: 12})\<CR>")
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
480 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
481 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
482
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
483 call term_sendkeys(buf, ":call popup_move(winid, ~{col: 65, line: 2})\<CR>")
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
484 call term_sendkeys(buf, ":call popup_move(winidb, ~{col: 63})\<CR>")
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
485 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
486 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
487
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
488 call term_sendkeys(buf, ":call popup_move(winid, ~{pos: 'topright', col: 12, line: 2})\<CR>")
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
489 call term_sendkeys(buf, ":call popup_move(winidb, ~{pos: 'topright', col: 12})\<CR>")
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
490 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
491 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
492
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
493 call term_sendkeys(buf, ":call popup_move(winid, ~{pos: 'topright', col: 12, line: 11})\<CR>")
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
494 call term_sendkeys(buf, ":call popup_move(winidb, ~{pos: 'topleft', col: 42, line: 11})\<CR>")
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
495 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
496 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
497
17172
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
498 " clean up
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
499 call StopVimInTerminal(buf)
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
500 call delete('XtestPopupMask')
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
501 endfunc
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
502
17069
76ae212a9075 patch 8.1.1534: modeless selection in popup window selects too much
Bram Moolenaar <Bram@vim.org>
parents: 17055
diff changeset
503 func Test_popup_select()
76ae212a9075 patch 8.1.1534: modeless selection in popup window selects too much
Bram Moolenaar <Bram@vim.org>
parents: 17055
diff changeset
504 if !CanRunVimInTerminal()
76ae212a9075 patch 8.1.1534: modeless selection in popup window selects too much
Bram Moolenaar <Bram@vim.org>
parents: 17055
diff changeset
505 throw 'Skipped: cannot make screendumps'
76ae212a9075 patch 8.1.1534: modeless selection in popup window selects too much
Bram Moolenaar <Bram@vim.org>
parents: 17055
diff changeset
506 endif
17071
57125309eef3 patch 8.1.1535: popup select test fails on Mac
Bram Moolenaar <Bram@vim.org>
parents: 17069
diff changeset
507 if !has('clipboard')
57125309eef3 patch 8.1.1535: popup select test fails on Mac
Bram Moolenaar <Bram@vim.org>
parents: 17069
diff changeset
508 throw 'Skipped: clipboard feature missing'
57125309eef3 patch 8.1.1535: popup select test fails on Mac
Bram Moolenaar <Bram@vim.org>
parents: 17069
diff changeset
509 endif
17069
76ae212a9075 patch 8.1.1534: modeless selection in popup window selects too much
Bram Moolenaar <Bram@vim.org>
parents: 17055
diff changeset
510 " 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
511 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
512 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
513 call setline(1, range(1, 20))
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
514 let winid = popup_create(['the word', 'some more', 'several words here'], ~{
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
515 \ drag: 1,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
516 \ border: [],
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
517 \ line: 3,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
518 \ col: 10,
17069
76ae212a9075 patch 8.1.1534: modeless selection in popup window selects too much
Bram Moolenaar <Bram@vim.org>
parents: 17055
diff changeset
519 \ })
76ae212a9075 patch 8.1.1534: modeless selection in popup window selects too much
Bram Moolenaar <Bram@vim.org>
parents: 17055
diff changeset
520 func Select1()
76ae212a9075 patch 8.1.1534: modeless selection in popup window selects too much
Bram Moolenaar <Bram@vim.org>
parents: 17055
diff changeset
521 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
522 endfunc
76ae212a9075 patch 8.1.1534: modeless selection in popup window selects too much
Bram Moolenaar <Bram@vim.org>
parents: 17055
diff changeset
523 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
524 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
525 END
76ae212a9075 patch 8.1.1534: modeless selection in popup window selects too much
Bram Moolenaar <Bram@vim.org>
parents: 17055
diff changeset
526 call writefile(lines, 'XtestPopupSelect')
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
527 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
528 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
529 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
530
76ae212a9075 patch 8.1.1534: modeless selection in popup window selects too much
Bram Moolenaar <Bram@vim.org>
parents: 17055
diff changeset
531 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
532 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
533 " 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
534 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
535
17069
76ae212a9075 patch 8.1.1534: modeless selection in popup window selects too much
Bram Moolenaar <Bram@vim.org>
parents: 17055
diff changeset
536 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
537
76ae212a9075 patch 8.1.1534: modeless selection in popup window selects too much
Bram Moolenaar <Bram@vim.org>
parents: 17055
diff changeset
538 " clean up
76ae212a9075 patch 8.1.1534: modeless selection in popup window selects too much
Bram Moolenaar <Bram@vim.org>
parents: 17055
diff changeset
539 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
540 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
541 endfunc
76ae212a9075 patch 8.1.1534: modeless selection in popup window selects too much
Bram Moolenaar <Bram@vim.org>
parents: 17055
diff changeset
542
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
543 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
544 " 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
545 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
546 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
547 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
548 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
549 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
550 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
551 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
552 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
553 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
554
d99805d25b42 patch 8.1.1521: when a popup window is closed the buffer remains
Bram Moolenaar <Bram@vim.org>
parents: 17037
diff changeset
555 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
556 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
557 " 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
558 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
559
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
560 " global popup is visible in any tab
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
561 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
562 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
563 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
564 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
565 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
566 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
567 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
568 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
569 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
570
c90fdb999393 patch 8.1.1574: tabpage option not yet implemented for popup window
Bram Moolenaar <Bram@vim.org>
parents: 17125
diff changeset
571 " 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
572 tabnew
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
573 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
574 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
575 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
576 quit
c90fdb999393 patch 8.1.1574: tabpage option not yet implemented for popup window
Bram Moolenaar <Bram@vim.org>
parents: 17125
diff changeset
577 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
578 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
579 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
580 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
581
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
582 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
583 " Zero value is like the property wasn't there
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
584 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
585 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
586 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
587 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
588
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
589 " using cursor column has minimum value of 1
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
590 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
591 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
592 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
593 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
594
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
595 " center
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
596 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
597 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
598 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
599 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
600 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
601 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
602 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
603 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
604
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
605 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
606 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
607 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
608 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
609 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
610
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
611 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
612 call popup_clear()
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
613 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
614 call popup_clear()
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
615 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
616 call popup_clear()
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
617 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
618 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
619
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
620 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
621 call popup_clear()
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
622 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
623 call popup_clear()
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
624 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
625 call popup_clear()
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
626 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
627 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
628
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
629 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
630 call popup_clear()
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
631 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
632 call popup_clear()
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
633 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
634 call popup_clear()
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
635 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
636 call popup_clear()
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
637 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
638 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
639
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
640 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
641 call popup_clear()
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
642 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
643 call popup_clear()
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
644 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
645 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
646 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
647
16863
2b00163053cd patch 8.1.1433: win_execute() may leave popup window focused
Bram Moolenaar <Bram@vim.org>
parents: 16859
diff changeset
648 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
649 split
2b00163053cd patch 8.1.1433: win_execute() may leave popup window focused
Bram Moolenaar <Bram@vim.org>
parents: 16859
diff changeset
650 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
651 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
652 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
653 endfunc
da5f5836e90c patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 16863
diff changeset
654
da5f5836e90c patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 16863
diff changeset
655 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
656 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
657 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
658 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
659 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
660 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
661 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
662 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
663 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
664 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
665 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
666 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
667 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
668 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
669 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
670 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
671 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
672 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
673 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
674 endfunc
2b00163053cd patch 8.1.1433: win_execute() may leave popup window focused
Bram Moolenaar <Bram@vim.org>
parents: 16859
diff changeset
675
16857
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
676 func Test_popup_with_wrap()
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
677 if !CanRunVimInTerminal()
16965
ba7727889385 patch 8.1.1483: skipped tests are not properly listed
Bram Moolenaar <Bram@vim.org>
parents: 16908
diff changeset
678 throw 'Skipped: cannot make screendumps'
16857
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
679 endif
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
680 let lines =<< trim END
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
681 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
682 let winid = popup_create(
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
683 \ 'a long line that wont fit',
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
684 \ ~{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
685 END
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
686 call writefile(lines, 'XtestPopup')
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
687 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
688 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
689
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
690 " clean up
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
691 call StopVimInTerminal(buf)
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
692 call delete('XtestPopup')
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
693 endfunc
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
694
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
695 func Test_popup_without_wrap()
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
696 if !CanRunVimInTerminal()
16965
ba7727889385 patch 8.1.1483: skipped tests are not properly listed
Bram Moolenaar <Bram@vim.org>
parents: 16908
diff changeset
697 throw 'Skipped: cannot make screendumps'
16857
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
698 endif
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
699 let lines =<< trim END
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
700 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
701 let winid = popup_create(
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
702 \ 'a long line that wont fit',
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
703 \ ~{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
704 END
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
705 call writefile(lines, 'XtestPopup')
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
706 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
707 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
708
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
709 " clean up
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
710 call StopVimInTerminal(buf)
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
711 call delete('XtestPopup')
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
712 endfunc
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
713
16800
12e3a3afdb6a patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents: 16794
diff changeset
714 func Test_popup_time()
16802
f5487021fdad patch 8.1.1403: cannot build without the timer feature
Bram Moolenaar <Bram@vim.org>
parents: 16800
diff changeset
715 if !has('timers')
17089
8e9e9124c7a2 patch 8.1.1544: some balloon tests don't run when they can
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
716 throw 'Skipped: timer feature not supported'
16802
f5487021fdad patch 8.1.1403: cannot build without the timer feature
Bram Moolenaar <Bram@vim.org>
parents: 16800
diff changeset
717 endif
16800
12e3a3afdb6a patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents: 16794
diff changeset
718 topleft vnew
12e3a3afdb6a patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents: 16794
diff changeset
719 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
720
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
721 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
722 \ line: 1,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
723 \ col: 1,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
724 \ minwidth: 20,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
725 \ time: 500,
16800
12e3a3afdb6a patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents: 16794
diff changeset
726 \})
12e3a3afdb6a patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents: 16794
diff changeset
727 redraw
12e3a3afdb6a patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents: 16794
diff changeset
728 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
729 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
730
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
731 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
732 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
733 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
734 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
735
16800
12e3a3afdb6a patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents: 16794
diff changeset
736 sleep 700m
16802
f5487021fdad patch 8.1.1403: cannot build without the timer feature
Bram Moolenaar <Bram@vim.org>
parents: 16800
diff changeset
737 redraw
16800
12e3a3afdb6a patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents: 16794
diff changeset
738 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
739 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
740
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
741 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
742 \ line: &lines,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
743 \ col: 10,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
744 \ minwidth: 20,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
745 \ time: 500,
16800
12e3a3afdb6a patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents: 16794
diff changeset
746 \})
12e3a3afdb6a patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents: 16794
diff changeset
747 redraw
12e3a3afdb6a patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents: 16794
diff changeset
748 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
749 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
750
12e3a3afdb6a patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents: 16794
diff changeset
751 sleep 700m
12e3a3afdb6a patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents: 16794
diff changeset
752 redraw
12e3a3afdb6a patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents: 16794
diff changeset
753 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
754 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
755
12e3a3afdb6a patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents: 16794
diff changeset
756 bwipe!
12e3a3afdb6a patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents: 16794
diff changeset
757 endfunc
16809
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
758
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
759 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
760 topleft vnew
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
761 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
762
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
763 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
764 \ line: 1,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
765 \ col: 1,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
766 \ 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
767 \})
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
768 redraw
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
769 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
770 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
771 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
772 " 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
773 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
774
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
775 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
776 redraw
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
777 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
778 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
779 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
780 " 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
781 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
782
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
783 call popup_show(winid)
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
784 redraw
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
785 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
786 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
787 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
788
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
789
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
790 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
791 redraw
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
792 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
793 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
794
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
795 " 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
796 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
797
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
798 " no error non-existing window
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
799 call popup_hide(1234234)
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
800 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
801
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
802 bwipe!
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
803 endfunc
16817
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16811
diff changeset
804
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16811
diff changeset
805 func Test_popup_move()
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16811
diff changeset
806 topleft vnew
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16811
diff changeset
807 call setline(1, 'hello')
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16811
diff changeset
808
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
809 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
810 \ line: 1,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
811 \ col: 1,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
812 \ minwidth: 20,
16817
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16811
diff changeset
813 \})
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16811
diff changeset
814 redraw
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16811
diff changeset
815 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
816 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
817
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
818 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
819 redraw
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16811
diff changeset
820 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
821 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
822 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
823 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
824
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
825 call popup_move(winid, ~{line: 1})
16817
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16811
diff changeset
826 redraw
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16811
diff changeset
827 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
828 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
829
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16811
diff changeset
830 call popup_close(winid)
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16811
diff changeset
831
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16811
diff changeset
832 bwipe!
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16811
diff changeset
833 endfunc
16829
5cebaecad422 patch 8.1.1416: popup_getposition() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16817
diff changeset
834
16857
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
835 func Test_popup_getpos()
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
836 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
837 \ line: 2,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
838 \ col: 3,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
839 \ minwidth: 10,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
840 \ minheight: 11,
16829
5cebaecad422 patch 8.1.1416: popup_getposition() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16817
diff changeset
841 \})
5cebaecad422 patch 8.1.1416: popup_getposition() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16817
diff changeset
842 redraw
16857
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
843 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
844 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
845 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
846 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
847 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
848 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
849
5cebaecad422 patch 8.1.1416: popup_getposition() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16817
diff changeset
850 call popup_close(winid)
5cebaecad422 patch 8.1.1416: popup_getposition() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16817
diff changeset
851 endfunc
16837
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
852
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
853 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
854 let tests = [
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
855 \ [['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
856 \ [['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
857 \ [['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
858 \ [['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
859 \ [['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
860 \ ]
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
861
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
862 for test in tests
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
863 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
864 redraw
16857
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
865 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
866 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
867 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
868 endfor
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
869 endfunc
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
870
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
871 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
872 let tests = [
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
873 \ ['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
874 \ ['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
875 \ ['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
876 \ ]
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
877 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
878 let winid = popup_create(test[0],
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
879 \ ~{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
880 redraw
16857
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
881 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
882 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
883 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
884
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
885 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
886 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
887 endfor
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
888 endfunc
16841
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
889
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
890 func Test_popup_getoptions()
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
891 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
892 \ line: 2,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
893 \ col: 3,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
894 \ minwidth: 10,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
895 \ minheight: 11,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
896 \ maxwidth: 20,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
897 \ maxheight: 21,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
898 \ zindex: 100,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
899 \ time: 5000,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
900 \ fixed: 1
16841
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
901 \})
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
902 redraw
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
903 let res = popup_getoptions(winid)
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
904 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
905 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
906 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
907 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
908 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
909 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
910 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
911 call assert_equal(1, res.fixed)
16841
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
912 if has('timers')
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
913 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
914 endif
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
915 call popup_close(winid)
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
916
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
917 let winid = popup_create('hello', {})
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
918 redraw
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
919 let res = popup_getoptions(winid)
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
920 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
921 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
922 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
923 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
924 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
925 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
926 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
927 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
928 if has('timers')
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
929 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
930 endif
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
931 call popup_close(winid)
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
932 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
933 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
934
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16841
diff changeset
935 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
936 new
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16841
diff changeset
937 " 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
938 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
939 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
940 " 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
941 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
942 " 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
943 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
944 " global/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
945 setlocal scrolloff=9
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16841
diff changeset
946
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16841
diff changeset
947 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
948 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
949 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
950 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
951 call assert_equal(&g:path, getwinvar(winid, '&path'))
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16841
diff changeset
952 call assert_equal(&g:scrolloff, getwinvar(winid, '&scrolloff'))
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16841
diff changeset
953
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16841
diff changeset
954 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
955 bwipe
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16841
diff changeset
956 endfunc
16853
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
957
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
958 func Test_popup_atcursor()
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
959 topleft vnew
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
960 call setline(1, [
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
961 \ 'xxxxxxxxxxxxxxxxx',
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
962 \ 'xxxxxxxxxxxxxxxxx',
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
963 \ 'xxxxxxxxxxxxxxxxx',
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
964 \])
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
965
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
966 call cursor(2, 2)
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
967 redraw
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
968 let winid = popup_atcursor('vim', {})
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
969 redraw
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
970 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
971 call assert_equal('xvimxxxxxxxxxxxxx', line)
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
972 call popup_close(winid)
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
973
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
974 call cursor(3, 4)
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
975 redraw
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
976 let winid = popup_atcursor('vim', {})
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
977 redraw
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
978 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
979 call assert_equal('xxxvimxxxxxxxxxxx', line)
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
980 call popup_close(winid)
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
981
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
982 call cursor(1, 1)
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
983 redraw
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
984 let winid = popup_create('vim', ~{
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
985 \ line: 'cursor+2',
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
986 \ col: 'cursor+1',
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
987 \})
16853
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
988 redraw
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
989 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
990 call assert_equal('xvimxxxxxxxxxxxxx', line)
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
991 call popup_close(winid)
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
992
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
993 call cursor(3, 3)
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
994 redraw
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
995 let winid = popup_create('vim', ~{
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
996 \ line: 'cursor-2',
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
997 \ col: 'cursor-1',
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
998 \})
16853
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
999 redraw
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
1000 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
1001 call assert_equal('xvimxxxxxxxxxxxxx', line)
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
1002 call popup_close(winid)
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
1003
16857
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1004 " just enough room above
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1005 call cursor(3, 3)
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1006 redraw
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1007 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
1008 redraw
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1009 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
1010 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
1011 call popup_close(winid)
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1012
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1013 " 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
1014 call cursor(3, 3)
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1015 redraw
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1016 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
1017 redraw
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1018 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
1019 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
1020 call popup_close(winid)
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1021
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
1022 " 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
1023 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
1024 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
1025 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
1026 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
1027 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
1028 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
1029 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
1030
16853
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
1031 bwipe!
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16849
diff changeset
1032 endfunc
16880
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1033
17292
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1034 func Test_popup_beval()
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1035 if !CanRunVimInTerminal()
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1036 throw 'Skipped: cannot make screendumps'
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1037 endif
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1038
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1039 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
1040 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
1041 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
1042 set balloonevalterm
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1043 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
1044 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
1045 func BalloonExpr()
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1046 let s:winid = popup_beval([v:beval_text], {})
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1047 return ''
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1048 endfunc
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1049 func Hover()
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1050 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
1051 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
1052 sleep 100m
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1053 endfunc
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1054 func MoveOntoPopup()
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1055 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
1056 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
1057 endfunc
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1058 func MoveAway()
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1059 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
1060 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
1061 endfunc
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1062 END
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1063 call writefile(lines, 'XtestPopupBeval')
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1064 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
1065 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
1066 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
1067 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
1068 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
1069
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1070 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
1071 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
1072
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1073 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
1074 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
1075
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1076 " clean up
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1077 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
1078 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
1079 endfunc
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17278
diff changeset
1080
16880
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1081 func Test_popup_filter()
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1082 new
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1083 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
1084
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1085 func MyPopupFilter(winid, c)
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1086 if a:c == 'e'
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1087 let g:eaten = 'e'
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1088 return 1
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1089 endif
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1090 if a:c == '0'
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1091 let g:ignored = '0'
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1092 return 0
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1093 endif
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1094 if a:c == 'x'
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1095 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
1096 return 1
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1097 endif
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1098 return 0
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1099 endfunc
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1100
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1101 let winid = popup_create('something', ~{filter: 'MyPopupFilter'})
16880
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1102 redraw
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1103
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1104 " 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
1105 call feedkeys('e', 'xt')
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1106 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
1107
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1108 " 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
1109 normal $
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1110 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
1111 call feedkeys('0', 'xt')
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1112 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
1113 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
1114
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1115 " x closes the popup
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1116 call feedkeys('x', 'xt')
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1117 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
1118 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
1119
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1120 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
1121 call popup_clear()
16880
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16878
diff changeset
1122 endfunc
16890
5131023c5728 patch 8.1.1446: popup window callback not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16888
diff changeset
1123
17097
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1124 func ShowDialog(key, result)
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1125 let s:cb_res = 999
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1126 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
1127 \ 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
1128 \ callback: 'QuitCallback',
17097
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1129 \ })
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1130 redraw
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1131 call feedkeys(a:key, "xt")
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1132 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
1133 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
1134 endfunc
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1135
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1136 func Test_popup_dialog()
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1137 func QuitCallback(id, res)
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1138 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
1139 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
1140 endfunc
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1141
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1142 let winid = ShowDialog("y", 1)
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1143 let winid = ShowDialog("Y", 1)
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1144 let winid = ShowDialog("n", 0)
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1145 let winid = ShowDialog("N", 0)
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1146 let winid = ShowDialog("x", 0)
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1147 let winid = ShowDialog("X", 0)
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1148 let winid = ShowDialog("\<Esc>", 0)
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1149 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
1150
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1151 delfunc QuitCallback
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1152 endfunc
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
1153
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
1154 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
1155 let s:cb_res = 999
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1156 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
1157 \ 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
1158 \ })
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1159 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
1160 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
1161 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
1162 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
1163 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
1164
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1165 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
1166 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
1167 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
1168 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
1169 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
1170
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1171 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
1172 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
1173 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
1174 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
1175 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
1176 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
1177 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
1178 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
1179 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
1180
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1181 delfunc QuitCallback
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1182 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
1183
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1184 func Test_popup_menu_screenshot()
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1185 if !CanRunVimInTerminal()
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1186 throw 'Skipped: cannot make screendumps'
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1187 endif
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1188
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1189 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
1190 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
1191 hi PopupSelected ctermbg=lightblue
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1192 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
1193 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
1194 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
1195 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
1196 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
1197 call writefile(lines, 'XtestPopupMenu')
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1198 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
1199 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
1200
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1201 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
1202 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
1203
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1204 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
1205 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
1206
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
1207 " 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
1208 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
1209 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
1210 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
1211
17119
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
1212 func Test_popup_title()
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
1213 if !CanRunVimInTerminal()
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
1214 throw 'Skipped: cannot make screendumps'
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
1215 endif
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
1216
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
1217 " 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
1218 " 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
1219 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
1220 call setline(1, range(1, 20))
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1221 call 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
1222 END
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
1223 call writefile(lines, 'XtestPopupTitle')
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1224 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
1225 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
1226
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
1227 " clean up
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
1228 call StopVimInTerminal(buf)
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
1229 call delete('XtestPopupTitle')
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
1230
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1231 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
1232 call assert_equal('Some Title', popup_getoptions(winid).title)
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1233 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
1234 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
1235
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
1236 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
1237 endfunc
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
1238
16890
5131023c5728 patch 8.1.1446: popup window callback not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16888
diff changeset
1239 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
1240 func PopupDone(id, result)
5131023c5728 patch 8.1.1446: popup window callback not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16888
diff changeset
1241 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
1242 endfunc
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1243 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
1244 redraw
5131023c5728 patch 8.1.1446: popup window callback not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16888
diff changeset
1245 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
1246 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
1247 endfunc
16892
60c9ac14a2ec patch 8.1.1447: not allowed to create an empty popup
Bram Moolenaar <Bram@vim.org>
parents: 16890
diff changeset
1248
60c9ac14a2ec patch 8.1.1447: not allowed to create an empty popup
Bram Moolenaar <Bram@vim.org>
parents: 16890
diff changeset
1249 func Test_popup_empty()
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1250 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
1251 redraw
60c9ac14a2ec patch 8.1.1447: not allowed to create an empty popup
Bram Moolenaar <Bram@vim.org>
parents: 16890
diff changeset
1252 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
1253 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
1254 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
1255
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1256 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
1257 redraw
60c9ac14a2ec patch 8.1.1447: not allowed to create an empty popup
Bram Moolenaar <Bram@vim.org>
parents: 16890
diff changeset
1258 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
1259 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
1260 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
1261 endfunc
16894
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1262
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1263 func Test_popup_never_behind()
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1264 if !CanRunVimInTerminal()
16965
ba7727889385 patch 8.1.1483: skipped tests are not properly listed
Bram Moolenaar <Bram@vim.org>
parents: 16908
diff changeset
1265 throw 'Skipped: cannot make screendumps'
16894
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1266 endif
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1267 " +-----------------------------+
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1268 " | | |
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1269 " | | |
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1270 " | | |
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1271 " | line1 |
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1272 " |------------line2------------|
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1273 " | line3 |
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1274 " | line4 |
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1275 " | |
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1276 " | |
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1277 " +-----------------------------+
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1278 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
1279 only
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1280 split
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1281 vsplit
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1282 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
1283 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
1284 let col = info_window1['width']
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1285 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
1286 \ line : line,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1287 \ 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
1288 \ })
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1289 END
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1290 call writefile(lines, 'XtestPopupBehind')
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1291 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
1292 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
1293 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
1294
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1295 " clean up
236c182c6300 patch 8.1.1448: statusline is sometimes drawn on top of popup
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1296 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
1297 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
1298 endfunc
16896
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1299
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1300 func s:VerifyPosition( p, msg, line, col, width, height )
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1301 call assert_equal( a:line, popup_getpos( a:p ).line, a:msg . ' (l)' )
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1302 call assert_equal( a:col, popup_getpos( a:p ).col, a:msg . ' (c)' )
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1303 call assert_equal( a:width, popup_getpos( a:p ).width, a:msg . ' (w)' )
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1304 call assert_equal( a:height, popup_getpos( a:p ).height, a:msg . ' (h)' )
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1305 endfunc
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1306
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1307 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
1308 " 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
1309 " left.
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1310 "
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1311 " 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
1312 " 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
1313
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1314 " 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
1315 " 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
1316 let both_wrap_tests = [
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1317 \ [ 'a', 5, &columns, 5, &columns - 2, 1, 1 ],
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1318 \ [ 'b', 5, &columns + 1, 5, &columns - 2, 1, 1 ],
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1319 \ [ 'c', 5, &columns - 1, 5, &columns - 2, 1, 1 ],
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1320 \ [ 'd', 5, &columns - 2, 5, &columns - 2, 1, 1 ],
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1321 \ [ 'e', 5, &columns - 3, 5, &columns - 3, 1, 1 ],
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1322 \
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1323 \ [ 'aa', 5, &columns, 5, &columns - 2, 2, 1 ],
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1324 \ [ 'bb', 5, &columns + 1, 5, &columns - 2, 2, 1 ],
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1325 \ [ 'cc', 5, &columns - 1, 5, &columns - 2, 2, 1 ],
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1326 \ [ 'dd', 5, &columns - 2, 5, &columns - 2, 2, 1 ],
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1327 \ [ 'ee', 5, &columns - 3, 5, &columns - 3, 2, 1 ],
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1328 \
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1329 \ [ 'aaa', 5, &columns, 5, &columns - 2, 3, 1 ],
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1330 \ [ 'bbb', 5, &columns + 1, 5, &columns - 2, 3, 1 ],
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1331 \ [ 'ccc', 5, &columns - 1, 5, &columns - 2, 3, 1 ],
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1332 \ [ 'ddd', 5, &columns - 2, 5, &columns - 2, 3, 1 ],
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1333 \ [ 'eee', 5, &columns - 3, 5, &columns - 3, 3, 1 ],
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1334 \ ]
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1335
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1336 " 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
1337 " - 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
1338 " - 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
1339 " - 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
1340 " - text
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1341 " - row
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1342 " - col
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1343 " - expected row
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1344 " - expected col
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1345 " - expected width
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1346 " - expected height
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1347 let tests = [
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1348 \ ~{
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1349 \ comment: 'left-aligned with wrapping',
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1350 \ options: ~{
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1351 \ wrap: 1,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1352 \ pos: 'botleft',
16896
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1353 \ },
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1354 \ tests: both_wrap_tests + [
16896
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1355 \ [ 'aaaa', 5, &columns, 4, &columns - 2, 3, 2 ],
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1356 \ [ 'bbbb', 5, &columns + 1, 4, &columns - 2, 3, 2 ],
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1357 \ [ 'cccc', 5, &columns - 1, 4, &columns - 2, 3, 2 ],
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1358 \ [ 'dddd', 5, &columns - 2, 4, &columns - 2, 3, 2 ],
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1359 \ [ 'eeee', 5, &columns - 3, 5, &columns - 3, 4, 1 ],
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1360 \ ],
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1361 \ },
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1362 \ ~{
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1363 \ comment: 'left aligned without wrapping',
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1364 \ options: ~{
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1365 \ wrap: 0,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1366 \ pos: 'botleft',
16896
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1367 \ },
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1368 \ tests: both_wrap_tests + [
16896
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1369 \ [ 'aaaa', 5, &columns, 5, &columns - 3, 4, 1 ],
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1370 \ [ 'bbbb', 5, &columns + 1, 5, &columns - 3, 4, 1 ],
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1371 \ [ 'cccc', 5, &columns - 1, 5, &columns - 3, 4, 1 ],
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1372 \ [ 'dddd', 5, &columns - 2, 5, &columns - 3, 4, 1 ],
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1373 \ [ 'eeee', 5, &columns - 3, 5, &columns - 3, 4, 1 ],
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1374 \ ],
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1375 \ },
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1376 \ ~{
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1377 \ comment: 'left aligned with fixed position',
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1378 \ options: ~{
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1379 \ wrap: 0,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1380 \ fixed: 1,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1381 \ pos: 'botleft',
16896
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1382 \ },
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1383 \ tests: both_wrap_tests + [
16896
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1384 \ [ 'aaaa', 5, &columns, 5, &columns - 2, 3, 1 ],
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1385 \ [ 'bbbb', 5, &columns + 1, 5, &columns - 2, 3, 1 ],
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1386 \ [ 'cccc', 5, &columns - 1, 5, &columns - 2, 3, 1 ],
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1387 \ [ 'dddd', 5, &columns - 2, 5, &columns - 2, 3, 1 ],
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1388 \ [ 'eeee', 5, &columns - 3, 5, &columns - 3, 4, 1 ],
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1389 \ ],
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1390 \ },
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1391 \ ]
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1392
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1393 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
1394 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
1395 let [ text, line, col, e_line, e_col, e_width, e_height ] = test
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1396 let options = ~{
17368
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1397 \ line: line,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1398 \ col: col,
16896
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1399 \ }
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1400 call extend( options, test_group.options )
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1401
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1402 let p = popup_create( text, options )
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1403
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1404 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
1405 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
1406 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
1407 endfor
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1408 endfor
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1409
17026
905e1b154058 patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents: 17022
diff changeset
1410 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
1411 %bwipe!
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1412 endfunc
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1413
16904
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1414 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
1415 " width of screen
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1416 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
1417
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1418 let p = popup_create( X, ~{line: 1, col: 1, wrap: 0})
16896
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1419 call s:VerifyPosition( p, 'full width topleft', 1, 1, &columns, 1 )
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1420
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1421 redraw
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1422 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
1423 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
1424
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1425 call popup_close( p )
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1426 redraw
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1427
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1428 " Same if placed on the right hand side
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1429 let p = popup_create( X, ~{line: 1, col: &columns, wrap: 0})
16896
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1430 call s:VerifyPosition( p, 'full width topright', 1, 1, &columns, 1 )
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1431
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1432 redraw
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1433 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
1434 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
1435
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1436 call popup_close( p )
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1437 redraw
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1438
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1439 " 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
1440 let X .= 'x'
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1441
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1442 let p = popup_create( X, ~{line: 1, col: 1, wrap: 0})
16896
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1443 call s:VerifyPosition( p, 'full width + 1 topleft', 1, 1, &columns, 1 )
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1444
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1445 redraw
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1446 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
1447 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
1448
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1449 call popup_close( p )
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1450 redraw
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1451
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1452 " Shifted then truncated (the x is not visible)
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1453 let p = popup_create( X, ~{line: 1, col: &columns - 3, wrap: 0})
16896
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1454 call s:VerifyPosition( p, 'full width + 1 topright', 1, 1, &columns, 1 )
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1455
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1456 redraw
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1457 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
1458 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
1459
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1460 call popup_close( p )
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1461 redraw
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1462
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1463 " Not shifted, just truncated
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1464 let p = popup_create( X,
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1465 \ ~{line: 1, col: 2, wrap: 0, fixed: 1})
16896
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1466 call s:VerifyPosition( p, 'full width + 1 fixed', 1, 2, &columns - 1, 1)
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1467
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1468 redraw
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1469 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
1470 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
1471 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
1472
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1473 call popup_close( p )
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1474 redraw
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16894
diff changeset
1475
17026
905e1b154058 patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents: 17022
diff changeset
1476 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
1477 %bwipe!
16904
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1478 endfunc
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1479
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1480 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
1481 new
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1482 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
1483 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
1484
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1485 exe "normal gg0/word\<CR>"
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1486 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
1487 redraw
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1488 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
1489 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
1490 " 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
1491 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
1492 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
1493 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
1494
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1495 exe "normal gg0/word\<CR>"
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1496 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
1497 redraw
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1498 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
1499 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
1500 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
1501 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
1502 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
1503
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1504 exe "normal gg0/word\<CR>"
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1505 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
1506 redraw
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1507 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
1508 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
1509 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
1510 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
1511 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
1512 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
1513 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
1514 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
1515 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
1516
16908
df06694b761b patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents: 16904
diff changeset
1517 " 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
1518 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
1519 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
1520 redraw
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1521 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
1522 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
1523 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
1524 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
1525 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
1526 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
1527 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
1528 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
1529 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
1530
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1531 exe "normal gg0/word\<CR>"
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1532 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
1533 redraw
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1534 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
1535 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
1536 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
1537 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
1538 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
1539 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
1540 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
1541
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1542 bwipe!
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
1543 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
1544 endfunc
17045
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17043
diff changeset
1545
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17043
diff changeset
1546 func Test_notifications()
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17043
diff changeset
1547 if !has('timers')
17089
8e9e9124c7a2 patch 8.1.1544: some balloon tests don't run when they can
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
1548 throw 'Skipped: timer feature not supported'
17045
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17043
diff changeset
1549 endif
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17043
diff changeset
1550 if !CanRunVimInTerminal()
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17043
diff changeset
1551 throw 'Skipped: cannot make screendumps'
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17043
diff changeset
1552 endif
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17043
diff changeset
1553
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17043
diff changeset
1554 call writefile([
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17043
diff changeset
1555 \ "call setline(1, range(1, 20))",
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17043
diff changeset
1556 \ "hi Notification ctermbg=lightblue",
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17043
diff changeset
1557 \ "call popup_notification('first notification', {})",
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17043
diff changeset
1558 \], 'XtestNotifications')
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1559 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
1560 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
1561
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17043
diff changeset
1562 " 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
1563 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
1564 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
1565 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
1566
17180
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1567 " clean up
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1568 call StopVimInTerminal(buf)
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1569 call delete('XtestNotifications')
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1570 endfunc
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1571
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1572 func Test_popup_scrollbar()
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1573 if !CanRunVimInTerminal()
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1574 throw 'Skipped: cannot make screendumps'
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1575 endif
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1576
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1577 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
1578 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
1579 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
1580 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
1581 let winid = popup_create(['one', 'two', 'three', 'four', 'five',
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1582 \ '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
1583 \ minwidth: 8,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1584 \ maxheight: 4,
17180
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1585 \ })
17198
4c009ec23c0a patch 8.1.1598: update to test file missing
Bram Moolenaar <Bram@vim.org>
parents: 17182
diff changeset
1586 func ScrollUp()
4c009ec23c0a patch 8.1.1598: update to test file missing
Bram Moolenaar <Bram@vim.org>
parents: 17182
diff changeset
1587 call feedkeys("\<F3>\<ScrollWheelUp>", "xt")
4c009ec23c0a patch 8.1.1598: update to test file missing
Bram Moolenaar <Bram@vim.org>
parents: 17182
diff changeset
1588 endfunc
4c009ec23c0a patch 8.1.1598: update to test file missing
Bram Moolenaar <Bram@vim.org>
parents: 17182
diff changeset
1589 func ScrollDown()
4c009ec23c0a patch 8.1.1598: update to test file missing
Bram Moolenaar <Bram@vim.org>
parents: 17182
diff changeset
1590 call feedkeys("\<F3>\<ScrollWheelDown>", "xt")
4c009ec23c0a patch 8.1.1598: update to test file missing
Bram Moolenaar <Bram@vim.org>
parents: 17182
diff changeset
1591 endfunc
17216
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17210
diff changeset
1592 func ClickTop()
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17210
diff changeset
1593 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
1594 endfunc
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17210
diff changeset
1595 func ClickBot()
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1596 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
1597 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
1598 endfunc
17198
4c009ec23c0a patch 8.1.1598: update to test file missing
Bram Moolenaar <Bram@vim.org>
parents: 17182
diff changeset
1599 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
1600 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
1601 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
1602 END
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
1603 call writefile(lines, 'XtestPopupScroll')
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1604 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
1605 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
1606
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1607 call term_sendkeys(buf, ":call popup_setoptions(winid, ~{firstline: 2})\<CR>")
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1608 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
1609 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
1610
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1611 call term_sendkeys(buf, ":call popup_setoptions(winid, ~{firstline: 6})\<CR>")
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1612 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
1613 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
1614
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1615 call term_sendkeys(buf, ":call popup_setoptions(winid, ~{firstline: 9})\<CR>")
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1616 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
1617 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
1618
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1619 call term_sendkeys(buf, ":call popup_setoptions(winid, ~{scrollbarhighlight: 'ScrollBar', thumbhighlight: 'ScrollThumb'})\<CR>")
17198
4c009ec23c0a patch 8.1.1598: update to test file missing
Bram Moolenaar <Bram@vim.org>
parents: 17182
diff changeset
1620 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
1621 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
1622
4c009ec23c0a patch 8.1.1598: update to test file missing
Bram Moolenaar <Bram@vim.org>
parents: 17182
diff changeset
1623 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
1624 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
1625
4c009ec23c0a patch 8.1.1598: update to test file missing
Bram Moolenaar <Bram@vim.org>
parents: 17182
diff changeset
1626 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
1627 " 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
1628 sleep 100m
17198
4c009ec23c0a patch 8.1.1598: update to test file missing
Bram Moolenaar <Bram@vim.org>
parents: 17182
diff changeset
1629 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
1630 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
1631
17216
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17210
diff changeset
1632 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
1633 sleep 100m
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17210
diff changeset
1634 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
1635 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
1636
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17210
diff changeset
1637 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
1638 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
1639
17045
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17043
diff changeset
1640 " clean up
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17043
diff changeset
1641 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
1642 call delete('XtestPopupScroll')
17045
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17043
diff changeset
1643 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
1644
17274
6a7ba68d448e patch 8.1.1636: crash when popup has fitting scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17253
diff changeset
1645 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
1646 " 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
1647 let winid = popup_create([
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1648 \ '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
1649 \ scrollbar: 1,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1650 \ maxwidth: 10,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1651 \ maxheight: 5,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1652 \ firstline: 2})
17274
6a7ba68d448e patch 8.1.1636: crash when popup has fitting scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17253
diff changeset
1653 redraw
6a7ba68d448e patch 8.1.1636: crash when popup has fitting scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17253
diff changeset
1654 call popup_clear()
6a7ba68d448e patch 8.1.1636: crash when popup has fitting scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17253
diff changeset
1655 endfunc
6a7ba68d448e patch 8.1.1636: crash when popup has fitting scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17253
diff changeset
1656
17121
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
1657 func Test_popup_settext()
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
1658 if !CanRunVimInTerminal()
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1659 throw 'Skipped: cannot make screendumps'
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1660 endif
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1661
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1662 let lines =<< trim END
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1663 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
1664 let p = popup_create('test', opts)
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1665 call popup_settext(p, 'this is a text')
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1666 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
1667
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1668 call writefile( lines, 'XtestPopupSetText' )
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1669 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
1670 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
1671
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1672 " 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
1673 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
1674 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
1675
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1676 " 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
1677 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
1678 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
1679
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1680 " 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
1681 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
1682 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
1683
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1684 " 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
1685 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
1686 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
1687
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1688 " 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
1689 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
1690 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
1691
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1692 " Dicts
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1693 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
1694 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
1695
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1696 " 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
1697 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
1698 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
1699 endfunc
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
1700
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
1701 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
1702 new
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
1703
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1704 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
1705 redraw
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
1706 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
1707 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
1708
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1709 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
1710 redraw
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
1711 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
1712 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
1713
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
1714 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
1715 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
1716 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
1717 endfunc
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1718 let winid = popup_dialog('make a choice', ~{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
1719 \ 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
1720 \ callback: 'QuitCallback',
17121
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
1721 \ })
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
1722 redraw
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
1723 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
1724 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
1725 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
1726 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
1727 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
1728
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
1729 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
1730 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
1731 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
1732
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
1733 bwipe!
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
1734 delfunc QuitCallback
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
1735 endfunc
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
1736
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
1737 " 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
1738 func Test_set_get_options()
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1739 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
1740 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
1741 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
1742 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
1743 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
1744
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1745 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
1746 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
1747 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
1748 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
1749 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
1750
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
1751 call popup_close(winid)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
1752 endfunc
17151
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
1753
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
1754 func Test_popupwin_garbage_collect()
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
1755 func MyPopupFilter(x, winid, c)
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
1756 " NOP
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
1757 endfunc
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
1758
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1759 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
1760 call test_garbagecollect_now()
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
1761 redraw
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
1762 " Must not crach caused by invalid memory access
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
1763 call feedkeys('j', 'xt')
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
1764 call assert_true(v:true)
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
1765
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
1766 call popup_close(winid)
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
1767 delfunc MyPopupFilter
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
1768 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
1769
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
1770 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
1771 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
1772 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
1773 call assert_equal(0, 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
1774 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
1775 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
1776 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
1777 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
1778 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
1779 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
1780 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
1781 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
1782 exe 'bwipe! ' .. buf
17231
e9ebf3f27af6 patch 8.1.1615: crash when passing buffer number to popup_create()
Bram Moolenaar <Bram@vim.org>
parents: 17225
diff changeset
1783
e9ebf3f27af6 patch 8.1.1615: crash when passing buffer number to popup_create()
Bram Moolenaar <Bram@vim.org>
parents: 17225
diff changeset
1784 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
1785 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
1786 redraw
e9ebf3f27af6 patch 8.1.1615: crash when passing buffer number to popup_create()
Bram Moolenaar <Bram@vim.org>
parents: 17225
diff changeset
1787 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
1788 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
1789 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
1790
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
1791 func Test_popupwin_width()
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1792 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
1793 \ maxwidth: 40,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1794 \ 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
1795 \ })
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
1796 for top in range(1, 20)
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1797 call popup_setoptions(winid, ~{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
1798 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
1799 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
1800 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
1801 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
1802 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
1803
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
1804 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
1805 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
1806 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
1807 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
1808 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
1809 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
1810 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
1811 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
1812 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
1813 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
1814 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
1815 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
1816 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
1817 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
1818
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
1819 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
1820 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
1821 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
1822 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
1823 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
1824 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
1825 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
1826 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
1827 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
1828 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
1829 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
1830
102ed3a26a5d patch 8.1.1676: "maxwidth" of popup window does not always work properly
Bram Moolenaar <Bram@vim.org>
parents: 17348
diff changeset
1831 func Test_popup_menu_with_maxwidth()
102ed3a26a5d patch 8.1.1676: "maxwidth" of popup window does not always work properly
Bram Moolenaar <Bram@vim.org>
parents: 17348
diff changeset
1832 if !CanRunVimInTerminal()
102ed3a26a5d patch 8.1.1676: "maxwidth" of popup window does not always work properly
Bram Moolenaar <Bram@vim.org>
parents: 17348
diff changeset
1833 throw 'Skipped: cannot make screendumps'
102ed3a26a5d patch 8.1.1676: "maxwidth" of popup window does not always work properly
Bram Moolenaar <Bram@vim.org>
parents: 17348
diff changeset
1834 endif
102ed3a26a5d patch 8.1.1676: "maxwidth" of popup window does not always work properly
Bram Moolenaar <Bram@vim.org>
parents: 17348
diff changeset
1835
102ed3a26a5d patch 8.1.1676: "maxwidth" of popup window does not always work properly
Bram Moolenaar <Bram@vim.org>
parents: 17348
diff changeset
1836 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
1837 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
1838 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
1839 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
1840 func PopupMenu(lines, line, col, scrollbar = 0)
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1841 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
1842 \ maxwidth: 10,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1843 \ maxheight: 3,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1844 \ pos : 'topleft',
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1845 \ 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
1846 \ 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
1847 \ 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
1848 \ })
102ed3a26a5d patch 8.1.1676: "maxwidth" of popup window does not always work properly
Bram Moolenaar <Bram@vim.org>
parents: 17348
diff changeset
1849 endfunc
102ed3a26a5d patch 8.1.1676: "maxwidth" of popup window does not always work properly
Bram Moolenaar <Bram@vim.org>
parents: 17348
diff changeset
1850 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
1851 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
1852 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
1853 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
1854 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
1855 END
102ed3a26a5d patch 8.1.1676: "maxwidth" of popup window does not always work properly
Bram Moolenaar <Bram@vim.org>
parents: 17348
diff changeset
1856 call writefile(lines, 'XtestPopupMenuMaxWidth')
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1857 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
1858 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
1859
102ed3a26a5d patch 8.1.1676: "maxwidth" of popup window does not always work properly
Bram Moolenaar <Bram@vim.org>
parents: 17348
diff changeset
1860 " 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
1861 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
1862 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
1863 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
1864 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
1865 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
1866
102ed3a26a5d patch 8.1.1676: "maxwidth" of popup window does not always work properly
Bram Moolenaar <Bram@vim.org>
parents: 17348
diff changeset
1867 " 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
1868 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
1869 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
1870 endfunc
102ed3a26a5d patch 8.1.1676: "maxwidth" of popup window does not always work properly
Bram Moolenaar <Bram@vim.org>
parents: 17348
diff changeset
1871
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
1872 func Test_popup_menu_with_scrollbar()
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
1873 if !CanRunVimInTerminal()
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
1874 throw 'Skipped: cannot make screendumps'
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
1875 endif
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
1876
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
1877 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
1878 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
1879 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
1880 hi ScrollBar ctermbg=red
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
1881 call popup_menu(['one', 'two', 'three', 'four', 'five',
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1882 \ '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
1883 \ minwidth: 8,
6604ecb7a615 patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents: 17358
diff changeset
1884 \ 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
1885 \ })
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
1886 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
1887 call writefile(lines, 'XtestPopupMenuScroll')
17387
2558f90045e5 patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 17368
diff changeset
1888 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
1889
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
1890 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
1891 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
1892
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
1893 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
1894 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
1895
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
1896 " 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
1897 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
1898 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
1899
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
1900 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
1901 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
1902
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
1903 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
1904 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
1905
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
1906 " 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
1907 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
1908 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
1909
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
1910 " 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
1911 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
1912
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
1913 " 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
1914 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
1915 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
1916 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
1917
17354
102ed3a26a5d patch 8.1.1676: "maxwidth" of popup window does not always work properly
Bram Moolenaar <Bram@vim.org>
parents: 17348
diff changeset
1918 " vim: shiftwidth=2 sts=2 expandtab