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
|
local helpers = require('test.functional.helpers')
local Screen = require('test.functional.ui.screen')
local clear, feed, nvim = helpers.clear, helpers.feed, helpers.nvim
describe('Mouse input', function()
local screen, hlgroup_colors
setup(function()
hlgroup_colors = {
Visual = nvim('name_to_color', 'LightGrey'),
}
end)
before_each(function()
clear()
nvim('set_option', 'mouse', 'a')
-- set mouset to very high value to ensure that even in valgrind/travis,
-- nvim will still pick multiple clicks
nvim('set_option', 'mouset', 5000)
screen = Screen.new(25, 5)
screen:attach()
screen:set_default_attr_ids({
[1] = {background = hlgroup_colors.Visual}
})
feed('itesting<cr>mouse<cr>support and selection<esc>')
screen:expect([[
testing |
mouse |
support and selectio^ |
~ |
|
]])
end)
after_each(function()
screen:detach()
end)
it('left click moves cursor', function()
feed('<LeftMouse><2,1>')
screen:expect([[
testing |
mo^se |
support and selection |
~ |
|
]])
feed('<LeftMouse><0,0>')
screen:expect([[
^esting |
mouse |
support and selection |
~ |
|
]])
end)
it('left drag changes visual selection', function()
-- drag events must be preceded by a click
feed('<LeftMouse><2,1>')
screen:expect([[
testing |
mo^se |
support and selection |
~ |
|
]])
feed('<LeftDrag><4,1>')
screen:expect([[
testing |
mo{1:us}^ |
support and selection |
~ |
-- VISUAL -- |
]])
feed('<LeftDrag><2,2>')
screen:expect([[
testing |
mo{1:use } |
{1:su}^port and selection |
~ |
-- VISUAL -- |
]])
feed('<LeftDrag><0,0>')
screen:expect([[
^{1:esting } |
{1:mou}se |
support and selection |
~ |
-- 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}^ and selection |
~ |
-- 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}^{1:port and selection } |
~ |
-- 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^port and selection |
~ |
-- VISUAL BLOCK -- |
]])
end)
it('right click extends visual selection to the clicked location', function()
feed('<LeftMouse><0,0>')
screen:expect([[
^esting |
mouse |
support and selection |
~ |
|
]])
feed('<RightMouse><2,2>')
screen:expect([[
{1:testing } |
{1:mouse } |
{1:su}^port and selection |
~ |
-- VISUAL -- |
]])
end)
it('ctrl + left click will search for a tag', function()
feed('<C-LeftMouse><0,0>')
screen:expect([[
E433: No tags file |
E426: tag not found: test|
ing |
Press ENTER or type comma|
nd to continue^ |
]])
feed('<cr>')
end)
end)
|