blob: c3288f8c1191c0a9b13fb80a98d0dddfa314b2cd [file] [log] [blame]
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +02001" Tests for tabpanel
2
3source check.vim
4source screendump.vim
5CheckFeature tabpanel
6
Hirohito Higashic659e4a2025-05-16 19:34:34 +02007function s:reset()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +02008 set tabpanel&
9 set tabpanelopt&
10 set showtabpanel&
11endfunc
12
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +020013function Test_tabpanel_showtabpanel_eq_1()
14 CheckScreendump
15
16 let lines =<< trim END
17 set showtabpanel=1
18 set noruler
19 END
20 call writefile(lines, 'XTest_tabpanel_stpl_eq_1', 'D')
21
22 let buf = RunVimInTerminal('-S XTest_tabpanel_stpl_eq_1', {'rows': 10, 'cols': 78})
23 call term_sendkeys(buf, "\<C-L>")
24 call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_1_0', {})
25 call term_sendkeys(buf, ":tabnew\<CR>\<C-L>")
26 call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_1_1', {})
27 call term_sendkeys(buf, ":tabfirst\<CR>:vsplit\<CR>\<C-L>")
28 call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_1_2', {})
29 call term_sendkeys(buf, ":tabclose\<CR>\<C-L>")
30 call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_1_0', {})
31
32 call term_sendkeys(buf, ":set tabpanelopt=align:right\<CR>\<C-L>")
33 call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_1_0', {})
34 call term_sendkeys(buf, ":tabnew\<CR>\<C-L>")
35 call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_1_3', {})
36 call term_sendkeys(buf, ":tabfirst\<CR>:vsplit\<CR>\<C-L>")
37 call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_1_4', {})
38 call term_sendkeys(buf, ":tabclose\<CR>\<C-L>")
39 call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_1_0', {})
40 call StopVimInTerminal(buf)
41endfunc
42
43function Test_tabpanel_with_vsplit()
44 CheckScreendump
45
46 let lines =<< trim END
47 set showtabpanel=2
48 set tabpanelopt=columns:20
49 set showtabline=0
50 tabnew
51 END
52 call writefile(lines, 'XTest_tabpanel_with_vsplit', 'D')
53
54 let buf = RunVimInTerminal('-S XTest_tabpanel_with_vsplit', {'rows': 10, 'cols': 78})
55 call VerifyScreenDump(buf, 'Test_tabpanel_with_vsplit_0', {})
56 call term_sendkeys(buf, ":vsplit\<CR>")
57 call VerifyScreenDump(buf, 'Test_tabpanel_with_vsplit_1', {})
58 call term_sendkeys(buf, ":vsplit\<CR>")
59 call VerifyScreenDump(buf, 'Test_tabpanel_with_vsplit_2', {})
60
61 call term_sendkeys(buf, ":only\<CR>")
62 call term_sendkeys(buf, ":set tabpanelopt=align:right,vert\<CR>")
63 call VerifyScreenDump(buf, 'Test_tabpanel_with_vsplit_3', {})
64 call term_sendkeys(buf, ":vsplit\<CR>")
65 call VerifyScreenDump(buf, 'Test_tabpanel_with_vsplit_4', {})
66 call term_sendkeys(buf, ":vsplit\<CR>")
67 call VerifyScreenDump(buf, 'Test_tabpanel_with_vsplit_5', {})
68 call StopVimInTerminal(buf)
69endfunc
70
Hirohito Higashic659e4a2025-05-16 19:34:34 +020071function Test_tabpanel_mouse()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +020072 let save_showtabline = &showtabline
73 let save_mouse = &mouse
74 set showtabline=0 mouse=a
75
76 tabnew
77 tabnew
78
79 call test_setmouse(1, 1)
80 call feedkeys("\<LeftMouse>", 'xt')
81 call assert_equal(3, tabpagenr())
82
83 set showtabpanel=2 tabpanelopt=columns:10
84
85 call test_setmouse(1, 1)
86 call feedkeys("\<LeftMouse>", 'xt')
87 call assert_equal(1, tabpagenr())
88 call test_setmouse(2, 1)
89 call feedkeys("\<LeftMouse>", 'xt')
90 call assert_equal(2, tabpagenr())
91 call test_setmouse(3, 1)
92 call feedkeys("\<LeftMouse>", 'xt')
93 call assert_equal(3, tabpagenr())
94
95 call feedkeys("\<LeftMouse>", 'xt')
96 call test_setmouse(2, 3)
97 let pos = getmousepos()
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +020098 call assert_equal(0, pos['winid'])
99 call assert_equal(0, pos['winrow'])
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200100 call assert_equal(0, pos['wincol'])
101 call assert_equal(2, pos['screenrow'])
102 call assert_equal(3, pos['screencol'])
103
104 call test_setmouse(1, 11)
105 call feedkeys("\<LeftMouse>", 'xt')
106 let pos = getmousepos()
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200107 call assert_notequal(0, pos['winid'])
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200108 call assert_equal(1, pos['winrow'])
109 call assert_equal(1, pos['wincol'])
110 call assert_equal(1, pos['screenrow'])
111 call assert_equal(11, pos['screencol'])
112
113 new
114 wincmd x
115
116 call test_setmouse(10, 11)
117 call feedkeys("\<LeftMouse>", 'xt')
118 let pos = getmousepos()
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200119 call assert_notequal(0, pos['winid'])
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200120 call assert_equal(10, pos['winrow'])
121 call assert_equal(1, pos['wincol'])
122 call assert_equal(10, pos['screenrow'])
123 call assert_equal(11, pos['screencol'])
124
125 tabonly!
126 call s:reset()
127 let &mouse = save_mouse
128 let &showtabline = save_showtabline
129endfunc
130
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200131function Test_tabpanel_drawing()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200132 CheckScreendump
133
134 let lines =<< trim END
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200135 function MyTabPanel()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200136 let n = g:actual_curtabpage
137 let hi = n == tabpagenr() ? 'TabLineSel' : 'TabLine'
138 let label = printf("\n%%#%sTabNumber#%d:%%#%s#", hi, n, hi)
139 let label ..= '%1*%f%*'
140 return label
141 endfunction
142 hi User1 ctermfg=12
143
144 set showtabline=0
145 set showtabpanel=0
146 set tabpanelopt=columns:16
147 set tabpanel=
148 silent edit Xtabpanel1
149
150 nnoremap \01 <Cmd>set showtabpanel=2<CR>
151 nnoremap \02 <C-w>v
152 nnoremap \03 <Cmd>call setline(1, ['a', 'b', 'c'])<CR>
153 nnoremap \04 <Cmd>silent tabnew Xtabpanel2<CR><Cmd>call setline(1, ['d', 'e', 'f'])<CR>
154 nnoremap \05 <Cmd>set tabpanel=%!MyTabPanel()<CR>
155 nnoremap \06 <Cmd>set tabpanelopt+=align:right<CR>
156 nnoremap \07 <Cmd>tab terminal NONE<CR><C-w>N
157 nnoremap \08 <Cmd>tabclose!<CR><Cmd>tabclose!<CR>
158 END
159 call writefile(lines, 'XTest_tabpanel', 'D')
160
161 let buf = RunVimInTerminal('-S XTest_tabpanel', {'rows': 6, 'cols': 45})
162
163 call VerifyScreenDump(buf, 'Test_tabpanel_drawing_00', {})
164
165 for i in range(1, 8)
166 let n = printf('%02d', i)
167 call term_sendkeys(buf, '\' .. n)
168 call VerifyScreenDump(buf, 'Test_tabpanel_drawing_' .. n, {})
169 endfor
170
171 call StopVimInTerminal(buf)
172endfunc
173
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200174function Test_tabpanel_drawing_with_popupwin()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200175 CheckScreendump
176
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200177 let tcols = 45
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200178 let lines =<< trim END
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200179 set showtabpanel=0
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200180 set tabpanelopt=columns:20
181 set showtabline=0
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200182 set nowrap
183 set noruler
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200184 tabnew
185 setlocal buftype=nofile
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200186 call setbufline(bufnr(), 1, repeat([repeat('.', &columns)], &lines - &ch))
187 for col in [1, &columns - 2]
188 call popup_create(['@'],
189 \ {
190 \ 'line': 1,
191 \ 'col': col,
192 \ 'border': [],
193 \ 'highlight': 'ErrorMsg',
194 \ })
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200195 endfor
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200196 call cursor(5, 10)
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200197 call popup_atcursor('atcursor', {
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200198 \ 'highlight': 'Question',
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200199 \ })
200 END
201 call writefile(lines, 'XTest_tabpanel_with_popupwin', 'D')
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200202 let buf = RunVimInTerminal('-S XTest_tabpanel_with_popupwin', {'rows': 10, 'cols': tcols})
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200203 call VerifyScreenDump(buf, 'Test_tabpanel_drawing_with_popupwin_0', {})
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200204 call term_sendkeys(buf, ":set showtabpanel=2\<CR>\<C-L>")
205 call VerifyScreenDump(buf, 'Test_tabpanel_drawing_with_popupwin_1', {})
206 call term_sendkeys(buf, ":set tabpanelopt+=align:right\<CR>\<C-L>")
207 call VerifyScreenDump(buf, 'Test_tabpanel_drawing_with_popupwin_2', {})
208 call term_sendkeys(buf, ":set showtabpanel=0\<CR>\<C-L>")
209 call VerifyScreenDump(buf, 'Test_tabpanel_drawing_with_popupwin_0', {})
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200210 call StopVimInTerminal(buf)
211endfunc
212
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200213function Test_tabpanel_drawing_fill_tailing()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200214 CheckScreendump
215
216 let lines =<< trim END
217 set showtabpanel=2
218 set tabpanelopt=columns:20
219 set showtabline=0
220 e aaa.txt
221 tabnew
222 e bbb.txt
223 let &tabpanel = "abc"
224 redraw!
225 " Check whether "abc" is cleared
226 let &tabpanel = "\nTOP\n%f\nBOTTOM"
227 END
228 call writefile(lines, 'XTest_tabpanel_fill_tailing', 'D')
229
230 let buf = RunVimInTerminal('-S XTest_tabpanel_fill_tailing', {'rows': 10, 'cols': 45})
231
232 call VerifyScreenDump(buf, 'Test_tabpanel_drawing_fill_tailing_0', {})
233
234 call StopVimInTerminal(buf)
235endfunc
236
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200237function Test_tabpanel_drawing_pum()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200238 CheckScreendump
239
240 let lines =<< trim END
241 set showtabpanel=2
242 set tabpanelopt=columns:20
243 set showtabline=0
244 e aaa.txt
245 tabnew
246 e bbb.txt
247 END
248 call writefile(lines, 'XTest_tabpanel_pum', 'D')
249
250 let buf = RunVimInTerminal('-S XTest_tabpanel_pum', {'rows': 10, 'cols': 45})
251
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200252 call term_sendkeys(buf, "i\<CR>aa\<CR>aaaa\<CR>aaac\<CR>aaab\<CR>\<Esc>")
253 call term_sendkeys(buf, "ggi\<C-X>\<C-N>")
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200254 call VerifyScreenDump(buf, 'Test_tabpanel_drawing_pum_0', {})
255
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200256 call term_sendkeys(buf, "\<Esc>Go a\<C-X>\<C-P>")
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200257 call VerifyScreenDump(buf, 'Test_tabpanel_drawing_pum_1', {})
258
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200259 call term_sendkeys(buf, "\<C-U>\<CR>\<Esc>")
260 call term_sendkeys(buf, ":set tabpanelopt+=align:right\<CR>")
261 let num = 45 - 20 - 2 " term-win-width - tabpanel-columns - 2
262 call term_sendkeys(buf, num .. "a \<Esc>")
263 call term_sendkeys(buf, "a\<C-X>\<C-N>")
264 call VerifyScreenDump(buf, 'Test_tabpanel_drawing_pum_2', {})
265
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200266 call StopVimInTerminal(buf)
267endfunc
268
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200269function Test_tabpanel_scrolling()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200270 CheckScreendump
271
272 let lines =<< trim END
273 set showtabpanel=2
274 set tabpanelopt=columns:20
275 set showtabline=0
276 set nowrap
277 set number
278 e aaa.txt
279 tabnew
280 e bbb.txt
281 vsplit
282 call setbufline(bufnr(), 1, repeat(['text text text text'], 100))
283 wincmd =
284 END
285 call writefile(lines, 'XTest_tabpanel_scrolling', 'D')
286
287 let buf = RunVimInTerminal('-S XTest_tabpanel_scrolling', {'rows': 10, 'cols': 45})
288 let n = 0
289 for c in ['H', 'J', 'K', 'L']
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200290 call term_sendkeys(buf, ":wincmd " .. c .. "\<CR>")
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200291 call term_sendkeys(buf, "\<C-d>\<C-d>")
292 call term_sendkeys(buf, "r@")
293 call VerifyScreenDump(buf, 'Test_tabpanel_drawing_scrolling_' .. n, {})
294 let n += 1
295 endfor
296
297 call StopVimInTerminal(buf)
298endfunc
299
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200300function Test_tabpanel_many_tabpages()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200301 CheckScreendump
302
303 let lines =<< trim END
304 set showtabpanel=2
305 set tabpanelopt=columns:10
306 set showtabline=0
307 set tabpanel=%{g:actual_curtabpage}:tab
308 execute join(repeat(['tabnew'], 20), ' | ')
309 END
310 call writefile(lines, 'XTest_tabpanel_many_tabpages', 'D')
311
312 let buf = RunVimInTerminal('-S XTest_tabpanel_many_tabpages', {'rows': 10, 'cols': 45})
313 for n in range(0, 3)
314 call term_sendkeys(buf, "gt")
315 call VerifyScreenDump(buf, 'Test_tabpanel_many_tabpages_' .. n, {})
316 endfor
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200317 call term_sendkeys(buf, ":tabnext +10\<CR>")
318 call term_sendkeys(buf, ":tabnext -3\<CR>")
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200319 call VerifyScreenDump(buf, 'Test_tabpanel_many_tabpages_4', {})
320
321 call StopVimInTerminal(buf)
322endfunc
323
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200324function Test_tabpanel_visual()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200325 CheckScreendump
326
327 let lines =<< trim END
328 set showtabpanel=2
329 set tabpanelopt=columns:10
330 set showtabline=0
331 tabnew
332 call setbufline(bufnr(), 1, ['aaa1 bbb1 ccc1 ddd1', 'aaa2 bbb2 ccc2 ddd2', 'aaa3 bbb3 ccc3 ddd3', 'aaa4 bbb4 ccc4 ddd4'])
333 END
334 call writefile(lines, 'XTest_tabpanel_visual', 'D')
335
336 let buf = RunVimInTerminal('-S XTest_tabpanel_visual', {'rows': 10, 'cols': 45})
337 call term_sendkeys(buf, "v2w")
338 call VerifyScreenDump(buf, 'Test_tabpanel_visual_0', {})
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200339 call term_sendkeys(buf, "\<Esc>0jw")
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200340 call term_sendkeys(buf, "v2wge")
341 call VerifyScreenDump(buf, 'Test_tabpanel_visual_1', {})
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200342 call term_sendkeys(buf, "y:echo @\"\<CR>")
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200343 call VerifyScreenDump(buf, 'Test_tabpanel_visual_2', {})
344
345 call StopVimInTerminal(buf)
346endfunc
347
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200348function Test_tabpanel_commandline()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200349 CheckScreendump
350
351 let lines =<< trim END
352 set showtabpanel=2
353 set tabpanelopt=columns:10
354 set showtabline=0
355 tabnew
356 END
357 call writefile(lines, 'XTest_tabpanel_commandline', 'D')
358
359 let buf = RunVimInTerminal('-S XTest_tabpanel_commandline', {'rows': 10, 'cols': 45})
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200360 call term_sendkeys(buf, ":ab\<Tab>")
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200361 call VerifyScreenDump(buf, 'Test_tabpanel_commandline_0', {})
362
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200363 call term_sendkeys(buf, "\<Esc>")
364 call term_sendkeys(buf, ":set wildoptions=pum\<CR>")
365 call term_sendkeys(buf, ":ab\<Tab>")
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200366 call VerifyScreenDump(buf, 'Test_tabpanel_commandline_1', {})
367
368 call StopVimInTerminal(buf)
369endfunc
370
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200371function Test_tabpanel_tabline_and_tabpanel()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200372 CheckScreendump
373
374 let lines =<< trim END
375 set showtabpanel=2
376 set tabpanelopt=columns:10,vert
377 set fillchars=tpl_vert:│
378 set showtabline=2
379 e aaa.txt
380 tabnew
381 e bbb.txt
382 tabnew
383 e ccc.txt
384 END
385 call writefile(lines, 'XTest_tabpanel_tabline_and_tabpanel', 'D')
386
387 let buf = RunVimInTerminal('-S XTest_tabpanel_tabline_and_tabpanel', {'rows': 10, 'cols': 45})
388 call VerifyScreenDump(buf, 'Test_tabpanel_tabline_and_tabpanel_0', {})
389
390 call StopVimInTerminal(buf)
391endfunc
392
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200393function Test_tabpanel_dont_overflow_into_tabpanel()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200394 CheckScreendump
395
396 let lines =<< trim END
397 set showtabpanel=2
398 set tabpanelopt=columns:10
399 set showtabline=2
400 tabnew
401 call setline(1, repeat('x', 100))
402 set wrap
403 END
404 call writefile(lines, 'XTest_tabpanel_dont_overflow_into_tabpanel', 'D')
405
406 let buf = RunVimInTerminal('-S XTest_tabpanel_dont_overflow_into_tabpanel', {'rows': 10, 'cols': 45})
407 call VerifyScreenDump(buf, 'Test_tabpanel_dont_overflow_into_tabpanel_0', {})
408
409 call StopVimInTerminal(buf)
410endfunc
411
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200412"""function Test_tabpanel_dont_vert_is_multibytes_left()
413""" CheckScreendump
414"""
415""" let lines =<< trim END
416""" set showtabpanel=2
417""" set tabpanelopt=columns:10,vert
418""" set fillchars=tpl_vert:│
419""" set showtabline=2
420""" tabnew
421""" END
422""" call writefile(lines, 'XTest_tabpanel_vert_is_multibyte_lefts', 'D')
423"""
424""" let buf = RunVimInTerminal('-S XTest_tabpanel_vert_is_multibyte_lefts', {'rows': 10, 'cols': 45})
425""" call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_left_0', {})
426"""
427""" call term_sendkeys(buf, ":set tabpanelopt=columns:1,vert\<CR>")
428""" call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_left_1', {})
429"""
430""" call term_sendkeys(buf, ":set tabpanelopt=columns:10,vert\<CR>")
431""" call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_left_2', {})
432"""
433""" call term_sendkeys(buf, ":set tabpanelopt=columns:2,vert\<CR>")
434""" call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_left_3', {})
435"""
436""" call StopVimInTerminal(buf)
437"""endfunc
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200438
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200439"""function Test_tabpanel_dont_vert_is_multibytes_right()
440""" CheckScreendump
441"""
442""" let lines =<< trim END
443""" set showtabpanel=2
444""" set tabpanelopt=align:right,columns:10,vert
445""" set fillchars=tpl_vert:│
446""" set showtabline=2
447""" tabnew
448""" END
449""" call writefile(lines, 'XTest_tabpanel_vert_is_multibytes_right', 'D')
450"""
451""" let buf = RunVimInTerminal('-S XTest_tabpanel_vert_is_multibytes_right', {'rows': 10, 'cols': 45})
452""" call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_right_0', {})
453"""
454""" call term_sendkeys(buf, ":set tabpanelopt=align:right,columns:1,vert\<CR>")
455""" call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_right_1', {})
456"""
457""" call term_sendkeys(buf, ":set tabpanelopt=align:right,columns:10,vert\<CR>")
458""" call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_right_2', {})
459"""
460""" call term_sendkeys(buf, ":set tabpanelopt=align:right,columns:2,vert\<CR>")
461""" call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_right_3', {})
462"""
463""" call StopVimInTerminal(buf)
464"""endfunc
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200465
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200466function Test_tabpanel_eval_tabpanel_statusline_tabline()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200467 CheckScreendump
468
469 let lines =<< trim END
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200470 function Expr()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200471 return "$%=[%f]%=$"
472 endfunction
473 set laststatus=2
474 set showtabline=2
475 set showtabpanel=2
476 set statusline=%!Expr()
477 set tabline=%!Expr()
478 set tabpanel=%!Expr()
479 set tabpanelopt=columns:10,vert
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200480 e aaa
481 tabnew
482 e bbb
483 tabnew
484 e ccc
485 END
486 call writefile(lines, 'XTest_tabpanel_eval_tabpanel_statusline_tabline', 'D')
487
488 let buf = RunVimInTerminal('-S XTest_tabpanel_eval_tabpanel_statusline_tabline', {'rows': 10, 'cols': 45})
489 call VerifyScreenDump(buf, 'Test_tabpanel_eval_tabpanel_statusline_tabline_0', {})
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200490 call term_sendkeys(buf, ":set tabpanelopt+=align:right\<CR>")
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200491 call VerifyScreenDump(buf, 'Test_tabpanel_eval_tabpanel_statusline_tabline_1', {})
492
493 call StopVimInTerminal(buf)
494endfunc
495
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200496function Test_tabpanel_noeval_tabpanel_statusline_tabline()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200497 CheckScreendump
498
499 let lines =<< trim END
500 set laststatus=2
501 set showtabline=2
502 set showtabpanel=2
503 set statusline=$%=[%f]%=$
504 set tabline=$%=[%f]%=$
505 set tabpanel=$%=[%f]%=$
506 set tabpanelopt=columns:10,vert
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200507 e aaa
508 tabnew
509 e bbb
510 tabnew
511 e ccc
512 END
513 call writefile(lines, 'XTest_tabpanel_noeval_tabpanel_statusline_tabline', 'D')
514
515 let buf = RunVimInTerminal('-S XTest_tabpanel_noeval_tabpanel_statusline_tabline', {'rows': 10, 'cols': 45})
516 call VerifyScreenDump(buf, 'Test_tabpanel_noeval_tabpanel_statusline_tabline_0', {})
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200517 call term_sendkeys(buf, ":set tabpanelopt+=align:right\<CR>")
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200518 call VerifyScreenDump(buf, 'Test_tabpanel_noeval_tabpanel_statusline_tabline_1', {})
519
520 call StopVimInTerminal(buf)
521endfunc
522
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200523function Test_tabpanel_eval_tabpanel_with_linebreaks()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200524 CheckScreendump
525
526 let lines =<< trim END
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200527 function Expr()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200528 return "top\n$%=[%f]%=$\nbottom"
529 endfunction
530 set showtabpanel=2
531 set tabpanel=%!Expr()
532 set tabpanelopt=columns:10
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200533 set noruler
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200534 e aaa
535 tabnew
536 e bbb
537 tabnew
538 e ccc
539 END
540 call writefile(lines, 'XTest_tabpanel_eval_tabpanel_with_linebreaks', 'D')
541
542 let buf = RunVimInTerminal('-S XTest_tabpanel_eval_tabpanel_with_linebreaks', {'rows': 10, 'cols': 45})
543 call VerifyScreenDump(buf, 'Test_tabpanel_eval_tabpanel_with_linebreaks_0', {})
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200544 call term_sendkeys(buf, ":set tabpanelopt+=align:right\<CR>")
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200545 call VerifyScreenDump(buf, 'Test_tabpanel_eval_tabpanel_with_linebreaks_1', {})
546
547 call StopVimInTerminal(buf)
548endfunc
549
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200550function Test_tabpanel_tabonly()
551 CheckScreendump
552
553 let lines =<< trim END
554 tabnew
555 set showtabpanel=1
556 norm 100oasdf
557 vsplit
558 END
559 call writefile(lines, 'XTest_tabpanel_tabonly', 'D')
560
Christian Brabandta004e512025-05-26 19:54:07 +0200561 let buf = RunVimInTerminal('-S XTest_tabpanel_tabonly', {'rows': 10, 'cols': 78})
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200562 call VerifyScreenDump(buf, 'Test_tabpanel_only_0', {})
563 call term_sendkeys(buf, ":tabonly\<CR>")
564 call VerifyScreenDump(buf, 'Test_tabpanel_only_1', {})
565
566 call StopVimInTerminal(buf)
567endfunc
568
Naruhiko Nishino2a1e2532025-05-17 16:19:24 +0200569function Test_tabpanel_equalalways()
570 CheckScreendump
571
572 let lines =<< trim END
573 tabnew
574 set showtabpanel=1
575 set tabpanelopt=columns:20
576 set equalalways
577 split
578 vsplit
579 END
580 call writefile(lines, 'XTest_tabpanel_equalalways', 'D')
581
582 let buf = RunVimInTerminal('-S XTest_tabpanel_equalalways', {'rows': 10, 'cols': 78})
583 call VerifyScreenDump(buf, 'Test_tabpanel_equalalways_0', {})
584 call term_sendkeys(buf, ":set tabpanelopt=columns:10\<CR>")
585 call VerifyScreenDump(buf, 'Test_tabpanel_equalalways_1', {})
586 call term_sendkeys(buf, ":set tabpanelopt=columns:30\<CR>")
587 call VerifyScreenDump(buf, 'Test_tabpanel_equalalways_2', {})
588 call term_sendkeys(buf, ":set tabpanelopt=columns:5\<CR>")
589 call VerifyScreenDump(buf, 'Test_tabpanel_equalalways_3', {})
590
591 call StopVimInTerminal(buf)
592endfunc
593
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200594function Test_tabpanel_quitall()
595 CheckScreendump
596
597 let lines =<< trim END
598 tabnew
599 set showtabpanel=1
600 set laststatus=2
601 call setline(1, 'aaa')
602 normal gt
603 silent! quitall
604 END
605 call writefile(lines, 'XTest_tabpanel_quitall', 'D')
606
607 let buf = RunVimInTerminal('-S XTest_tabpanel_quitall', {'rows': 10, 'cols': 45})
608 call VerifyScreenDump(buf, 'Test_tabpanel_quitall_0', {})
609
610 call StopVimInTerminal(buf)
611endfunc
612
613function Test_tabpanel_ruler()
614 CheckScreendump
615
616 let lines =<< trim END
617 tabnew
618 set statusline& laststatus=0
619 set rulerformat& ruler
620 set showtabpanel=1
621 END
622 call writefile(lines, 'XTest_tabpanel_ruler', 'D')
623
624 let buf = RunVimInTerminal('-S XTest_tabpanel_ruler', {'rows': 10, 'cols': 45})
625 call VerifyScreenDump(buf, 'Test_tabpanel_ruler_0', {})
626
627 call StopVimInTerminal(buf)
628endfunc
629
Christian Brabandta88c5bd2025-05-26 19:51:03 +0200630function Test_tabpanel_error()
631 set tabpanel=%!NonExistingFunc()
632 try
633 set showtabpanel=2
634 redraw!
635 catch /^Vim\%((\a\+)\)\=:E117:/
636 endtry
637 call assert_true(empty(&tabpanel))
Christian Brabandtac83b3c2025-05-27 20:49:34 +0200638
639 try
640 set tabpanel=%{my#util#TabPanelHighlight}%t
641 redraw!
642 catch /^Vim\%((\a\+)\)\=:E121:/
643 endtry
644 call assert_true(empty(&tabpanel))
645
Christian Brabandta88c5bd2025-05-26 19:51:03 +0200646 set tabpanel&vim
647 set showtabpanel&vim
648endfunc
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200649" vim: shiftwidth=2 sts=2 expandtab