Bram Moolenaar | 8e95636 | 2019-08-25 23:08:17 +0200 | [diff] [blame] | 1 | " Tests for popup windows for text properties |
| 2 | |
| 3 | source check.vim |
| 4 | CheckFeature textprop |
| 5 | |
| 6 | source screendump.vim |
| 7 | CheckScreendump |
| 8 | |
| 9 | func Test_textprop_popup() |
| 10 | let lines =<< trim END |
| 11 | call setline(1, range(1, 100)) |
| 12 | call setline(50, 'some text to work with') |
| 13 | 50 |
| 14 | normal zz |
| 15 | set scrolloff=0 |
Bram Moolenaar | a37cb55 | 2019-11-16 20:03:31 +0100 | [diff] [blame^] | 16 | call prop_type_add('popupMarker', #{highlight: 'DiffAdd', bufnr: bufnr('%')}) |
Bram Moolenaar | 8e95636 | 2019-08-25 23:08:17 +0200 | [diff] [blame] | 17 | call prop_add(50, 11, #{ |
| 18 | \ length: 7, |
| 19 | \ type: 'popupMarker', |
Bram Moolenaar | a37cb55 | 2019-11-16 20:03:31 +0100 | [diff] [blame^] | 20 | \ bufnr: bufnr('%'), |
Bram Moolenaar | 8e95636 | 2019-08-25 23:08:17 +0200 | [diff] [blame] | 21 | \ }) |
| 22 | let winid = popup_create('the text', #{ |
| 23 | \ pos: 'botleft', |
| 24 | \ textprop: 'popupMarker', |
| 25 | \ border: [], |
| 26 | \ padding: [0,1,0,1], |
| 27 | \ close: 'click', |
| 28 | \ }) |
| 29 | END |
| 30 | call writefile(lines, 'XtestTextpropPopup') |
| 31 | let buf = RunVimInTerminal('-S XtestTextpropPopup', #{rows: 10}) |
| 32 | call VerifyScreenDump(buf, 'Test_popup_textprop_01', {}) |
| 33 | |
| 34 | call term_sendkeys(buf, "zt") |
| 35 | call VerifyScreenDump(buf, 'Test_popup_textprop_02', {}) |
| 36 | |
| 37 | call term_sendkeys(buf, "zzIawe\<Esc>") |
| 38 | call VerifyScreenDump(buf, 'Test_popup_textprop_03', {}) |
| 39 | |
| 40 | call term_sendkeys(buf, "0dw") |
| 41 | call VerifyScreenDump(buf, 'Test_popup_textprop_04', {}) |
| 42 | |
| 43 | call term_sendkeys(buf, "Oinserted\<Esc>") |
| 44 | call VerifyScreenDump(buf, 'Test_popup_textprop_05', {}) |
| 45 | |
| 46 | call term_sendkeys(buf, "k2dd") |
| 47 | call VerifyScreenDump(buf, 'Test_popup_textprop_06', {}) |
| 48 | |
Bram Moolenaar | 1fb0831 | 2019-08-29 20:02:11 +0200 | [diff] [blame] | 49 | call term_sendkeys(buf, "4\<C-E>") |
| 50 | call VerifyScreenDump(buf, 'Test_popup_textprop_07', {}) |
| 51 | |
Bram Moolenaar | 8e95636 | 2019-08-25 23:08:17 +0200 | [diff] [blame] | 52 | " clean up |
| 53 | call StopVimInTerminal(buf) |
| 54 | call delete('XtestTextpropPopup') |
| 55 | endfunc |
| 56 | |
Bram Moolenaar | bc2d4c1 | 2019-08-28 22:18:30 +0200 | [diff] [blame] | 57 | func Test_textprop_popup_corners() |
| 58 | let lines =<< trim END |
| 59 | call setline(1, range(1, 100)) |
| 60 | call setline(50, 'now working with some longer text here') |
| 61 | 50 |
| 62 | normal zz |
| 63 | set scrolloff=0 |
| 64 | call prop_type_add('popupMarker', #{highlight: 'DiffAdd'}) |
| 65 | call prop_add(50, 23, #{ |
| 66 | \ length: 6, |
| 67 | \ type: 'popupMarker', |
| 68 | \ }) |
| 69 | let winid = popup_create('bottom left', #{ |
| 70 | \ pos: 'botleft', |
| 71 | \ textprop: 'popupMarker', |
Bram Moolenaar | a37cb55 | 2019-11-16 20:03:31 +0100 | [diff] [blame^] | 72 | \ textpropwin: win_getid(), |
Bram Moolenaar | bc2d4c1 | 2019-08-28 22:18:30 +0200 | [diff] [blame] | 73 | \ padding: [0,1,0,1], |
| 74 | \ }) |
| 75 | let winid = popup_create('bottom right', #{ |
| 76 | \ pos: 'botright', |
| 77 | \ textprop: 'popupMarker', |
| 78 | \ border: [], |
| 79 | \ padding: [0,1,0,1], |
| 80 | \ }) |
| 81 | let winid = popup_create('top left', #{ |
| 82 | \ pos: 'topleft', |
| 83 | \ textprop: 'popupMarker', |
| 84 | \ border: [], |
| 85 | \ padding: [0,1,0,1], |
| 86 | \ }) |
| 87 | let winid = popup_create('top right', #{ |
| 88 | \ pos: 'topright', |
| 89 | \ textprop: 'popupMarker', |
| 90 | \ padding: [0,1,0,1], |
| 91 | \ }) |
| 92 | END |
| 93 | call writefile(lines, 'XtestTextpropPopupCorners') |
| 94 | let buf = RunVimInTerminal('-S XtestTextpropPopupCorners', #{rows: 12}) |
| 95 | call VerifyScreenDump(buf, 'Test_popup_textprop_corn_1', {}) |
| 96 | |
| 97 | call term_sendkeys(buf, "0dw") |
| 98 | call VerifyScreenDump(buf, 'Test_popup_textprop_corn_2', {}) |
| 99 | |
| 100 | call term_sendkeys(buf, "46Goextra\<Esc>") |
| 101 | call VerifyScreenDump(buf, 'Test_popup_textprop_corn_3', {}) |
| 102 | |
| 103 | call term_sendkeys(buf, "u") |
Bram Moolenaar | 57441d6 | 2019-08-28 22:38:07 +0200 | [diff] [blame] | 104 | call term_sendkeys(buf, ":\<CR>") |
Bram Moolenaar | bc2d4c1 | 2019-08-28 22:18:30 +0200 | [diff] [blame] | 105 | call VerifyScreenDump(buf, 'Test_popup_textprop_corn_4', {}) |
| 106 | |
Bram Moolenaar | 1fb0831 | 2019-08-29 20:02:11 +0200 | [diff] [blame] | 107 | call term_sendkeys(buf, ":vsplit foo\<CR>") |
| 108 | call VerifyScreenDump(buf, 'Test_popup_textprop_corn_5', {}) |
| 109 | |
| 110 | call term_sendkeys(buf, ":only!\<CR>") |
| 111 | call VerifyScreenDump(buf, 'Test_popup_textprop_corn_6', {}) |
| 112 | |
Bram Moolenaar | bc2d4c1 | 2019-08-28 22:18:30 +0200 | [diff] [blame] | 113 | " clean up |
| 114 | call StopVimInTerminal(buf) |
| 115 | call delete('XtestTextpropPopupCorners') |
| 116 | endfunc |
| 117 | |
Bram Moolenaar | 1fb0831 | 2019-08-29 20:02:11 +0200 | [diff] [blame] | 118 | func Test_textprop_popup_offsets() |
| 119 | let lines =<< trim END |
| 120 | call setline(1, range(1, 100)) |
| 121 | call setline(50, 'now working with some longer text here') |
| 122 | 50 |
| 123 | normal zz |
| 124 | set scrolloff=0 |
| 125 | call prop_type_add('popupMarker', #{highlight: 'DiffAdd'}) |
| 126 | call prop_add(50, 23, #{ |
| 127 | \ length: 6, |
| 128 | \ type: 'popupMarker', |
| 129 | \ }) |
| 130 | let winid = popup_create('bottom left', #{ |
| 131 | \ pos: 'botleft', |
| 132 | \ line: -1, |
| 133 | \ col: 2, |
| 134 | \ textprop: 'popupMarker', |
| 135 | \ padding: [0,1,0,1], |
| 136 | \ }) |
| 137 | let winid = popup_create('bottom right', #{ |
| 138 | \ pos: 'botright', |
| 139 | \ line: -1, |
| 140 | \ col: -2, |
| 141 | \ textprop: 'popupMarker', |
| 142 | \ border: [], |
| 143 | \ padding: [0,1,0,1], |
| 144 | \ }) |
| 145 | let winid = popup_create('top left', #{ |
| 146 | \ pos: 'topleft', |
| 147 | \ line: 1, |
| 148 | \ col: 2, |
| 149 | \ textprop: 'popupMarker', |
| 150 | \ border: [], |
| 151 | \ padding: [0,1,0,1], |
| 152 | \ }) |
| 153 | let winid = popup_create('top right', #{ |
| 154 | \ pos: 'topright', |
| 155 | \ line: 1, |
| 156 | \ col: -2, |
| 157 | \ textprop: 'popupMarker', |
| 158 | \ padding: [0,1,0,1], |
| 159 | \ }) |
| 160 | END |
| 161 | call writefile(lines, 'XtestTextpropPopupOffset') |
| 162 | let buf = RunVimInTerminal('-S XtestTextpropPopupOffset', #{rows: 12}) |
| 163 | call VerifyScreenDump(buf, 'Test_popup_textprop_off_1', {}) |
| 164 | |
| 165 | " test that removing the text property closes the popups |
| 166 | call term_sendkeys(buf, ":call prop_clear(50)\<CR>") |
| 167 | call VerifyScreenDump(buf, 'Test_popup_textprop_off_2', {}) |
| 168 | |
| 169 | " clean up |
| 170 | call StopVimInTerminal(buf) |
| 171 | call delete('XtestTextpropPopupOffset') |
| 172 | endfunc |
| 173 | |
Bram Moolenaar | 8e95636 | 2019-08-25 23:08:17 +0200 | [diff] [blame] | 174 | |
| 175 | " vim: shiftwidth=2 sts=2 |