blob: 0d729a82e14d8b787f3555f08c17c426177843e8 [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
Hirohito Higashia1522f72025-06-03 21:07:25 +020095 " Confirm that tabpagenr() does not change when dragging outside the tabpanel
96 call test_setmouse(3, 30)
97 call feedkeys("\<LeftMouse>", 'xt')
98 call test_setmouse(1, 30)
99 call feedkeys("\<LeftDrag>", 'xt')
100 call assert_equal(3, tabpagenr())
101
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200102 call feedkeys("\<LeftMouse>", 'xt')
103 call test_setmouse(2, 3)
104 let pos = getmousepos()
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200105 call assert_equal(0, pos['winid'])
106 call assert_equal(0, pos['winrow'])
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200107 call assert_equal(0, pos['wincol'])
108 call assert_equal(2, pos['screenrow'])
109 call assert_equal(3, pos['screencol'])
110
111 call test_setmouse(1, 11)
112 call feedkeys("\<LeftMouse>", 'xt')
113 let pos = getmousepos()
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200114 call assert_notequal(0, pos['winid'])
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200115 call assert_equal(1, pos['winrow'])
116 call assert_equal(1, pos['wincol'])
117 call assert_equal(1, pos['screenrow'])
118 call assert_equal(11, pos['screencol'])
119
120 new
121 wincmd x
122
123 call test_setmouse(10, 11)
124 call feedkeys("\<LeftMouse>", 'xt')
125 let pos = getmousepos()
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200126 call assert_notequal(0, pos['winid'])
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200127 call assert_equal(10, pos['winrow'])
128 call assert_equal(1, pos['wincol'])
129 call assert_equal(10, pos['screenrow'])
130 call assert_equal(11, pos['screencol'])
131
132 tabonly!
133 call s:reset()
134 let &mouse = save_mouse
135 let &showtabline = save_showtabline
136endfunc
137
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200138function Test_tabpanel_drawing()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200139 CheckScreendump
140
141 let lines =<< trim END
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200142 function MyTabPanel()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200143 let n = g:actual_curtabpage
144 let hi = n == tabpagenr() ? 'TabLineSel' : 'TabLine'
145 let label = printf("\n%%#%sTabNumber#%d:%%#%s#", hi, n, hi)
146 let label ..= '%1*%f%*'
147 return label
148 endfunction
149 hi User1 ctermfg=12
150
151 set showtabline=0
152 set showtabpanel=0
153 set tabpanelopt=columns:16
154 set tabpanel=
155 silent edit Xtabpanel1
156
157 nnoremap \01 <Cmd>set showtabpanel=2<CR>
158 nnoremap \02 <C-w>v
159 nnoremap \03 <Cmd>call setline(1, ['a', 'b', 'c'])<CR>
160 nnoremap \04 <Cmd>silent tabnew Xtabpanel2<CR><Cmd>call setline(1, ['d', 'e', 'f'])<CR>
161 nnoremap \05 <Cmd>set tabpanel=%!MyTabPanel()<CR>
162 nnoremap \06 <Cmd>set tabpanelopt+=align:right<CR>
163 nnoremap \07 <Cmd>tab terminal NONE<CR><C-w>N
164 nnoremap \08 <Cmd>tabclose!<CR><Cmd>tabclose!<CR>
165 END
166 call writefile(lines, 'XTest_tabpanel', 'D')
167
168 let buf = RunVimInTerminal('-S XTest_tabpanel', {'rows': 6, 'cols': 45})
169
170 call VerifyScreenDump(buf, 'Test_tabpanel_drawing_00', {})
171
172 for i in range(1, 8)
173 let n = printf('%02d', i)
174 call term_sendkeys(buf, '\' .. n)
175 call VerifyScreenDump(buf, 'Test_tabpanel_drawing_' .. n, {})
176 endfor
177
178 call StopVimInTerminal(buf)
179endfunc
180
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200181function Test_tabpanel_drawing_with_popupwin()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200182 CheckScreendump
183
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200184 let tcols = 45
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200185 let lines =<< trim END
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200186 set showtabpanel=0
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200187 set tabpanelopt=columns:20
188 set showtabline=0
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200189 set nowrap
190 set noruler
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200191 tabnew
192 setlocal buftype=nofile
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200193 call setbufline(bufnr(), 1, repeat([repeat('.', &columns)], &lines - &ch))
194 for col in [1, &columns - 2]
195 call popup_create(['@'],
196 \ {
197 \ 'line': 1,
198 \ 'col': col,
199 \ 'border': [],
200 \ 'highlight': 'ErrorMsg',
201 \ })
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200202 endfor
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200203 call cursor(5, 10)
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200204 call popup_atcursor('atcursor', {
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200205 \ 'highlight': 'Question',
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200206 \ })
207 END
208 call writefile(lines, 'XTest_tabpanel_with_popupwin', 'D')
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200209 let buf = RunVimInTerminal('-S XTest_tabpanel_with_popupwin', {'rows': 10, 'cols': tcols})
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200210 call VerifyScreenDump(buf, 'Test_tabpanel_drawing_with_popupwin_0', {})
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200211 call term_sendkeys(buf, ":set showtabpanel=2\<CR>\<C-L>")
212 call VerifyScreenDump(buf, 'Test_tabpanel_drawing_with_popupwin_1', {})
213 call term_sendkeys(buf, ":set tabpanelopt+=align:right\<CR>\<C-L>")
214 call VerifyScreenDump(buf, 'Test_tabpanel_drawing_with_popupwin_2', {})
215 call term_sendkeys(buf, ":set showtabpanel=0\<CR>\<C-L>")
216 call VerifyScreenDump(buf, 'Test_tabpanel_drawing_with_popupwin_0', {})
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200217 call StopVimInTerminal(buf)
218endfunc
219
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200220function Test_tabpanel_drawing_fill_tailing()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200221 CheckScreendump
222
223 let lines =<< trim END
224 set showtabpanel=2
225 set tabpanelopt=columns:20
226 set showtabline=0
227 e aaa.txt
228 tabnew
229 e bbb.txt
230 let &tabpanel = "abc"
231 redraw!
232 " Check whether "abc" is cleared
233 let &tabpanel = "\nTOP\n%f\nBOTTOM"
234 END
235 call writefile(lines, 'XTest_tabpanel_fill_tailing', 'D')
236
237 let buf = RunVimInTerminal('-S XTest_tabpanel_fill_tailing', {'rows': 10, 'cols': 45})
238
239 call VerifyScreenDump(buf, 'Test_tabpanel_drawing_fill_tailing_0', {})
240
241 call StopVimInTerminal(buf)
242endfunc
243
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200244function Test_tabpanel_drawing_pum()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200245 CheckScreendump
246
247 let lines =<< trim END
248 set showtabpanel=2
249 set tabpanelopt=columns:20
250 set showtabline=0
251 e aaa.txt
252 tabnew
253 e bbb.txt
254 END
255 call writefile(lines, 'XTest_tabpanel_pum', 'D')
256
257 let buf = RunVimInTerminal('-S XTest_tabpanel_pum', {'rows': 10, 'cols': 45})
258
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200259 call term_sendkeys(buf, "i\<CR>aa\<CR>aaaa\<CR>aaac\<CR>aaab\<CR>\<Esc>")
260 call term_sendkeys(buf, "ggi\<C-X>\<C-N>")
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200261 call VerifyScreenDump(buf, 'Test_tabpanel_drawing_pum_0', {})
262
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200263 call term_sendkeys(buf, "\<Esc>Go a\<C-X>\<C-P>")
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200264 call VerifyScreenDump(buf, 'Test_tabpanel_drawing_pum_1', {})
265
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200266 call term_sendkeys(buf, "\<C-U>\<CR>\<Esc>")
267 call term_sendkeys(buf, ":set tabpanelopt+=align:right\<CR>")
268 let num = 45 - 20 - 2 " term-win-width - tabpanel-columns - 2
269 call term_sendkeys(buf, num .. "a \<Esc>")
270 call term_sendkeys(buf, "a\<C-X>\<C-N>")
271 call VerifyScreenDump(buf, 'Test_tabpanel_drawing_pum_2', {})
272
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200273 call StopVimInTerminal(buf)
274endfunc
275
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200276function Test_tabpanel_scrolling()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200277 CheckScreendump
278
279 let lines =<< trim END
280 set showtabpanel=2
281 set tabpanelopt=columns:20
282 set showtabline=0
283 set nowrap
284 set number
285 e aaa.txt
286 tabnew
287 e bbb.txt
288 vsplit
289 call setbufline(bufnr(), 1, repeat(['text text text text'], 100))
290 wincmd =
291 END
292 call writefile(lines, 'XTest_tabpanel_scrolling', 'D')
293
294 let buf = RunVimInTerminal('-S XTest_tabpanel_scrolling', {'rows': 10, 'cols': 45})
295 let n = 0
296 for c in ['H', 'J', 'K', 'L']
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200297 call term_sendkeys(buf, ":wincmd " .. c .. "\<CR>")
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200298 call term_sendkeys(buf, "\<C-d>\<C-d>")
299 call term_sendkeys(buf, "r@")
300 call VerifyScreenDump(buf, 'Test_tabpanel_drawing_scrolling_' .. n, {})
301 let n += 1
302 endfor
303
304 call StopVimInTerminal(buf)
305endfunc
306
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200307function Test_tabpanel_many_tabpages()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200308 CheckScreendump
309
310 let lines =<< trim END
311 set showtabpanel=2
312 set tabpanelopt=columns:10
313 set showtabline=0
314 set tabpanel=%{g:actual_curtabpage}:tab
315 execute join(repeat(['tabnew'], 20), ' | ')
316 END
317 call writefile(lines, 'XTest_tabpanel_many_tabpages', 'D')
318
319 let buf = RunVimInTerminal('-S XTest_tabpanel_many_tabpages', {'rows': 10, 'cols': 45})
320 for n in range(0, 3)
321 call term_sendkeys(buf, "gt")
322 call VerifyScreenDump(buf, 'Test_tabpanel_many_tabpages_' .. n, {})
323 endfor
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200324 call term_sendkeys(buf, ":tabnext +10\<CR>")
325 call term_sendkeys(buf, ":tabnext -3\<CR>")
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200326 call VerifyScreenDump(buf, 'Test_tabpanel_many_tabpages_4', {})
327
328 call StopVimInTerminal(buf)
329endfunc
330
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200331function Test_tabpanel_visual()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200332 CheckScreendump
333
334 let lines =<< trim END
335 set showtabpanel=2
336 set tabpanelopt=columns:10
337 set showtabline=0
338 tabnew
339 call setbufline(bufnr(), 1, ['aaa1 bbb1 ccc1 ddd1', 'aaa2 bbb2 ccc2 ddd2', 'aaa3 bbb3 ccc3 ddd3', 'aaa4 bbb4 ccc4 ddd4'])
340 END
341 call writefile(lines, 'XTest_tabpanel_visual', 'D')
342
343 let buf = RunVimInTerminal('-S XTest_tabpanel_visual', {'rows': 10, 'cols': 45})
344 call term_sendkeys(buf, "v2w")
345 call VerifyScreenDump(buf, 'Test_tabpanel_visual_0', {})
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200346 call term_sendkeys(buf, "\<Esc>0jw")
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200347 call term_sendkeys(buf, "v2wge")
348 call VerifyScreenDump(buf, 'Test_tabpanel_visual_1', {})
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200349 call term_sendkeys(buf, "y:echo @\"\<CR>")
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200350 call VerifyScreenDump(buf, 'Test_tabpanel_visual_2', {})
351
352 call StopVimInTerminal(buf)
353endfunc
354
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200355function Test_tabpanel_commandline()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200356 CheckScreendump
357
358 let lines =<< trim END
359 set showtabpanel=2
360 set tabpanelopt=columns:10
361 set showtabline=0
362 tabnew
363 END
364 call writefile(lines, 'XTest_tabpanel_commandline', 'D')
365
366 let buf = RunVimInTerminal('-S XTest_tabpanel_commandline', {'rows': 10, 'cols': 45})
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200367 call term_sendkeys(buf, ":ab\<Tab>")
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200368 call VerifyScreenDump(buf, 'Test_tabpanel_commandline_0', {})
369
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200370 call term_sendkeys(buf, "\<Esc>")
371 call term_sendkeys(buf, ":set wildoptions=pum\<CR>")
372 call term_sendkeys(buf, ":ab\<Tab>")
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200373 call VerifyScreenDump(buf, 'Test_tabpanel_commandline_1', {})
374
375 call StopVimInTerminal(buf)
376endfunc
377
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200378function Test_tabpanel_tabline_and_tabpanel()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200379 CheckScreendump
380
381 let lines =<< trim END
382 set showtabpanel=2
383 set tabpanelopt=columns:10,vert
384 set fillchars=tpl_vert:│
385 set showtabline=2
386 e aaa.txt
387 tabnew
388 e bbb.txt
389 tabnew
390 e ccc.txt
391 END
392 call writefile(lines, 'XTest_tabpanel_tabline_and_tabpanel', 'D')
393
394 let buf = RunVimInTerminal('-S XTest_tabpanel_tabline_and_tabpanel', {'rows': 10, 'cols': 45})
395 call VerifyScreenDump(buf, 'Test_tabpanel_tabline_and_tabpanel_0', {})
396
397 call StopVimInTerminal(buf)
398endfunc
399
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200400function Test_tabpanel_dont_overflow_into_tabpanel()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200401 CheckScreendump
402
403 let lines =<< trim END
404 set showtabpanel=2
405 set tabpanelopt=columns:10
406 set showtabline=2
407 tabnew
408 call setline(1, repeat('x', 100))
409 set wrap
410 END
411 call writefile(lines, 'XTest_tabpanel_dont_overflow_into_tabpanel', 'D')
412
413 let buf = RunVimInTerminal('-S XTest_tabpanel_dont_overflow_into_tabpanel', {'rows': 10, 'cols': 45})
414 call VerifyScreenDump(buf, 'Test_tabpanel_dont_overflow_into_tabpanel_0', {})
415
416 call StopVimInTerminal(buf)
417endfunc
418
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200419"""function Test_tabpanel_dont_vert_is_multibytes_left()
420""" CheckScreendump
421"""
422""" let lines =<< trim END
423""" set showtabpanel=2
424""" set tabpanelopt=columns:10,vert
425""" set fillchars=tpl_vert:│
426""" set showtabline=2
427""" tabnew
428""" END
429""" call writefile(lines, 'XTest_tabpanel_vert_is_multibyte_lefts', 'D')
430"""
431""" let buf = RunVimInTerminal('-S XTest_tabpanel_vert_is_multibyte_lefts', {'rows': 10, 'cols': 45})
432""" call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_left_0', {})
433"""
434""" call term_sendkeys(buf, ":set tabpanelopt=columns:1,vert\<CR>")
435""" call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_left_1', {})
436"""
437""" call term_sendkeys(buf, ":set tabpanelopt=columns:10,vert\<CR>")
438""" call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_left_2', {})
439"""
440""" call term_sendkeys(buf, ":set tabpanelopt=columns:2,vert\<CR>")
441""" call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_left_3', {})
442"""
443""" call StopVimInTerminal(buf)
444"""endfunc
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200445
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200446"""function Test_tabpanel_dont_vert_is_multibytes_right()
447""" CheckScreendump
448"""
449""" let lines =<< trim END
450""" set showtabpanel=2
451""" set tabpanelopt=align:right,columns:10,vert
452""" set fillchars=tpl_vert:│
453""" set showtabline=2
454""" tabnew
455""" END
456""" call writefile(lines, 'XTest_tabpanel_vert_is_multibytes_right', 'D')
457"""
458""" let buf = RunVimInTerminal('-S XTest_tabpanel_vert_is_multibytes_right', {'rows': 10, 'cols': 45})
459""" call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_right_0', {})
460"""
461""" call term_sendkeys(buf, ":set tabpanelopt=align:right,columns:1,vert\<CR>")
462""" call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_right_1', {})
463"""
464""" call term_sendkeys(buf, ":set tabpanelopt=align:right,columns:10,vert\<CR>")
465""" call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_right_2', {})
466"""
467""" call term_sendkeys(buf, ":set tabpanelopt=align:right,columns:2,vert\<CR>")
468""" call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_right_3', {})
469"""
470""" call StopVimInTerminal(buf)
471"""endfunc
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200472
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200473function Test_tabpanel_eval_tabpanel_statusline_tabline()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200474 CheckScreendump
475
476 let lines =<< trim END
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200477 function Expr()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200478 return "$%=[%f]%=$"
479 endfunction
480 set laststatus=2
481 set showtabline=2
482 set showtabpanel=2
483 set statusline=%!Expr()
484 set tabline=%!Expr()
485 set tabpanel=%!Expr()
486 set tabpanelopt=columns:10,vert
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200487 e aaa
488 tabnew
489 e bbb
490 tabnew
491 e ccc
492 END
493 call writefile(lines, 'XTest_tabpanel_eval_tabpanel_statusline_tabline', 'D')
494
495 let buf = RunVimInTerminal('-S XTest_tabpanel_eval_tabpanel_statusline_tabline', {'rows': 10, 'cols': 45})
496 call VerifyScreenDump(buf, 'Test_tabpanel_eval_tabpanel_statusline_tabline_0', {})
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200497 call term_sendkeys(buf, ":set tabpanelopt+=align:right\<CR>")
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200498 call VerifyScreenDump(buf, 'Test_tabpanel_eval_tabpanel_statusline_tabline_1', {})
499
500 call StopVimInTerminal(buf)
501endfunc
502
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200503function Test_tabpanel_noeval_tabpanel_statusline_tabline()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200504 CheckScreendump
505
506 let lines =<< trim END
507 set laststatus=2
508 set showtabline=2
509 set showtabpanel=2
510 set statusline=$%=[%f]%=$
511 set tabline=$%=[%f]%=$
512 set tabpanel=$%=[%f]%=$
513 set tabpanelopt=columns:10,vert
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200514 e aaa
515 tabnew
516 e bbb
517 tabnew
518 e ccc
519 END
520 call writefile(lines, 'XTest_tabpanel_noeval_tabpanel_statusline_tabline', 'D')
521
522 let buf = RunVimInTerminal('-S XTest_tabpanel_noeval_tabpanel_statusline_tabline', {'rows': 10, 'cols': 45})
523 call VerifyScreenDump(buf, 'Test_tabpanel_noeval_tabpanel_statusline_tabline_0', {})
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200524 call term_sendkeys(buf, ":set tabpanelopt+=align:right\<CR>")
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200525 call VerifyScreenDump(buf, 'Test_tabpanel_noeval_tabpanel_statusline_tabline_1', {})
526
527 call StopVimInTerminal(buf)
528endfunc
529
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200530function Test_tabpanel_eval_tabpanel_with_linebreaks()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200531 CheckScreendump
532
533 let lines =<< trim END
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200534 function Expr()
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200535 return "top\n$%=[%f]%=$\nbottom"
536 endfunction
537 set showtabpanel=2
538 set tabpanel=%!Expr()
539 set tabpanelopt=columns:10
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200540 set noruler
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200541 e aaa
542 tabnew
543 e bbb
544 tabnew
545 e ccc
546 END
547 call writefile(lines, 'XTest_tabpanel_eval_tabpanel_with_linebreaks', 'D')
548
549 let buf = RunVimInTerminal('-S XTest_tabpanel_eval_tabpanel_with_linebreaks', {'rows': 10, 'cols': 45})
550 call VerifyScreenDump(buf, 'Test_tabpanel_eval_tabpanel_with_linebreaks_0', {})
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200551 call term_sendkeys(buf, ":set tabpanelopt+=align:right\<CR>")
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200552 call VerifyScreenDump(buf, 'Test_tabpanel_eval_tabpanel_with_linebreaks_1', {})
553
554 call StopVimInTerminal(buf)
555endfunc
556
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200557function Test_tabpanel_tabonly()
558 CheckScreendump
559
560 let lines =<< trim END
561 tabnew
562 set showtabpanel=1
563 norm 100oasdf
564 vsplit
565 END
566 call writefile(lines, 'XTest_tabpanel_tabonly', 'D')
567
Christian Brabandta004e512025-05-26 19:54:07 +0200568 let buf = RunVimInTerminal('-S XTest_tabpanel_tabonly', {'rows': 10, 'cols': 78})
Hirohito Higashic659e4a2025-05-16 19:34:34 +0200569 call VerifyScreenDump(buf, 'Test_tabpanel_only_0', {})
570 call term_sendkeys(buf, ":tabonly\<CR>")
571 call VerifyScreenDump(buf, 'Test_tabpanel_only_1', {})
572
573 call StopVimInTerminal(buf)
574endfunc
575
Naruhiko Nishino2a1e2532025-05-17 16:19:24 +0200576function Test_tabpanel_equalalways()
577 CheckScreendump
578
579 let lines =<< trim END
580 tabnew
581 set showtabpanel=1
582 set tabpanelopt=columns:20
583 set equalalways
584 split
585 vsplit
586 END
587 call writefile(lines, 'XTest_tabpanel_equalalways', 'D')
588
589 let buf = RunVimInTerminal('-S XTest_tabpanel_equalalways', {'rows': 10, 'cols': 78})
590 call VerifyScreenDump(buf, 'Test_tabpanel_equalalways_0', {})
591 call term_sendkeys(buf, ":set tabpanelopt=columns:10\<CR>")
592 call VerifyScreenDump(buf, 'Test_tabpanel_equalalways_1', {})
593 call term_sendkeys(buf, ":set tabpanelopt=columns:30\<CR>")
594 call VerifyScreenDump(buf, 'Test_tabpanel_equalalways_2', {})
595 call term_sendkeys(buf, ":set tabpanelopt=columns:5\<CR>")
596 call VerifyScreenDump(buf, 'Test_tabpanel_equalalways_3', {})
597
598 call StopVimInTerminal(buf)
599endfunc
600
Hirohito Higashi3b9b95d2025-06-01 20:22:55 +0200601function Test_tabpanel_quitall()
602 CheckScreendump
603
604 let lines =<< trim END
605 tabnew
606 set showtabpanel=1
607 set laststatus=2
608 call setline(1, 'aaa')
609 normal gt
610 silent! quitall
611 END
612 call writefile(lines, 'XTest_tabpanel_quitall', 'D')
613
614 let buf = RunVimInTerminal('-S XTest_tabpanel_quitall', {'rows': 10, 'cols': 45})
615 call VerifyScreenDump(buf, 'Test_tabpanel_quitall_0', {})
616
617 call StopVimInTerminal(buf)
618endfunc
619
620function Test_tabpanel_ruler()
621 CheckScreendump
622
623 let lines =<< trim END
624 tabnew
625 set statusline& laststatus=0
626 set rulerformat& ruler
627 set showtabpanel=1
628 END
629 call writefile(lines, 'XTest_tabpanel_ruler', 'D')
630
631 let buf = RunVimInTerminal('-S XTest_tabpanel_ruler', {'rows': 10, 'cols': 45})
632 call VerifyScreenDump(buf, 'Test_tabpanel_ruler_0', {})
633
634 call StopVimInTerminal(buf)
635endfunc
636
Christian Brabandta88c5bd2025-05-26 19:51:03 +0200637function Test_tabpanel_error()
638 set tabpanel=%!NonExistingFunc()
639 try
640 set showtabpanel=2
641 redraw!
642 catch /^Vim\%((\a\+)\)\=:E117:/
643 endtry
644 call assert_true(empty(&tabpanel))
Christian Brabandtac83b3c2025-05-27 20:49:34 +0200645
646 try
647 set tabpanel=%{my#util#TabPanelHighlight}%t
648 redraw!
649 catch /^Vim\%((\a\+)\)\=:E121:/
650 endtry
651 call assert_true(empty(&tabpanel))
652
Christian Brabandta88c5bd2025-05-26 19:51:03 +0200653 set tabpanel&vim
654 set showtabpanel&vim
655endfunc
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200656" vim: shiftwidth=2 sts=2 expandtab