1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
|
" Tests for tabpanel
source util/screendump.mnv
CheckFeature tabpanel
function s:reset()
set tabpanel&
set tabpanelopt&
set showtabpanel&
endfunc
function Test_tabpanel_showtabpanel_eq_0()
CheckScreendump
let lines =<< trim END
set showtabpanel=2
set noruler
call setbufline(bufnr(), 1, ['aaa','bbb','ccc','ddd'])
tabnew 0000
END
call writefile(lines, 'XTest_tabpanel_stpl_eq_0', 'D')
let buf = RunMNVInTerminal('-S XTest_tabpanel_stpl_eq_0', {'rows': 10, 'cols': 78})
call term_sendkeys(buf, ":set showtabpanel=0\<CR>\<C-L>")
call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_0_0', {})
call term_sendkeys(buf, ":tabnext\<CR>\<C-L>")
call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_0_1', {})
call term_sendkeys(buf, ":set showtabpanel=2\<CR>")
call term_sendkeys(buf, ":vsp aaa\<CR>:vsp bbb\<CR>\<C-L>")
call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_0_2', {})
call term_sendkeys(buf, ":set showtabpanel=0\<CR>\<C-L>")
call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_0_3', {})
call term_sendkeys(buf, ":wincmd |\<CR>")
call term_sendkeys(buf, ":set showtabpanel=2\<CR>\<C-L>")
call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_0_2', {})
call StopMNVInTerminal(buf)
endfunc
function Test_tabpanel_showtabpanel_eq_1()
CheckScreendump
let lines =<< trim END
set showtabpanel=1
set noruler
END
call writefile(lines, 'XTest_tabpanel_stpl_eq_1', 'D')
let buf = RunMNVInTerminal('-S XTest_tabpanel_stpl_eq_1', {'rows': 10, 'cols': 78})
call term_sendkeys(buf, "\<C-L>")
call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_1_0', {})
call term_sendkeys(buf, ":tabnew\<CR>\<C-L>")
call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_1_1', {})
call term_sendkeys(buf, ":tabfirst\<CR>:vsplit\<CR>\<C-L>")
call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_1_2', {})
call term_sendkeys(buf, ":tabclose\<CR>\<C-L>")
call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_1_0', {})
call term_sendkeys(buf, ":set tabpanelopt=align:right\<CR>\<C-L>")
call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_1_0', {})
call term_sendkeys(buf, ":tabnew\<CR>\<C-L>")
call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_1_3', {})
call term_sendkeys(buf, ":tabfirst\<CR>:vsplit\<CR>\<C-L>")
call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_1_4', {})
call term_sendkeys(buf, ":tabclose\<CR>\<C-L>")
call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_1_0', {})
call StopMNVInTerminal(buf)
endfunc
function Test_tabpanel_with_vsplit()
CheckScreendump
let lines =<< trim END
set showtabpanel=2
set tabpanelopt=columns:20
set showtabline=0
tabnew
END
call writefile(lines, 'XTest_tabpanel_with_vsplit', 'D')
let buf = RunMNVInTerminal('-S XTest_tabpanel_with_vsplit', {'rows': 10, 'cols': 78})
call VerifyScreenDump(buf, 'Test_tabpanel_with_vsplit_0', {})
call term_sendkeys(buf, ":vsplit\<CR>")
call VerifyScreenDump(buf, 'Test_tabpanel_with_vsplit_1', {})
call term_sendkeys(buf, ":vsplit\<CR>")
call VerifyScreenDump(buf, 'Test_tabpanel_with_vsplit_2', {})
call term_sendkeys(buf, ":only\<CR>")
call term_sendkeys(buf, ":set tabpanelopt=align:right,vert\<CR>")
call VerifyScreenDump(buf, 'Test_tabpanel_with_vsplit_3', {})
call term_sendkeys(buf, ":vsplit\<CR>")
call VerifyScreenDump(buf, 'Test_tabpanel_with_vsplit_4', {})
call term_sendkeys(buf, ":vsplit\<CR>")
call VerifyScreenDump(buf, 'Test_tabpanel_with_vsplit_5', {})
call StopMNVInTerminal(buf)
endfunc
func Call_cmd_funcs()
let g:results = [getcmdpos(), getcmdscreenpos(), getcmdline()]
endfunc
function Test_tabpanel_cmdline_pos()
let save_showtabline = &showtabline
let g:results = []
cnoremap <expr> <F2> Call_cmd_funcs()
set showtabline=0 showtabpanel=0
call Call_cmd_funcs()
call assert_equal([0, 0, ''], g:results)
call feedkeys(":\<F2>\<Esc>", "xt")
call assert_equal([1, 2, ''], g:results)
call feedkeys(":pwd\<F2>\<Esc>", "xt")
call assert_equal([4, 5, 'pwd'], g:results)
set showtabline=2 showtabpanel=2 tabpanelopt=columns:20,align:left
call Call_cmd_funcs()
call assert_equal([0, 0, ''], g:results)
call feedkeys(":\<F2>\<Esc>", "xt")
call assert_equal([1, 22, ''], g:results)
call feedkeys(":pwd\<F2>\<Esc>", "xt")
call assert_equal([4, 25, 'pwd'], g:results)
set showtabline=2 showtabpanel=2 tabpanelopt+=align:right
call Call_cmd_funcs()
call assert_equal([0, 0, ''], g:results)
call feedkeys(":\<F2>\<Esc>", "xt")
call assert_equal([1, 2, ''], g:results)
call feedkeys(":pwd\<F2>\<Esc>", "xt")
call assert_equal([4, 5, 'pwd'], g:results)
unlet g:results
cunmap <F2>
call s:reset()
let &showtabline = save_showtabline
endfunc
function Test_tabpanel_cmdline_compl()
CheckScreendump
let lines =<< trim END
set showtabpanel=2
set tabpanelopt=columns:10
set showtabline=0
tabnew
END
call writefile(lines, 'XTest_tabpanel_cmdline_compl', 'D')
let buf = RunMNVInTerminal('-S XTest_tabpanel_cmdline_compl', {'rows': 10, 'cols': 45})
call term_sendkeys(buf, ":ab\<Tab>")
call VerifyScreenDump(buf, 'Test_tabpanel_cmdline_compl_0', {})
call term_sendkeys(buf, "\<Esc>")
call term_sendkeys(buf, ":set wildoptions=pum\<CR>")
call term_sendkeys(buf, ":ab\<Tab>")
call VerifyScreenDump(buf, 'Test_tabpanel_cmdline_compl_1', {})
call StopMNVInTerminal(buf)
endfunc
function Test_tabpanel_mouse()
let save_showtabline = &showtabline
let save_mouse = &mouse
set showtabline=0 mouse=a
tabnew
tabnew
call test_setmouse(1, 1)
call feedkeys("\<LeftMouse>", 'xt')
call assert_equal(3, tabpagenr())
set showtabpanel=2 tabpanelopt=columns:10
call test_setmouse(1, 1)
call feedkeys("\<LeftMouse>", 'xt')
call assert_equal(1, tabpagenr())
call test_setmouse(2, 1)
call feedkeys("\<LeftMouse>", 'xt')
call assert_equal(2, tabpagenr())
call test_setmouse(3, 1)
call feedkeys("\<LeftMouse>", 'xt')
call assert_equal(3, tabpagenr())
call test_setmouse(&lines, 1)
call feedkeys("\<LeftMouse>", 'xt')
call assert_equal(1, tabpagenr())
" Drag the active tab page
tablast
call test_setmouse(3, 1)
call feedkeys("\<LeftMouse>\<LeftDrag>", 'xt')
call test_setmouse(2, 1)
call feedkeys("\<LeftDrag>", 'xt')
call assert_equal(3, tabpagenr())
call feedkeys("\<LeftRelease>", 'xt')
tabmove $
" Drag the inactive tab page
tablast
call test_setmouse(2, 1)
call feedkeys("\<LeftMouse>\<LeftDrag>", 'xt')
call test_setmouse(1, 1)
call feedkeys("\<LeftDrag>", 'xt')
call assert_equal(2, tabpagenr())
call feedkeys("\<LeftRelease>", 'xt')
tabmove 2
" Confirm that tabpagenr() does not change when dragging outside the tabpanel
tablast
call test_setmouse(3, 30)
call feedkeys("\<LeftMouse>\<LeftDrag>", 'xt')
call test_setmouse(1, 30)
call feedkeys("\<LeftDrag>", 'xt')
call feedkeys("\<LeftRelease>", 'xt')
call assert_equal(3, tabpagenr())
" Test getmousepos()
call test_setmouse(2, 3)
call feedkeys("\<LeftMouse>", 'xt')
let pos = getmousepos()
call assert_equal(0, pos['winid'])
call assert_equal(0, pos['winrow'])
call assert_equal(0, pos['wincol'])
call assert_equal(2, pos['screenrow'])
call assert_equal(3, pos['screencol'])
call test_setmouse(1, 11)
call feedkeys("\<LeftMouse>", 'xt')
let pos = getmousepos()
call assert_notequal(0, pos['winid'])
call assert_equal(1, pos['winrow'])
call assert_equal(1, pos['wincol'])
call assert_equal(1, pos['screenrow'])
call assert_equal(11, pos['screencol'])
new
wincmd x
call test_setmouse(10, 11)
call feedkeys("\<LeftMouse>", 'xt')
let pos = getmousepos()
call assert_notequal(0, pos['winid'])
call assert_equal(10, pos['winrow'])
call assert_equal(1, pos['wincol'])
call assert_equal(10, pos['screenrow'])
call assert_equal(11, pos['screencol'])
tabonly!
call s:reset()
let &mouse = save_mouse
let &showtabline = save_showtabline
endfunc
function Test_tabpanel_drawing()
CheckScreendump
let lines =<< trim END
function MyTabPanel()
let n = g:actual_curtabpage
let hi = n == tabpagenr() ? 'TabLineSel' : 'TabLine'
let label = printf("%%@%%#%sTabNumber#%d:%%#%s#", hi, n, hi)
let label ..= '%1*%f%*'
return label
endfunction
hi User1 ctermfg=12
set showtabline=0
set showtabpanel=0
set tabpanelopt=columns:16
set tabpanel=
silent edit Xtabpanel1
nnoremap \01 <Cmd>set showtabpanel=2<CR>
nnoremap \02 <C-w>v
nnoremap \03 <Cmd>call setline(1, ['a', 'b', 'c'])<CR>
nnoremap \04 <Cmd>silent tabnew Xtabpanel2<CR><Cmd>call setline(1, ['d', 'e', 'f'])<CR>
nnoremap \05 <Cmd>set tabpanel=%!MyTabPanel()<CR>
nnoremap \06 <Cmd>set tabpanelopt+=align:right<CR>
nnoremap \07 <Cmd>tab terminal NONE<CR><C-w>N
nnoremap \08 <Cmd>tabclose!<CR><Cmd>tabclose!<CR>
END
call writefile(lines, 'XTest_tabpanel', 'D')
let buf = RunMNVInTerminal('-S XTest_tabpanel', {'rows': 6, 'cols': 45})
call VerifyScreenDump(buf, 'Test_tabpanel_drawing_00', {})
for i in range(1, 8)
let n = printf('%02d', i)
call term_sendkeys(buf, '\' .. n)
call VerifyScreenDump(buf, 'Test_tabpanel_drawing_' .. n, {})
endfor
call StopMNVInTerminal(buf)
endfunc
function Test_tabpanel_drawing_2()
CheckScreendump
let lines =<< trim END
set showtabpanel=2
set tabpanelopt=align:right,vert
call setbufline(bufnr(), 1, ['', 'aaa'])
END
call writefile(lines, 'XTest_tabpanel_drawing_2', 'D')
let buf = RunMNVInTerminal('-S XTest_tabpanel_drawing_2', {'rows': 10, 'cols': 78})
call term_sendkeys(buf, "ggo")
call VerifyScreenDump(buf, 'Test_tabpanel_drawing_2_0', {})
call term_sendkeys(buf, "\<Esc>u:set tabpanelopt+=align:left\<CR>")
call term_sendkeys(buf, "ggo")
call VerifyScreenDump(buf, 'Test_tabpanel_drawing_2_1', {})
call StopMNVInTerminal(buf)
endfunc
function Test_tabpanel_drawing_with_popupwin()
CheckScreendump
let tcols = 45
let lines =<< trim END
set showtabpanel=0
set tabpanelopt=columns:20
set showtabline=0
set nowrap
set noruler
tabnew
setlocal buftype=nofile
call setbufline(bufnr(), 1, repeat([repeat('.', &columns)], &lines - &ch))
for col in [1, &columns - 2]
call popup_create(['@'],
\ {
\ 'line': 1,
\ 'col': col,
\ 'border': [],
\ 'highlight': 'ErrorMsg',
\ })
endfor
call cursor(5, 10)
call popup_atcursor('atcursor', {
\ 'highlight': 'Question',
\ })
END
call writefile(lines, 'XTest_tabpanel_with_popupwin', 'D')
let buf = RunMNVInTerminal('-S XTest_tabpanel_with_popupwin', {'rows': 10, 'cols': tcols})
call VerifyScreenDump(buf, 'Test_tabpanel_drawing_with_popupwin_0', {})
call term_sendkeys(buf, ":set showtabpanel=2\<CR>\<C-L>")
call VerifyScreenDump(buf, 'Test_tabpanel_drawing_with_popupwin_1', {})
call term_sendkeys(buf, ":set tabpanelopt+=align:right\<CR>\<C-L>")
call VerifyScreenDump(buf, 'Test_tabpanel_drawing_with_popupwin_2', {})
call term_sendkeys(buf, ":set showtabpanel=0\<CR>\<C-L>")
call VerifyScreenDump(buf, 'Test_tabpanel_drawing_with_popupwin_0', {})
call StopMNVInTerminal(buf)
endfunc
function Test_tabpanel_drawing_fill_tailing()
CheckScreendump
let lines =<< trim END
set showtabpanel=2
set tabpanelopt=columns:20
set showtabline=0
e aaa.txt
tabnew
e bbb.txt
let &tabpanel = "abc"
redraw!
" Check whether "abc" is cleared
let &tabpanel = "%@TOP%@%f%@BOTTOM"
END
call writefile(lines, 'XTest_tabpanel_fill_tailing', 'D')
let buf = RunMNVInTerminal('-S XTest_tabpanel_fill_tailing', {'rows': 10, 'cols': 45})
call VerifyScreenDump(buf, 'Test_tabpanel_drawing_fill_tailing_0', {})
" TODO: If line breaks within 'tabpanel' using "\n" are no longer supported,
" delete the following two lines:
call term_sendkeys(buf, ':let &tabpanel = "\nTOP\n%f\nBOTTOM"' .. "\<CR>")
call VerifyScreenDump(buf, 'Test_tabpanel_drawing_fill_tailing_0', {})
call StopMNVInTerminal(buf)
endfunc
function Test_tabpanel_drawing_pum()
CheckScreendump
let lines =<< trim END
set showtabpanel=2
set tabpanelopt=columns:20
set showtabline=0
e aaa.txt
tabnew
e bbb.txt
END
call writefile(lines, 'XTest_tabpanel_pum', 'D')
let buf = RunMNVInTerminal('-S XTest_tabpanel_pum', {'rows': 10, 'cols': 45})
call term_sendkeys(buf, "i\<CR>aa\<CR>aaaa\<CR>aaac\<CR>aaab\<CR>\<Esc>")
call term_sendkeys(buf, "ggi\<C-X>\<C-N>")
call VerifyScreenDump(buf, 'Test_tabpanel_drawing_pum_0', {})
call term_sendkeys(buf, "\<Esc>Go a\<C-X>\<C-P>")
call VerifyScreenDump(buf, 'Test_tabpanel_drawing_pum_1', {})
call term_sendkeys(buf, "\<C-U>\<CR>\<Esc>")
call term_sendkeys(buf, ":set tabpanelopt+=align:right\<CR>")
let num = 45 - 20 - 2 " term-win-width - tabpanel-columns - 2
call term_sendkeys(buf, num .. "a \<Esc>")
call term_sendkeys(buf, "a\<C-X>\<C-N>")
call VerifyScreenDump(buf, 'Test_tabpanel_drawing_pum_2', {})
call StopMNVInTerminal(buf)
endfunc
function Test_tabpanel_scrolling()
CheckScreendump
let lines =<< trim END
set showtabpanel=2
set tabpanelopt=columns:20
set showtabline=0
set nowrap
set number
e aaa.txt
tabnew
e bbb.txt
vsplit
call setbufline(bufnr(), 1, repeat(['text text text text'], 100))
wincmd =
END
call writefile(lines, 'XTest_tabpanel_scrolling', 'D')
let buf = RunMNVInTerminal('-S XTest_tabpanel_scrolling', {'rows': 10, 'cols': 45})
let n = 0
for c in ['H', 'J', 'K', 'L']
call term_sendkeys(buf, ":wincmd " .. c .. "\<CR>")
call term_sendkeys(buf, "\<C-d>\<C-d>")
call term_sendkeys(buf, "r@")
call VerifyScreenDump(buf, 'Test_tabpanel_drawing_scrolling_' .. n, {})
let n += 1
endfor
call StopMNVInTerminal(buf)
endfunc
function Test_tabpanel_many_tabpages()
CheckScreendump
let lines =<< trim END
set showtabpanel=2
set tabpanelopt=columns:10
set showtabline=0
set tabpanel=%{g:actual_curtabpage}:tab
execute join(repeat(['tabnew'], 20), ' | ')
END
call writefile(lines, 'XTest_tabpanel_many_tabpages', 'D')
let buf = RunMNVInTerminal('-S XTest_tabpanel_many_tabpages', {'rows': 10, 'cols': 45})
for n in range(0, 3)
call term_sendkeys(buf, "gt")
call VerifyScreenDump(buf, 'Test_tabpanel_many_tabpages_' .. n, {})
endfor
call term_sendkeys(buf, ":tabnext +10\<CR>")
call term_sendkeys(buf, ":tabnext -3\<CR>")
call VerifyScreenDump(buf, 'Test_tabpanel_many_tabpages_4', {})
call StopMNVInTerminal(buf)
endfunc
function Test_tabpanel_visual()
CheckScreendump
let lines =<< trim END
set showtabpanel=2
set tabpanelopt=columns:10
set showtabline=0 laststatus=2
tabnew
call setbufline(bufnr(), 1, ['aaa1 bbb1 ccc1 ddd1', 'aaa2 bbb2 ccc2 ddd2', 'aaa3 bbb3 ccc3 ddd3', 'aaa4 bbb4 ccc4 ddd4'])
END
call writefile(lines, 'XTest_tabpanel_visual', 'D')
let buf = RunMNVInTerminal('-S XTest_tabpanel_visual', {'rows': 10, 'cols': 45})
call term_sendkeys(buf, "v2w")
call VerifyScreenDump(buf, 'Test_tabpanel_visual_0', {})
call term_sendkeys(buf, "\<Esc>0jw")
call term_sendkeys(buf, "v2wge")
call VerifyScreenDump(buf, 'Test_tabpanel_visual_1', {})
call term_sendkeys(buf, "y:echo @\"\<CR>")
call VerifyScreenDump(buf, 'Test_tabpanel_visual_2', {})
call StopMNVInTerminal(buf)
endfunc
function Test_tabpanel_with_tabline()
CheckScreendump
let lines =<< trim END
set showtabpanel=2
set tabpanelopt=columns:10,vert
set fillchars=tpl_vert:│
set showtabline=2 laststatus=2
e aaa.txt
tabnew
e bbb.txt
tabnew
e ccc.txt
END
call writefile(lines, 'XTest_tabpanel_with_tabline', 'D')
let buf = RunMNVInTerminal('-S XTest_tabpanel_with_tabline', {'rows': 10, 'cols': 45})
call VerifyScreenDump(buf, 'Test_tabpanel_with_tabline_0', {})
call StopMNVInTerminal(buf)
endfunc
function Test_tabpanel_dont_overflow_into_tabpanel()
CheckScreendump
let lines =<< trim END
set showtabpanel=2
set tabpanelopt=columns:10
set showtabline=2
tabnew
call setline(1, repeat('x', 100))
set wrap
END
call writefile(lines, 'XTest_tabpanel_dont_overflow_into_tabpanel', 'D')
let buf = RunMNVInTerminal('-S XTest_tabpanel_dont_overflow_into_tabpanel', {'rows': 10, 'cols': 45})
call VerifyScreenDump(buf, 'Test_tabpanel_dont_overflow_into_tabpanel_0', {})
call StopMNVInTerminal(buf)
endfunc
"""function Test_tabpanel_dont_vert_is_multibytes_left()
""" CheckScreendump
"""
""" let lines =<< trim END
""" set showtabpanel=2
""" set tabpanelopt=columns:10,vert
""" set fillchars=tpl_vert:│
""" set showtabline=2
""" tabnew
""" END
""" call writefile(lines, 'XTest_tabpanel_vert_is_multibyte_lefts', 'D')
"""
""" let buf = RunMNVInTerminal('-S XTest_tabpanel_vert_is_multibyte_lefts', {'rows': 10, 'cols': 45})
""" call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_left_0', {})
"""
""" call term_sendkeys(buf, ":set tabpanelopt=columns:1,vert\<CR>")
""" call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_left_1', {})
"""
""" call term_sendkeys(buf, ":set tabpanelopt=columns:10,vert\<CR>")
""" call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_left_2', {})
"""
""" call term_sendkeys(buf, ":set tabpanelopt=columns:2,vert\<CR>")
""" call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_left_3', {})
"""
""" call StopMNVInTerminal(buf)
"""endfunc
"""function Test_tabpanel_dont_vert_is_multibytes_right()
""" CheckScreendump
"""
""" let lines =<< trim END
""" set showtabpanel=2
""" set tabpanelopt=align:right,columns:10,vert
""" set fillchars=tpl_vert:│
""" set showtabline=2
""" tabnew
""" END
""" call writefile(lines, 'XTest_tabpanel_vert_is_multibytes_right', 'D')
"""
""" let buf = RunMNVInTerminal('-S XTest_tabpanel_vert_is_multibytes_right', {'rows': 10, 'cols': 45})
""" call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_right_0', {})
"""
""" call term_sendkeys(buf, ":set tabpanelopt=align:right,columns:1,vert\<CR>")
""" call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_right_1', {})
"""
""" call term_sendkeys(buf, ":set tabpanelopt=align:right,columns:10,vert\<CR>")
""" call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_right_2', {})
"""
""" call term_sendkeys(buf, ":set tabpanelopt=align:right,columns:2,vert\<CR>")
""" call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_right_3', {})
"""
""" call StopMNVInTerminal(buf)
"""endfunc
function Test_tabpanel_eval()
CheckScreendump
let lines =<< trim END
function Expr()
return "$%=[%f]%=$"
endfunction
set laststatus=2
set showtabline=2
set showtabpanel=2
set statusline=%!Expr()
set tabline=%!Expr()
set tabpanel=%!Expr()
set tabpanelopt=columns:10,vert
e aaa
tabnew
e bbb
tabnew
e ccc
END
call writefile(lines, 'XTest_tabpanel_eval', 'D')
let buf = RunMNVInTerminal('-S XTest_tabpanel_eval', {'rows': 10, 'cols': 45})
call VerifyScreenDump(buf, 'Test_tabpanel_eval_0', {})
call term_sendkeys(buf, ":set tabpanelopt+=align:right\<CR>")
call VerifyScreenDump(buf, 'Test_tabpanel_eval_1', {})
call StopMNVInTerminal(buf)
endfunc
function Test_tabpanel_noeval()
CheckScreendump
let lines =<< trim END
set laststatus=2
set showtabline=2
set showtabpanel=2
set statusline=$%=[%f]%=$
set tabline=$%=[%f]%=$
set tabpanel=$%=[%f]%=$
set tabpanelopt=columns:10,vert
e aaa
tabnew
e bbb
tabnew
e ccc
END
call writefile(lines, 'XTest_tabpanel_noeval', 'D')
let buf = RunMNVInTerminal('-S XTest_tabpanel_noeval', {'rows': 10, 'cols': 45})
call VerifyScreenDump(buf, 'Test_tabpanel_noeval_0', {})
call term_sendkeys(buf, ":set tabpanelopt+=align:right\<CR>")
call VerifyScreenDump(buf, 'Test_tabpanel_noeval_1', {})
call StopMNVInTerminal(buf)
endfunc
function Test_tabpanel_eval_with_linebreaks()
CheckScreendump
let lines =<< trim END
let g:ExprRetVal = "top%@$%=[%f]%=$%@bottom"
function Expr()
return g:ExprRetVal
endfunction
set showtabpanel=2
set tabpanel=%!Expr()
set tabpanelopt=columns:10
set noruler
e aaa
tabnew
e bbb
tabnew
e ccc
END
call writefile(lines, 'XTest_tabpanel_eval_with_linebreaks', 'D')
let buf = RunMNVInTerminal('-S XTest_tabpanel_eval_with_linebreaks', {'rows': 10, 'cols': 45})
call term_sendkeys(buf, "\<C-L>") " Clear cmdline area
call VerifyScreenDump(buf, 'Test_tabpanel_eval_with_linebreaks_0', {})
call term_sendkeys(buf, ":set tabpanelopt+=align:right\<CR>")
call VerifyScreenDump(buf, 'Test_tabpanel_eval_with_linebreaks_1', {})
" TODO: If line breaks within 'tabpanel' using "\n" are no longer supported,
" delete the following five lines:
call term_sendkeys(buf, ':let g:ExprRetVal = "top\n$%=[%f]%=$\nbottom"' .. "\<CR>")
call term_sendkeys(buf, ":set tabpanelopt=columns:10\<CR>")
call VerifyScreenDump(buf, 'Test_tabpanel_eval_with_linebreaks_0', {})
call term_sendkeys(buf, ":set tabpanelopt+=align:right\<CR>")
call VerifyScreenDump(buf, 'Test_tabpanel_eval_with_linebreaks_1', {})
call StopMNVInTerminal(buf)
endfunc
function Test_tabpanel_tabonly()
CheckScreendump
let lines =<< trim END
tabnew
set showtabpanel=1
norm 100oasdf
vsplit
END
call writefile(lines, 'XTest_tabpanel_tabonly', 'D')
let buf = RunMNVInTerminal('-S XTest_tabpanel_tabonly', {'rows': 10, 'cols': 78})
call VerifyScreenDump(buf, 'Test_tabpanel_only_0', {})
call term_sendkeys(buf, ":tabonly\<CR>")
call VerifyScreenDump(buf, 'Test_tabpanel_only_1', {})
call StopMNVInTerminal(buf)
endfunc
function Test_tabpanel_equalalways()
CheckScreendump
let lines =<< trim END
tabnew
set showtabpanel=1
set tabpanelopt=columns:20
set equalalways
split
vsplit
END
call writefile(lines, 'XTest_tabpanel_equalalways', 'D')
let buf = RunMNVInTerminal('-S XTest_tabpanel_equalalways', {'rows': 10, 'cols': 78})
call VerifyScreenDump(buf, 'Test_tabpanel_equalalways_0', {})
call term_sendkeys(buf, ":set tabpanelopt=columns:10\<CR>")
call VerifyScreenDump(buf, 'Test_tabpanel_equalalways_1', {})
call term_sendkeys(buf, ":set tabpanelopt=columns:30\<CR>")
call VerifyScreenDump(buf, 'Test_tabpanel_equalalways_2', {})
call term_sendkeys(buf, ":set tabpanelopt=columns:5\<CR>")
call VerifyScreenDump(buf, 'Test_tabpanel_equalalways_3', {})
call StopMNVInTerminal(buf)
endfunc
function Test_tabpanel_quitall()
CheckScreendump
let lines =<< trim END
tabnew
set showtabpanel=1
set laststatus=2
call setline(1, 'aaa')
normal gt
silent! quitall
END
call writefile(lines, 'XTest_tabpanel_quitall', 'D')
let buf = RunMNVInTerminal('-S XTest_tabpanel_quitall', {'rows': 10, 'cols': 45})
call VerifyScreenDump(buf, 'Test_tabpanel_quitall_0', {})
call StopMNVInTerminal(buf)
endfunc
function Test_tabpanel_ruler()
CheckScreendump
let lines =<< trim END
tabnew
set statusline& laststatus=0
set rulerformat& ruler
set showtabpanel=1
END
call writefile(lines, 'XTest_tabpanel_ruler', 'D')
let buf = RunMNVInTerminal('-S XTest_tabpanel_ruler', {'rows': 10, 'cols': 45})
call VerifyScreenDump(buf, 'Test_tabpanel_ruler_0', {})
call StopMNVInTerminal(buf)
endfunc
function Test_tabpanel_error()
set tabpanel=%!NonExistingFunc()
try
set showtabpanel=2
redraw!
catch /^MNV\%((\a\+)\)\=:E117:/
endtry
call assert_true(empty(&tabpanel))
try
set tabpanel=%{my#util#TabPanelHighlight}%t
redraw!
catch /^MNV\%((\a\+)\)\=:E121:/
endtry
call assert_true(empty(&tabpanel))
set tabpanel&mnv
set showtabpanel&mnv
endfunc
function Test_tabpanel_with_msg_scrolled()
CheckScreendump
let lines =<< trim END
set showtabpanel=2
set noruler
tabnew
set modified
tabfirst
END
call writefile(lines, 'XTest_tabpanel_with_msg_scrolled', 'D')
let buf = RunMNVInTerminal('-S XTest_tabpanel_with_msg_scrolled', {'rows': 10, 'cols': 45})
call VerifyScreenDump(buf, 'Test_tabpanel_with_msg_scrolled_0', {})
call term_sendkeys(buf, ":qa\<CR>")
call term_sendkeys(buf, "\<CR>")
call VerifyScreenDump(buf, 'Test_tabpanel_with_msg_scrolled_1', {})
call StopMNVInTerminal(buf)
endfunc
function Test_tabpanel_with_cmdline_pum()
CheckScreendump
let lines =<< trim END
set showtabpanel=2
set noruler
tabnew aaa
set wildoptions+=pum
func TimerCb(timer)
tabnew bbb
endfunc
call timer_start(100, 'TimerCb')
END
call writefile(lines, 'XTest_tabpanel_with_cmdline_pum', 'D')
let buf = RunMNVInTerminal('-S XTest_tabpanel_with_cmdline_pum', {'rows': 10, 'cols': 45})
call term_sendkeys(buf, "\<C-L>")
call VerifyScreenDump(buf, 'Test_tabpanel_with_cmdline_pum_0', {})
call term_sendkeys(buf, ":set\<Tab>")
call term_wait(buf, 120)
call VerifyScreenDump(buf, 'Test_tabpanel_with_cmdline_pum_1', {})
call term_sendkeys(buf, "\<Esc>:tabclose\<CR>\<C-L>")
call VerifyScreenDump(buf, 'Test_tabpanel_with_cmdline_pum_0', {})
call StopMNVInTerminal(buf)
endfunc
function Test_tabpanel_with_cmdline_no_pum()
CheckScreendump
let lines =<< trim END
set showtabpanel=2
set noruler
tabnew aaa
set wildoptions-=pum
END
call writefile(lines, 'XTest_tabpanel_with_cmdline_pum', 'D')
let buf = RunMNVInTerminal('-S XTest_tabpanel_with_cmdline_pum', {'rows': 10, 'cols': 45})
call term_sendkeys(buf, "\<C-L>")
call VerifyScreenDump(buf, 'Test_tabpanel_with_cmdline_no_pum_0', {})
call term_sendkeys(buf, ":tabne\<Tab>")
call VerifyScreenDump(buf, 'Test_tabpanel_with_cmdline_no_pum_1', {})
call term_sendkeys(buf, "\<Esc>\<C-L>")
call VerifyScreenDump(buf, 'Test_tabpanel_with_cmdline_no_pum_0', {})
call StopMNVInTerminal(buf)
endfunc
" When showtabpanel=1 and a second tab is opened, all existing tab pages must
" have their frame width updated, not just the newly created one.
function Test_tabpanel_showtabpanel_via_cmd_arg()
let tpl_width = 20 " default tpl_columns
set showtabpanel=1 noruler
" With one tab the tabpanel is hidden; no width reduction yet.
tabfirst
call assert_equal(&columns, winwidth(0))
" Opening a second tab makes the tabpanel visible; the first tab page must
" also get its frame width reduced.
tabnew
tabfirst
call assert_equal(&columns - tpl_width, winwidth(0),
\ 'first tab width after tabnew')
call assert_equal(tpl_width + 1, win_screenpos(0)[1],
\ 'first tab wincol after tabnew')
tabonly
set showtabpanel& noruler&
endfunc
func Test_tabpanel_no_modeline()
let _tpl = &tabpanel
let _mls = &modelineexpr
set nomodelineexpr
setlocal modeline
new
call writefile(['/* mnv: set tabpanel=test: */'], 'Xtabpanel.txt', 'D')
call assert_fails(':e Xtabpanel.txt', 'E992:')
let &tabpanel = _tpl
let &modelineexpr = _mls
bw!
endfunc
func Test_tabpanel_large_columns()
call assert_fails(':set tabpanelopt=columns:10001', 'E474:')
call assert_fails(':set tabpanelopt=columns:-1', 'E474:')
endfunc
" mnv: shiftwidth=2 sts=2 expandtab
|