Bram Moolenaar | 6270660 | 2016-12-09 19:28:48 +0100 | [diff] [blame] | 1 | " Test for displaying stuff |
| 2 | if !has('gui_running') && has('unix') |
| 3 | set term=ansi |
| 4 | endif |
| 5 | |
Bram Moolenaar | c6cd840 | 2017-03-29 14:40:47 +0200 | [diff] [blame] | 6 | source view_util.vim |
Bram Moolenaar | 3c8ee62 | 2019-08-03 22:55:50 +0200 | [diff] [blame] | 7 | source check.vim |
| 8 | source screendump.vim |
Bram Moolenaar | 6270660 | 2016-12-09 19:28:48 +0100 | [diff] [blame] | 9 | |
Bram Moolenaar | 1e11536 | 2019-01-09 23:01:02 +0100 | [diff] [blame] | 10 | func Test_display_foldcolumn() |
Bram Moolenaar | 3c8ee62 | 2019-08-03 22:55:50 +0200 | [diff] [blame] | 11 | CheckFeature folding |
| 12 | |
Bram Moolenaar | 6270660 | 2016-12-09 19:28:48 +0100 | [diff] [blame] | 13 | new |
| 14 | vnew |
| 15 | vert resize 25 |
Bram Moolenaar | 7089237 | 2016-12-09 19:51:49 +0100 | [diff] [blame] | 16 | call assert_equal(25, winwidth(winnr())) |
| 17 | set isprint=@ |
Bram Moolenaar | 6270660 | 2016-12-09 19:28:48 +0100 | [diff] [blame] | 18 | |
| 19 | 1put='e more noise blah blah‚ more stuff here' |
| 20 | |
Bram Moolenaar | c6cd840 | 2017-03-29 14:40:47 +0200 | [diff] [blame] | 21 | let expect = [ |
| 22 | \ "e more noise blah blah<82", |
| 23 | \ "> more stuff here " |
| 24 | \ ] |
Bram Moolenaar | 6270660 | 2016-12-09 19:28:48 +0100 | [diff] [blame] | 25 | |
| 26 | call cursor(2, 1) |
| 27 | norm! zt |
Bram Moolenaar | 3c8ee62 | 2019-08-03 22:55:50 +0200 | [diff] [blame] | 28 | let lines = ScreenLines([1,2], winwidth(0)) |
Bram Moolenaar | c6cd840 | 2017-03-29 14:40:47 +0200 | [diff] [blame] | 29 | call assert_equal(expect, lines) |
Bram Moolenaar | 6270660 | 2016-12-09 19:28:48 +0100 | [diff] [blame] | 30 | set fdc=2 |
Bram Moolenaar | 3c8ee62 | 2019-08-03 22:55:50 +0200 | [diff] [blame] | 31 | let lines = ScreenLines([1,2], winwidth(0)) |
Bram Moolenaar | c6cd840 | 2017-03-29 14:40:47 +0200 | [diff] [blame] | 32 | let expect = [ |
| 33 | \ " e more noise blah blah<", |
| 34 | \ " 82> more stuff here " |
| 35 | \ ] |
| 36 | call assert_equal(expect, lines) |
Bram Moolenaar | 6270660 | 2016-12-09 19:28:48 +0100 | [diff] [blame] | 37 | |
| 38 | quit! |
| 39 | quit! |
Bram Moolenaar | c6cd840 | 2017-03-29 14:40:47 +0200 | [diff] [blame] | 40 | endfunc |
| 41 | |
Bram Moolenaar | 1e11536 | 2019-01-09 23:01:02 +0100 | [diff] [blame] | 42 | func Test_display_foldtext_mbyte() |
Bram Moolenaar | 3c8ee62 | 2019-08-03 22:55:50 +0200 | [diff] [blame] | 43 | CheckFeature folding |
| 44 | |
Bram Moolenaar | c6cd840 | 2017-03-29 14:40:47 +0200 | [diff] [blame] | 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) |
Bram Moolenaar | 8da1e6c | 2017-03-29 20:38:59 +0200 | [diff] [blame] | 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 | |
Bram Moolenaar | c6cd840 | 2017-03-29 14:40:47 +0200 | [diff] [blame] | 67 | set foldtext& fillchars& foldmethod& fdc& |
| 68 | bw! |
| 69 | endfunc |
Bram Moolenaar | 3c8ee62 | 2019-08-03 22:55:50 +0200 | [diff] [blame] | 70 | |
| 71 | " check that win_ins_lines() and win_del_lines() work when t_cs is empty. |
| 72 | func 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 | |
Bram Moolenaar | 7cc5351 | 2019-08-03 23:30:21 +0200 | [diff] [blame] | 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 | |
Bram Moolenaar | 3c8ee62 | 2019-08-03 22:55:50 +0200 | [diff] [blame] | 102 | " clean up |
| 103 | call StopVimInTerminal(buf) |
| 104 | call delete('Xtestscroll') |
| 105 | endfunc |
Bram Moolenaar | bffba7f | 2019-09-20 17:00:17 +0200 | [diff] [blame] | 106 | |
| 107 | func Test_display_listchars_precedes() |
| 108 | call NewWindow(10, 10) |
| 109 | " Need a physical line that wraps over the complete |
| 110 | " window size |
| 111 | call append(0, repeat('aaa aaa aa ', 10)) |
| 112 | call append(1, repeat(['bbb bbb bbb bbb'], 2)) |
| 113 | " remove blank trailing line |
| 114 | $d |
| 115 | set list nowrap |
| 116 | call cursor(1, 1) |
| 117 | " move to end of line and scroll 2 characters back |
| 118 | norm! $2zh |
| 119 | let lines=ScreenLines([1,4], winwidth(0)+1) |
| 120 | let expect = [ |
| 121 | \ " aaa aa $ |", |
| 122 | \ "$ |", |
| 123 | \ "$ |", |
| 124 | \ "~ |", |
| 125 | \ ] |
| 126 | call assert_equal(expect, lines) |
| 127 | set list listchars+=precedes:< nowrap |
| 128 | call cursor(1, 1) |
| 129 | " move to end of line and scroll 2 characters back |
| 130 | norm! $2zh |
| 131 | let lines = ScreenLines([1,4], winwidth(0)+1) |
| 132 | let expect = [ |
| 133 | \ "<aaa aa $ |", |
| 134 | \ "< |", |
| 135 | \ "< |", |
| 136 | \ "~ |", |
| 137 | \ ] |
| 138 | call assert_equal(expect, lines) |
| 139 | set wrap |
| 140 | call cursor(1, 1) |
| 141 | " the complete line should be displayed in the window |
| 142 | norm! $ |
| 143 | |
| 144 | let lines = ScreenLines([1,10], winwidth(0)+1) |
| 145 | let expect = [ |
| 146 | \ "<aaa aaa a|", |
| 147 | \ "a aaa aaa |", |
| 148 | \ "aa aaa aaa|", |
| 149 | \ " aa aaa aa|", |
| 150 | \ "a aa aaa a|", |
| 151 | \ "aa aa aaa |", |
| 152 | \ "aaa aa aaa|", |
| 153 | \ " aaa aa aa|", |
| 154 | \ "a aaa aa a|", |
| 155 | \ "aa aaa aa |", |
| 156 | \ ] |
| 157 | call assert_equal(expect, lines) |
| 158 | set list& listchars& wrap& |
| 159 | bw! |
| 160 | endfunc |