xref: /vim-8.2.3635/src/testdir/test_display.vim (revision 8fe1000e)
1" Test for displaying stuff
2if !has('gui_running') && has('unix')
3  set term=ansi
4endif
5
6source view_util.vim
7source check.vim
8source screendump.vim
9
10func Test_display_foldcolumn()
11  CheckFeature folding
12
13  new
14  vnew
15  vert resize 25
16  call assert_equal(25, winwidth(winnr()))
17  set isprint=@
18
19  1put='e more noise blah blah‚ more stuff here'
20
21  let expect = [
22        \ "e more noise blah blah<82",
23        \ "> more stuff here        "
24        \ ]
25
26  call cursor(2, 1)
27  norm! zt
28  let lines = ScreenLines([1,2], winwidth(0))
29  call assert_equal(expect, lines)
30  set fdc=2
31  let lines = ScreenLines([1,2], winwidth(0))
32  let expect = [
33        \ "  e more noise blah blah<",
34        \ "  82> more stuff here    "
35        \ ]
36  call assert_equal(expect, lines)
37
38  quit!
39  quit!
40endfunc
41
42func Test_display_foldtext_mbyte()
43  CheckFeature folding
44
45  call NewWindow(10, 40)
46  call append(0, range(1,20))
47  exe "set foldmethod=manual foldtext=foldtext() fillchars=fold:\u2500,vert:\u2502 fdc=2"
48  call cursor(2, 1)
49  norm! zf13G
50  let lines=ScreenLines([1,3], winwidth(0)+1)
51  let expect=[
52        \ "  1                                     \u2502",
53        \ "+ +-- 12 lines: 2". repeat("\u2500", 23). "\u2502",
54        \ "  14                                    \u2502",
55        \ ]
56  call assert_equal(expect, lines)
57
58  set fillchars=fold:-,vert:\|
59  let lines=ScreenLines([1,3], winwidth(0)+1)
60  let expect=[
61        \ "  1                                     |",
62        \ "+ +-- 12 lines: 2". repeat("-", 23). "|",
63        \ "  14                                    |",
64        \ ]
65  call assert_equal(expect, lines)
66
67  set foldtext& fillchars& foldmethod& fdc&
68  bw!
69endfunc
70
71" check that win_ins_lines() and win_del_lines() work when t_cs is empty.
72func Test_scroll_without_region()
73  CheckScreendump
74
75  let lines =<< trim END
76    call setline(1, range(1, 20))
77    set t_cs=
78    set laststatus=2
79  END
80  call writefile(lines, 'Xtestscroll')
81  let buf = RunVimInTerminal('-S Xtestscroll', #{rows: 10})
82
83  call VerifyScreenDump(buf, 'Test_scroll_no_region_1', {})
84
85  call term_sendkeys(buf, ":3delete\<cr>")
86  call VerifyScreenDump(buf, 'Test_scroll_no_region_2', {})
87
88  call term_sendkeys(buf, ":4put\<cr>")
89  call VerifyScreenDump(buf, 'Test_scroll_no_region_3', {})
90
91  call term_sendkeys(buf, ":undo\<cr>")
92  call term_sendkeys(buf, ":undo\<cr>")
93  call term_sendkeys(buf, ":set laststatus=0\<cr>")
94  call VerifyScreenDump(buf, 'Test_scroll_no_region_4', {})
95
96  call term_sendkeys(buf, ":3delete\<cr>")
97  call VerifyScreenDump(buf, 'Test_scroll_no_region_5', {})
98
99  call term_sendkeys(buf, ":4put\<cr>")
100  call VerifyScreenDump(buf, 'Test_scroll_no_region_6', {})
101
102  " clean up
103  call StopVimInTerminal(buf)
104  call delete('Xtestscroll')
105endfunc
106