12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388 |
- local helpers = require('test.functional.helpers')(after_each)
- local Screen = require('test.functional.ui.screen')
- local clear, feed, meths = helpers.clear, helpers.feed, helpers.meths
- local insert, feed_command = helpers.insert, helpers.feed_command
- local eq, funcs = helpers.eq, helpers.funcs
- local command = helpers.command
- describe('ui/mouse/input', function()
- local screen
- before_each(function()
- clear()
- meths.set_option('mouse', 'a')
- meths.set_option('list', true)
- -- NB: this is weird, but mostly irrelevant to the test
- -- So I didn't bother to change it
- command('set listchars=eol:$')
- command('setl listchars=nbsp:x')
- screen = Screen.new(25, 5)
- screen:attach()
- screen:set_default_attr_ids({
- [0] = {bold=true, foreground=Screen.colors.Blue},
- [1] = {background = Screen.colors.LightGrey},
- [2] = {bold = true},
- [3] = {
- foreground = Screen.colors.Blue,
- background = Screen.colors.LightGrey,
- bold = true,
- },
- [4] = {reverse = true},
- [5] = {bold = true, reverse = true},
- [6] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
- [7] = {bold = true, foreground = Screen.colors.SeaGreen4},
- })
- command("set display-=msgsep")
- feed('itesting<cr>mouse<cr>support and selection<esc>')
- screen:expect([[
- testing |
- mouse |
- support and selectio^n |
- {0:~ }|
- |
- ]])
- end)
- it('single left click moves cursor', function()
- feed('<LeftMouse><2,1>')
- screen:expect{grid=[[
- testing |
- mo^use |
- support and selection |
- {0:~ }|
- |
- ]], mouse_enabled=true}
- feed('<LeftMouse><0,0>')
- screen:expect([[
- ^testing |
- mouse |
- support and selection |
- {0:~ }|
- |
- ]])
- end)
- it("in external ui works with unset 'mouse'", function()
- meths.set_option('mouse', '')
- feed('<LeftMouse><2,1>')
- screen:expect{grid=[[
- testing |
- mo^use |
- support and selection |
- {0:~ }|
- |
- ]], mouse_enabled=false}
- feed('<LeftMouse><0,0>')
- screen:expect([[
- ^testing |
- mouse |
- support and selection |
- {0:~ }|
- |
- ]])
- end)
- it('double left click enters visual mode', function()
- feed('<LeftMouse><0,0>')
- feed('<LeftRelease><0,0>')
- feed('<LeftMouse><0,0>')
- feed('<LeftRelease><0,0>')
- screen:expect([[
- {1:testin}^g |
- mouse |
- support and selection |
- {0:~ }|
- {2:-- VISUAL --} |
- ]])
- end)
- it('triple left click enters visual line mode', function()
- feed('<LeftMouse><0,0>')
- feed('<LeftRelease><0,0>')
- feed('<LeftMouse><0,0>')
- feed('<LeftRelease><0,0>')
- feed('<LeftMouse><0,0>')
- feed('<LeftRelease><0,0>')
- screen:expect([[
- ^t{1:esting} |
- mouse |
- support and selection |
- {0:~ }|
- {2:-- VISUAL LINE --} |
- ]])
- end)
- it('quadruple left click enters visual block mode', function()
- feed('<LeftMouse><0,0>')
- feed('<LeftRelease><0,0>')
- feed('<LeftMouse><0,0>')
- feed('<LeftRelease><0,0>')
- feed('<LeftMouse><0,0>')
- feed('<LeftRelease><0,0>')
- feed('<LeftMouse><0,0>')
- feed('<LeftRelease><0,0>')
- screen:expect([[
- ^testing |
- mouse |
- support and selection |
- {0:~ }|
- {2:-- VISUAL BLOCK --} |
- ]])
- end)
- describe('tab drag', function()
- before_each(function()
- screen:set_default_attr_ids( {
- [0] = {bold=true, foreground=Screen.colors.Blue},
- tab = { background=Screen.colors.LightGrey, underline=true },
- sel = { bold=true },
- fill = { reverse=true }
- })
- end)
- it('in tabline on filler space moves tab to the end', function()
- feed_command('%delete')
- insert('this is foo')
- feed_command('silent file foo | tabnew | file bar')
- insert('this is bar')
- screen:expect([[
- {tab: + foo }{sel: + bar }{fill: }{tab:X}|
- this is ba^r{0:$} |
- {0:~ }|
- {0:~ }|
- |
- ]])
- feed('<LeftMouse><4,0>')
- screen:expect([[
- {sel: + foo }{tab: + bar }{fill: }{tab:X}|
- this is fo^o |
- {0:~ }|
- {0:~ }|
- |
- ]])
- feed('<LeftDrag><14,0>')
- screen:expect([[
- {tab: + bar }{sel: + foo }{fill: }{tab:X}|
- this is fo^o |
- {0:~ }|
- {0:~ }|
- |
- ]])
- end)
- it('in tabline to the left moves tab left', function()
- feed_command('%delete')
- insert('this is foo')
- feed_command('silent file foo | tabnew | file bar')
- insert('this is bar')
- screen:expect([[
- {tab: + foo }{sel: + bar }{fill: }{tab:X}|
- this is ba^r{0:$} |
- {0:~ }|
- {0:~ }|
- |
- ]])
- feed('<LeftMouse><11,0>')
- screen:expect{grid=[[
- {tab: + foo }{sel: + bar }{fill: }{tab:X}|
- this is ba^r{0:$} |
- {0:~ }|
- {0:~ }|
- |
- ]], unchanged=true}
- feed('<LeftDrag><6,0>')
- screen:expect([[
- {sel: + bar }{tab: + foo }{fill: }{tab:X}|
- this is ba^r{0:$} |
- {0:~ }|
- {0:~ }|
- |
- ]])
- end)
- it('in tabline to the right moves tab right', function()
- feed_command('%delete')
- insert('this is foo')
- feed_command('silent file foo | tabnew | file bar')
- insert('this is bar')
- screen:expect([[
- {tab: + foo }{sel: + bar }{fill: }{tab:X}|
- this is ba^r{0:$} |
- {0:~ }|
- {0:~ }|
- |
- ]])
- feed('<LeftMouse><4,0>')
- screen:expect([[
- {sel: + foo }{tab: + bar }{fill: }{tab:X}|
- this is fo^o |
- {0:~ }|
- {0:~ }|
- |
- ]])
- feed('<LeftDrag><7,0>')
- screen:expect([[
- {tab: + bar }{sel: + foo }{fill: }{tab:X}|
- this is fo^o |
- {0:~ }|
- {0:~ }|
- |
- ]])
- end)
- it('out of tabline under filler space moves tab to the end', function()
- feed_command('%delete')
- insert('this is foo')
- feed_command('silent file foo | tabnew | file bar')
- insert('this is bar')
- screen:expect([[
- {tab: + foo }{sel: + bar }{fill: }{tab:X}|
- this is ba^r{0:$} |
- {0:~ }|
- {0:~ }|
- |
- ]])
- feed('<LeftMouse><4,0>')
- screen:expect([[
- {sel: + foo }{tab: + bar }{fill: }{tab:X}|
- this is fo^o |
- {0:~ }|
- {0:~ }|
- |
- ]])
- feed('<LeftDrag><4,1>')
- screen:expect{grid=[[
- {sel: + foo }{tab: + bar }{fill: }{tab:X}|
- this is fo^o |
- {0:~ }|
- {0:~ }|
- |
- ]], unchanged=true}
- feed('<LeftDrag><14,1>')
- screen:expect([[
- {tab: + bar }{sel: + foo }{fill: }{tab:X}|
- this is fo^o |
- {0:~ }|
- {0:~ }|
- |
- ]])
- end)
- it('out of tabline to the left moves tab left', function()
- feed_command('%delete')
- insert('this is foo')
- feed_command('silent file foo | tabnew | file bar')
- insert('this is bar')
- screen:expect([[
- {tab: + foo }{sel: + bar }{fill: }{tab:X}|
- this is ba^r{0:$} |
- {0:~ }|
- {0:~ }|
- |
- ]])
- feed('<LeftMouse><11,0>')
- screen:expect{grid=[[
- {tab: + foo }{sel: + bar }{fill: }{tab:X}|
- this is ba^r{0:$} |
- {0:~ }|
- {0:~ }|
- |
- ]], unchanged=true}
- feed('<LeftDrag><11,1>')
- screen:expect{grid=[[
- {tab: + foo }{sel: + bar }{fill: }{tab:X}|
- this is ba^r{0:$} |
- {0:~ }|
- {0:~ }|
- |
- ]], unchanged=true}
- feed('<LeftDrag><6,1>')
- screen:expect([[
- {sel: + bar }{tab: + foo }{fill: }{tab:X}|
- this is ba^r{0:$} |
- {0:~ }|
- {0:~ }|
- |
- ]])
- end)
- it('out of tabline to the right moves tab right', function()
- feed_command('%delete')
- insert('this is foo')
- feed_command('silent file foo | tabnew | file bar')
- insert('this is bar')
- screen:expect([[
- {tab: + foo }{sel: + bar }{fill: }{tab:X}|
- this is ba^r{0:$} |
- {0:~ }|
- {0:~ }|
- |
- ]])
- feed('<LeftMouse><4,0>')
- screen:expect([[
- {sel: + foo }{tab: + bar }{fill: }{tab:X}|
- this is fo^o |
- {0:~ }|
- {0:~ }|
- |
- ]])
- feed('<LeftDrag><4,1>')
- screen:expect{grid=[[
- {sel: + foo }{tab: + bar }{fill: }{tab:X}|
- this is fo^o |
- {0:~ }|
- {0:~ }|
- |
- ]], unchanged=true}
- feed('<LeftDrag><7,1>')
- screen:expect([[
- {tab: + bar }{sel: + foo }{fill: }{tab:X}|
- this is fo^o |
- {0:~ }|
- {0:~ }|
- |
- ]])
- end)
- end)
- describe('tabline', function()
- before_each(function()
- screen:set_default_attr_ids( {
- [0] = {bold=true, foreground=Screen.colors.Blue},
- tab = { background=Screen.colors.LightGrey, underline=true },
- sel = { bold=true },
- fill = { reverse=true }
- })
- end)
- it('left click in default tabline (position 4) switches to tab', function()
- feed_command('%delete')
- insert('this is foo')
- feed_command('silent file foo | tabnew | file bar')
- insert('this is bar')
- screen:expect([[
- {tab: + foo }{sel: + bar }{fill: }{tab:X}|
- this is ba^r{0:$} |
- {0:~ }|
- {0:~ }|
- |
- ]])
- feed('<LeftMouse><4,0>')
- screen:expect([[
- {sel: + foo }{tab: + bar }{fill: }{tab:X}|
- this is fo^o |
- {0:~ }|
- {0:~ }|
- |
- ]])
- end)
- it('left click in default tabline (position 24) closes tab', function()
- meths.set_option('hidden', true)
- feed_command('%delete')
- insert('this is foo')
- feed_command('silent file foo | tabnew | file bar')
- insert('this is bar')
- screen:expect([[
- {tab: + foo }{sel: + bar }{fill: }{tab:X}|
- this is ba^r{0:$} |
- {0:~ }|
- {0:~ }|
- |
- ]])
- feed('<LeftMouse><24,0>')
- screen:expect([[
- this is fo^o |
- {0:~ }|
- {0:~ }|
- {0:~ }|
- |
- ]])
- end)
- it('double click in default tabline (position 4) opens new tab', function()
- meths.set_option('hidden', true)
- feed_command('%delete')
- insert('this is foo')
- feed_command('silent file foo | tabnew | file bar')
- insert('this is bar')
- screen:expect([[
- {tab: + foo }{sel: + bar }{fill: }{tab:X}|
- this is ba^r{0:$} |
- {0:~ }|
- {0:~ }|
- |
- ]])
- feed('<2-LeftMouse><4,0>')
- screen:expect([[
- {sel: Name] }{tab: + foo + bar }{fill: }{tab:X}|
- {0:^$} |
- {0:~ }|
- {0:~ }|
- |
- ]])
- end)
- describe('%@ label', function()
- before_each(function()
- feed_command([[
- function Test(...)
- let g:reply = a:000
- return copy(a:000) " Check for memory leaks: return should be freed
- endfunction
- ]])
- feed_command([[
- function Test2(...)
- return call('Test', a:000 + [2])
- endfunction
- ]])
- meths.set_option('tabline', '%@Test@test%X-%5@Test2@test2')
- meths.set_option('showtabline', 2)
- screen:expect([[
- {fill:test-test2 }|
- testing |
- mouse |
- support and selectio^n |
- |
- ]])
- meths.set_var('reply', {})
- end)
- local check_reply = function(expected)
- eq(expected, meths.get_var('reply'))
- meths.set_var('reply', {})
- end
- local test_click = function(name, click_str, click_num, mouse_button,
- modifiers)
- local function doit(do_click)
- eq(1, funcs.has('tablineat'))
- do_click(0,3)
- check_reply({0, click_num, mouse_button, modifiers})
- do_click(0,4)
- check_reply({})
- do_click(0,6)
- check_reply({5, click_num, mouse_button, modifiers, 2})
- do_click(0,13)
- check_reply({5, click_num, mouse_button, modifiers, 2})
- end
- it(name .. ' works (pseudokey)', function()
- doit(function (row,col)
- feed(click_str .. '<' .. col .. ',' .. row .. '>')
- end)
- end)
- it(name .. ' works (nvim_input_mouse)', function()
- doit(function (row,col)
- local buttons = {l='left',m='middle',r='right'}
- local modstr = (click_num > 1) and tostring(click_num) or ''
- for char in string.gmatch(modifiers, '%w') do
- modstr = modstr .. char .. '-' -- - not needed but should be accepted
- end
- meths.input_mouse(buttons[mouse_button], 'press', modstr, 0, row, col)
- end)
- end)
- end
- test_click('single left click', '<LeftMouse>', 1, 'l', ' ')
- test_click('shifted single left click', '<S-LeftMouse>', 1, 'l', 's ')
- test_click('shifted single left click with alt modifier',
- '<S-A-LeftMouse>', 1, 'l', 's a ')
- test_click('shifted single left click with alt and ctrl modifiers',
- '<S-C-A-LeftMouse>', 1, 'l', 'sca ')
- -- <C-RightMouse> does not work
- test_click('shifted single right click with alt modifier',
- '<S-A-RightMouse>', 1, 'r', 's a ')
- -- Modifiers do not work with MiddleMouse
- test_click('shifted single middle click with alt and ctrl modifiers',
- '<MiddleMouse>', 1, 'm', ' ')
- -- Modifiers do not work with N-*Mouse
- test_click('double left click', '<2-LeftMouse>', 2, 'l', ' ')
- test_click('triple left click', '<3-LeftMouse>', 3, 'l', ' ')
- test_click('quadruple left click', '<4-LeftMouse>', 4, 'l', ' ')
- test_click('double right click', '<2-RightMouse>', 2, 'r', ' ')
- test_click('triple right click', '<3-RightMouse>', 3, 'r', ' ')
- test_click('quadruple right click', '<4-RightMouse>', 4, 'r', ' ')
- test_click('double middle click', '<2-MiddleMouse>', 2, 'm', ' ')
- test_click('triple middle click', '<3-MiddleMouse>', 3, 'm', ' ')
- test_click('quadruple middle click', '<4-MiddleMouse>', 4, 'm', ' ')
- end)
- end)
- it('left drag changes visual selection', function()
- -- drag events must be preceded by a click
- feed('<LeftMouse><2,1>')
- screen:expect([[
- testing |
- mo^use |
- support and selection |
- {0:~ }|
- |
- ]])
- feed('<LeftDrag><4,1>')
- screen:expect([[
- testing |
- mo{1:us}^e |
- support and selection |
- {0:~ }|
- {2:-- VISUAL --} |
- ]])
- feed('<LeftDrag><2,2>')
- screen:expect([[
- testing |
- mo{1:use} |
- {1:su}^pport and selection |
- {0:~ }|
- {2:-- VISUAL --} |
- ]])
- feed('<LeftDrag><0,0>')
- screen:expect([[
- ^t{1:esting} |
- {1:mou}se |
- support and selection |
- {0:~ }|
- {2:-- VISUAL --} |
- ]])
- end)
- it('left drag changes visual selection after tab click', function()
- screen:set_default_attr_ids({
- [0] = {bold=true, foreground=Screen.colors.Blue},
- tab = { background=Screen.colors.LightGrey, underline=true },
- sel = { bold=true },
- fill = { reverse=true },
- vis = { background=Screen.colors.LightGrey }
- })
- feed_command('silent file foo | tabnew | file bar')
- insert('this is bar')
- feed_command('tabprevious') -- go to first tab
- screen:expect([[
- {sel: + foo }{tab: + bar }{fill: }{tab:X}|
- testing |
- mouse |
- support and selectio^n |
- :tabprevious |
- ]])
- feed('<LeftMouse><10,0><LeftRelease>') -- go to second tab
- helpers.poke_eventloop()
- feed('<LeftMouse><0,1>')
- screen:expect([[
- {tab: + foo }{sel: + bar }{fill: }{tab:X}|
- ^this is bar{0:$} |
- {0:~ }|
- {0:~ }|
- :tabprevious |
- ]])
- feed('<LeftDrag><4,1>')
- screen:expect([[
- {tab: + foo }{sel: + bar }{fill: }{tab:X}|
- {vis:this}^ is bar{0:$} |
- {0:~ }|
- {0:~ }|
- {sel:-- VISUAL --} |
- ]])
- end)
- it('two clicks will select the word and enter VISUAL', function()
- feed('<LeftMouse><2,2><LeftMouse><2,2>')
- screen:expect([[
- testing |
- mouse |
- {1:suppor}^t and selection |
- {0:~ }|
- {2:-- VISUAL --} |
- ]])
- end)
- it('three clicks will select the line and enter VISUAL LINE', function()
- feed('<LeftMouse><2,2><LeftMouse><2,2><LeftMouse><2,2>')
- screen:expect([[
- testing |
- mouse |
- {1:su}^p{1:port and selection} |
- {0:~ }|
- {2:-- VISUAL LINE --} |
- ]])
- end)
- it('four clicks will enter VISUAL BLOCK', function()
- feed('<LeftMouse><2,2><LeftMouse><2,2><LeftMouse><2,2><LeftMouse><2,2>')
- screen:expect([[
- testing |
- mouse |
- su^pport and selection |
- {0:~ }|
- {2:-- VISUAL BLOCK --} |
- ]])
- end)
- it('right click extends visual selection to the clicked location', function()
- feed('<LeftMouse><0,0>')
- screen:expect([[
- ^testing |
- mouse |
- support and selection |
- {0:~ }|
- |
- ]])
- feed('<RightMouse><2,2>')
- screen:expect([[
- {1:testing} |
- {1:mouse} |
- {1:su}^pport and selection |
- {0:~ }|
- {2:-- VISUAL --} |
- ]])
- end)
- it('ctrl + left click will search for a tag', function()
- meths.set_option('tags', './non-existent-tags-file')
- feed('<C-LeftMouse><0,0>')
- screen:expect([[
- {6:E433: No tags file} |
- {6:E426: tag not found: test}|
- {6:ing} |
- {7:Press ENTER or type comma}|
- {7:nd to continue}^ |
- ]])
- feed('<cr>')
- end)
- local function wheel(use_api)
- feed('ggdG')
- insert([[
- Inserting
- text
- with
- many
- lines
- to
- test
- mouse scrolling
- ]])
- screen:try_resize(53, 14)
- feed('k')
- feed_command('sp', 'vsp')
- screen:expect([[
- lines {4:│}lines |
- to {4:│}to |
- test {4:│}test |
- ^mouse scrolling {4:│}mouse scrolling |
- {4:│} |
- {0:~ }{4:│}{0:~ }|
- {5:[No Name] [+] }{4:[No Name] [+] }|
- to |
- test |
- mouse scrolling |
- |
- {0:~ }|
- {4:[No Name] [+] }|
- :vsp |
- ]])
- if use_api then
- meths.input_mouse('wheel', 'down', '', 0, 0, 0)
- else
- feed('<ScrollWheelDown><0,0>')
- end
- screen:expect([[
- ^mouse scrolling {4:│}lines |
- {4:│}to |
- {0:~ }{4:│}test |
- {0:~ }{4:│}mouse scrolling |
- {0:~ }{4:│} |
- {0:~ }{4:│}{0:~ }|
- {5:[No Name] [+] }{4:[No Name] [+] }|
- to |
- test |
- mouse scrolling |
- |
- {0:~ }|
- {4:[No Name] [+] }|
- :vsp |
- ]])
- if use_api then
- meths.input_mouse('wheel', 'up', '', 0, 0, 27)
- else
- feed('<ScrollWheelUp><27,0>')
- end
- screen:expect([[
- ^mouse scrolling {4:│}text |
- {4:│}with |
- {0:~ }{4:│}many |
- {0:~ }{4:│}lines |
- {0:~ }{4:│}to |
- {0:~ }{4:│}test |
- {5:[No Name] [+] }{4:[No Name] [+] }|
- to |
- test |
- mouse scrolling |
- |
- {0:~ }|
- {4:[No Name] [+] }|
- :vsp |
- ]])
- if use_api then
- meths.input_mouse('wheel', 'up', '', 0, 7, 27)
- meths.input_mouse('wheel', 'up', '', 0, 7, 27)
- else
- feed('<ScrollWheelUp><27,7><ScrollWheelUp>')
- end
- screen:expect([[
- ^mouse scrolling {4:│}text |
- {4:│}with |
- {0:~ }{4:│}many |
- {0:~ }{4:│}lines |
- {0:~ }{4:│}to |
- {0:~ }{4:│}test |
- {5:[No Name] [+] }{4:[No Name] [+] }|
- Inserting |
- text |
- with |
- many |
- lines |
- {4:[No Name] [+] }|
- :vsp |
- ]])
- end
- it('mouse wheel will target the hovered window (pseudokey)', function()
- wheel(false)
- end)
- it('mouse wheel will target the hovered window (nvim_input_mouse)', function()
- wheel(true)
- end)
- it('horizontal scrolling (pseudokey)', function()
- command('set sidescroll=0')
- feed("<esc>:set nowrap<cr>")
- feed("a <esc>20Ab<esc>")
- screen:expect([[
- |
- |
- bbbbbbbbbbbbbbb^b |
- {0:~ }|
- |
- ]])
- feed("<ScrollWheelLeft><0,0>")
- screen:expect([[
- |
- |
- n bbbbbbbbbbbbbbbbbbb^b |
- {0:~ }|
- |
- ]])
- feed("^<ScrollWheelRight><0,0>")
- screen:expect([[
- g |
- |
- ^t and selection bbbbbbbbb|
- {0:~ }|
- |
- ]])
- end)
- it('horizontal scrolling (nvim_input_mouse)', function()
- command('set sidescroll=0')
- feed("<esc>:set nowrap<cr>")
- feed("a <esc>20Ab<esc>")
- screen:expect([[
- |
- |
- bbbbbbbbbbbbbbb^b |
- {0:~ }|
- |
- ]])
- meths.input_mouse('wheel', 'left', '', 0, 0, 27)
- screen:expect([[
- |
- |
- n bbbbbbbbbbbbbbbbbbb^b |
- {0:~ }|
- |
- ]])
- feed("^")
- meths.input_mouse('wheel', 'right', '', 0, 0, 0)
- screen:expect([[
- g |
- |
- ^t and selection bbbbbbbbb|
- {0:~ }|
- |
- ]])
- end)
- describe('on concealed text', function()
- -- Helpful for reading the test expectations:
- -- :match Error /\^/
- before_each(function()
- screen:try_resize(25, 7)
- screen:set_default_attr_ids({
- [0] = {bold=true, foreground=Screen.colors.Blue},
- c = { foreground = Screen.colors.LightGrey, background = Screen.colors.DarkGray },
- sm = {bold = true},
- })
- feed('ggdG')
- feed_command('set concealcursor=ni')
- feed_command('set nowrap')
- feed_command('set shiftwidth=2 tabstop=4 list')
- feed_command('setl listchars=tab:>-')
- feed_command('syntax match NonText "\\*" conceal')
- feed_command('syntax match NonText "cats" conceal cchar=X')
- feed_command('syntax match NonText "x" conceal cchar=>')
- -- First column is there to retain the tabs.
- insert([[
- |Section *t1*
- | *t2* *t3* *t4*
- |x 私は猫が大好き *cats* ✨🐈✨
- ]])
- feed('gg<c-v>Gxgg')
- end)
- it('(level 1) click on non-wrapped lines', function()
- feed_command('let &conceallevel=1', 'echo')
- feed('<esc><LeftMouse><0,0>')
- screen:expect([[
- ^Section{0:>>--->--->---}{c: }t1{c: } |
- {0:>--->--->---} {c: }t2{c: } {c: }t3{c: } {c: }|
- {c:>} 私は猫が大好き{0:>---}{c: X } {0:>}|
- |
- {0:~ }|
- {0:~ }|
- |
- ]])
- feed('<esc><LeftMouse><1,0>')
- screen:expect([[
- S^ection{0:>>--->--->---}{c: }t1{c: } |
- {0:>--->--->---} {c: }t2{c: } {c: }t3{c: } {c: }|
- {c:>} 私は猫が大好き{0:>---}{c: X } {0:>}|
- |
- {0:~ }|
- {0:~ }|
- |
- ]])
- feed('<esc><LeftMouse><21,0>')
- screen:expect([[
- Section{0:>>--->--->---}{c: }^t1{c: } |
- {0:>--->--->---} {c: }t2{c: } {c: }t3{c: } {c: }|
- {c:>} 私は猫が大好き{0:>---}{c: X } {0:>}|
- |
- {0:~ }|
- {0:~ }|
- |
- ]])
- feed('<esc><LeftMouse><21,1>')
- screen:expect([[
- Section{0:>>--->--->---}{c: }t1{c: } |
- {0:>--->--->---} {c: }t2{c: } {c: }t^3{c: } {c: }|
- {c:>} 私は猫が大好き{0:>---}{c: X } {0:>}|
- |
- {0:~ }|
- {0:~ }|
- |
- ]])
- feed('<esc><LeftMouse><0,2>')
- screen:expect([[
- Section{0:>>--->--->---}{c: }t1{c: } |
- {0:>--->--->---} {c: }t2{c: } {c: }t3{c: } {c: }|
- {c:^>} 私は猫が大好き{0:>---}{c: X } {0:>}|
- |
- {0:~ }|
- {0:~ }|
- |
- ]])
- feed('<esc><LeftMouse><7,2>')
- screen:expect([[
- Section{0:>>--->--->---}{c: }t1{c: } |
- {0:>--->--->---} {c: }t2{c: } {c: }t3{c: } {c: }|
- {c:>} 私は^猫が大好き{0:>---}{c: X } {0:>}|
- |
- {0:~ }|
- {0:~ }|
- |
- ]])
- feed('<esc><LeftMouse><21,2>')
- screen:expect([[
- Section{0:>>--->--->---}{c: }t1{c: } |
- {0:>--->--->---} {c: }t2{c: } {c: }t3{c: } {c: }|
- {c:>} 私は猫が大好き{0:>---}{c: ^X } {0:>}|
- |
- {0:~ }|
- {0:~ }|
- |
- ]])
- end) -- level 1 - non wrapped
- it('(level 1) click on wrapped lines', function()
- feed_command('let &conceallevel=1', 'let &wrap=1', 'echo')
- feed('<esc><LeftMouse><24,1>')
- screen:expect([[
- Section{0:>>--->--->---}{c: }t1{c: } |
- {0:>--->--->---} {c: }t2{c: } {c: }t3{c: } {c:^ }|
- t4{c: } |
- {c:>} 私は猫が大好き{0:>---}{c: X} |
- {c: } ✨🐈✨ |
- |
- |
- ]])
- feed('<esc><LeftMouse><0,2>')
- screen:expect([[
- Section{0:>>--->--->---}{c: }t1{c: } |
- {0:>--->--->---} {c: }t2{c: } {c: }t3{c: } {c: }|
- ^t4{c: } |
- {c:>} 私は猫が大好き{0:>---}{c: X} |
- {c: } ✨🐈✨ |
- |
- |
- ]])
- feed('<esc><LeftMouse><8,3>')
- screen:expect([[
- Section{0:>>--->--->---}{c: }t1{c: } |
- {0:>--->--->---} {c: }t2{c: } {c: }t3{c: } {c: }|
- t4{c: } |
- {c:>} 私は猫^が大好き{0:>---}{c: X} |
- {c: } ✨🐈✨ |
- |
- |
- ]])
- feed('<esc><LeftMouse><21,3>')
- screen:expect([[
- Section{0:>>--->--->---}{c: }t1{c: } |
- {0:>--->--->---} {c: }t2{c: } {c: }t3{c: } {c: }|
- t4{c: } |
- {c:>} 私は猫が大好き{0:>---}{c: ^X} |
- {c: } ✨🐈✨ |
- |
- |
- ]])
- feed('<esc><LeftMouse><4,4>')
- screen:expect([[
- Section{0:>>--->--->---}{c: }t1{c: } |
- {0:>--->--->---} {c: }t2{c: } {c: }t3{c: } {c: }|
- t4{c: } |
- {c:>} 私は猫が大好き{0:>---}{c: X} |
- {c: } ✨^🐈✨ |
- |
- |
- ]])
- end) -- level 1 - wrapped
- it('(level 2) click on non-wrapped lines', function()
- feed_command('let &conceallevel=2', 'echo')
- feed('<esc><LeftMouse><20,0>')
- screen:expect([[
- Section{0:>>--->--->---}^t1 |
- {0:>--->--->---} t2 t3 t4 |
- {c:>} 私は猫が大好き{0:>---}{c:X} ✨{0:>}|
- |
- {0:~ }|
- {0:~ }|
- |
- ]])
- feed('<esc><LeftMouse><14,1>')
- screen:expect([[
- Section{0:>>--->--->---}t1 |
- {0:>--->--->---} ^t2 t3 t4 |
- {c:>} 私は猫が大好き{0:>---}{c:X} ✨{0:>}|
- |
- {0:~ }|
- {0:~ }|
- |
- ]])
- feed('<esc><LeftMouse><18,1>')
- screen:expect([[
- Section{0:>>--->--->---}t1 |
- {0:>--->--->---} t2 t^3 t4 |
- {c:>} 私は猫が大好き{0:>---}{c:X} ✨{0:>}|
- |
- {0:~ }|
- {0:~ }|
- |
- ]])
- feed('<esc><LeftMouse><0,2>') -- Weirdness
- screen:expect([[
- Section{0:>>--->--->---}t1 |
- {0:>--->--->---} t2 t3 t4 |
- {c:^>} 私は猫が大好き{0:>---}{c:X} ✨{0:>}|
- |
- {0:~ }|
- {0:~ }|
- |
- ]])
- feed('<esc><LeftMouse><8,2>')
- screen:expect([[
- Section{0:>>--->--->---}t1 |
- {0:>--->--->---} t2 t3 t4 |
- {c:>} 私は猫^が大好き{0:>---}{c:X} ✨{0:>}|
- |
- {0:~ }|
- {0:~ }|
- |
- ]])
- feed('<esc><LeftMouse><20,2>')
- screen:expect([[
- Section{0:>>--->--->---}t1 |
- {0:>--->--->---} t2 t3 t4 |
- {c:>} 私は猫が大好き{0:>---}{c:^X} ✨{0:>}|
- |
- {0:~ }|
- {0:~ }|
- |
- ]])
- end) -- level 2 - non wrapped
- it('(level 2) click on non-wrapped lines (insert mode)', function()
- feed_command('let &conceallevel=2', 'echo')
- feed('<esc>i<LeftMouse><20,0>')
- screen:expect([[
- Section{0:>>--->--->---}^t1 |
- {0:>--->--->---} t2 t3 t4 |
- {c:>} 私は猫が大好き{0:>---}{c:X} ✨{0:>}|
- |
- {0:~ }|
- {0:~ }|
- {sm:-- INSERT --} |
- ]])
- feed('<LeftMouse><14,1>')
- screen:expect([[
- Section{0:>>--->--->---}t1 |
- {0:>--->--->---} ^t2 t3 t4 |
- {c:>} 私は猫が大好き{0:>---}{c:X} ✨{0:>}|
- |
- {0:~ }|
- {0:~ }|
- {sm:-- INSERT --} |
- ]])
- feed('<LeftMouse><18,1>')
- screen:expect([[
- Section{0:>>--->--->---}t1 |
- {0:>--->--->---} t2 t^3 t4 |
- {c:>} 私は猫が大好き{0:>---}{c:X} ✨{0:>}|
- |
- {0:~ }|
- {0:~ }|
- {sm:-- INSERT --} |
- ]])
- feed('<LeftMouse><0,2>') -- Weirdness
- screen:expect([[
- Section{0:>>--->--->---}t1 |
- {0:>--->--->---} t2 t3 t4 |
- {c:^>} 私は猫が大好き{0:>---}{c:X} ✨{0:>}|
- |
- {0:~ }|
- {0:~ }|
- {sm:-- INSERT --} |
- ]])
- feed('<LeftMouse><8,2>')
- screen:expect([[
- Section{0:>>--->--->---}t1 |
- {0:>--->--->---} t2 t3 t4 |
- {c:>} 私は猫^が大好き{0:>---}{c:X} ✨{0:>}|
- |
- {0:~ }|
- {0:~ }|
- {sm:-- INSERT --} |
- ]])
- feed('<LeftMouse><20,2>')
- screen:expect([[
- Section{0:>>--->--->---}t1 |
- {0:>--->--->---} t2 t3 t4 |
- {c:>} 私は猫が大好き{0:>---}{c:^X} ✨{0:>}|
- |
- {0:~ }|
- {0:~ }|
- {sm:-- INSERT --} |
- ]])
- end) -- level 2 - non wrapped (insert mode)
- it('(level 2) click on wrapped lines', function()
- feed_command('let &conceallevel=2', 'let &wrap=1', 'echo')
- feed('<esc><LeftMouse><20,0>')
- screen:expect([[
- Section{0:>>--->--->---}^t1 |
- {0:>--->--->---} t2 t3 |
- t4 |
- {c:>} 私は猫が大好き{0:>---}{c:X} |
- ✨🐈✨ |
- |
- |
- ]])
- feed('<esc><LeftMouse><14,1>')
- screen:expect([[
- Section{0:>>--->--->---}t1 |
- {0:>--->--->---} ^t2 t3 |
- t4 |
- {c:>} 私は猫が大好き{0:>---}{c:X} |
- ✨🐈✨ |
- |
- |
- ]])
- feed('<esc><LeftMouse><18,1>')
- screen:expect([[
- Section{0:>>--->--->---}t1 |
- {0:>--->--->---} t2 t^3 |
- t4 |
- {c:>} 私は猫が大好き{0:>---}{c:X} |
- ✨🐈✨ |
- |
- |
- ]])
- -- NOTE: The click would ideally be on the 't' in 't4', but wrapping
- -- caused the invisible '*' right before 't4' to remain on the previous
- -- screen line. This is being treated as expected because fixing this is
- -- out of scope for mouse clicks. Should the wrapping behavior of
- -- concealed characters change in the future, this case should be
- -- reevaluated.
- feed('<esc><LeftMouse><0,2>')
- screen:expect([[
- Section{0:>>--->--->---}t1 |
- {0:>--->--->---} t2 t3 ^ |
- t4 |
- {c:>} 私は猫が大好き{0:>---}{c:X} |
- ✨🐈✨ |
- |
- |
- ]])
- feed('<esc><LeftMouse><1,2>')
- screen:expect([[
- Section{0:>>--->--->---}t1 |
- {0:>--->--->---} t2 t3 |
- t^4 |
- {c:>} 私は猫が大好き{0:>---}{c:X} |
- ✨🐈✨ |
- |
- |
- ]])
- feed('<esc><LeftMouse><0,3>')
- screen:expect([[
- Section{0:>>--->--->---}t1 |
- {0:>--->--->---} t2 t3 |
- t4 |
- {c:^>} 私は猫が大好き{0:>---}{c:X} |
- ✨🐈✨ |
- |
- |
- ]])
- feed('<esc><LeftMouse><20,3>')
- screen:expect([[
- Section{0:>>--->--->---}t1 |
- {0:>--->--->---} t2 t3 |
- t4 |
- {c:>} 私は猫が大好き{0:>---}{c:^X} |
- ✨🐈✨ |
- |
- |
- ]])
- feed('<esc><LeftMouse><1,4>')
- screen:expect([[
- Section{0:>>--->--->---}t1 |
- {0:>--->--->---} t2 t3 |
- t4 |
- {c:>} 私は猫が大好き{0:>---}{c:X} |
- ^✨🐈✨ |
- |
- |
- ]])
- feed('<esc><LeftMouse><5,4>')
- screen:expect([[
- Section{0:>>--->--->---}t1 |
- {0:>--->--->---} t2 t3 |
- t4 |
- {c:>} 私は猫が大好き{0:>---}{c:X} |
- ✨🐈^✨ |
- |
- |
- ]])
- end) -- level 2 - wrapped
- it('(level 3) click on non-wrapped lines', function()
- feed_command('let &conceallevel=3', 'echo')
- feed('<esc><LeftMouse><0,2>')
- screen:expect([[
- Section{0:>>--->--->---}t1 |
- {0:>--->--->---} t2 t3 t4 |
- ^ 私は猫が大好き{0:>----} ✨🐈|
- |
- {0:~ }|
- {0:~ }|
- |
- ]])
- feed('<esc><LeftMouse><1,2>')
- screen:expect([[
- Section{0:>>--->--->---}t1 |
- {0:>--->--->---} t2 t3 t4 |
- ^私は猫が大好き{0:>----} ✨🐈|
- |
- {0:~ }|
- {0:~ }|
- |
- ]])
- feed('<esc><LeftMouse><13,2>')
- screen:expect([[
- Section{0:>>--->--->---}t1 |
- {0:>--->--->---} t2 t3 t4 |
- 私は猫が大好^き{0:>----} ✨🐈|
- |
- {0:~ }|
- {0:~ }|
- |
- ]])
- feed('<esc><LeftMouse><20,2>')
- screen:expect([[
- Section{0:>>--->--->---}t1 |
- {0:>--->--->---} t2 t3 t4 |
- 私は猫が大好き{0:>----}^ ✨🐈|
- |
- {0:~ }|
- {0:~ }|
- |
- ]])
- end) -- level 3 - non wrapped
- it('(level 3) click on wrapped lines', function()
- feed_command('let &conceallevel=3', 'let &wrap=1', 'echo')
- feed('<esc><LeftMouse><14,1>')
- screen:expect([[
- Section{0:>>--->--->---}t1 |
- {0:>--->--->---} ^t2 t3 |
- t4 |
- 私は猫が大好き{0:>----} |
- ✨🐈✨ |
- |
- |
- ]])
- feed('<esc><LeftMouse><18,1>')
- screen:expect([[
- Section{0:>>--->--->---}t1 |
- {0:>--->--->---} t2 t^3 |
- t4 |
- 私は猫が大好き{0:>----} |
- ✨🐈✨ |
- |
- |
- ]])
- feed('<esc><LeftMouse><1,2>')
- screen:expect([[
- Section{0:>>--->--->---}t1 |
- {0:>--->--->---} t2 t3 |
- t^4 |
- 私は猫が大好き{0:>----} |
- ✨🐈✨ |
- |
- |
- ]])
- feed('<esc><LeftMouse><0,3>')
- screen:expect([[
- Section{0:>>--->--->---}t1 |
- {0:>--->--->---} t2 t3 |
- t4 |
- ^ 私は猫が大好き{0:>----} |
- ✨🐈✨ |
- |
- |
- ]])
- feed('<esc><LeftMouse><20,3>')
- screen:expect([[
- Section{0:>>--->--->---}t1 |
- {0:>--->--->---} t2 t3 |
- t4 |
- 私は猫が大好き{0:>----}^ |
- ✨🐈✨ |
- |
- |
- ]])
- feed('<esc><LeftMouse><1,4>')
- screen:expect([[
- Section{0:>>--->--->---}t1 |
- {0:>--->--->---} t2 t3 |
- t4 |
- 私は猫が大好き{0:>----} |
- ^✨🐈✨ |
- |
- |
- ]])
- feed('<esc><LeftMouse><3,4>')
- screen:expect([[
- Section{0:>>--->--->---}t1 |
- {0:>--->--->---} t2 t3 |
- t4 |
- 私は猫が大好き{0:>----} |
- ✨^🐈✨ |
- |
- |
- ]])
- feed('<esc><LeftMouse><5,4>')
- screen:expect([[
- Section{0:>>--->--->---}t1 |
- {0:>--->--->---} t2 t3 |
- t4 |
- 私は猫が大好き{0:>----} |
- ✨🐈^✨ |
- |
- |
- ]])
- end) -- level 3 - wrapped
- end)
- end)
|