1
local helpers = require('test.functional.helpers')
2
local Screen = require('test.functional.ui.screen')
3
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
4
local execute, request, neq = helpers.execute, helpers.request, helpers.neq
7
describe('Buffer highlighting', function()
12
NonText = Screen.colors.Blue,
13
Question = Screen.colors.SeaGreen,
14
String = Screen.colors.Fuchsia,
15
Statement = Screen.colors.Brown,
16
Special = Screen.colors.SlateBlue,
17
Identifier = Screen.colors.DarkCyan
20
before_each(function()
23
screen = Screen.new(40, 8)
25
screen:set_default_attr_ignore( {{bold=true, foreground=hl_colors.NonText}} )
26
screen:set_default_attr_ids({
27
[1] = {foreground = hl_colors.String},
28
[2] = {foreground = hl_colors.Statement, bold = true},
29
[3] = {foreground = hl_colors.Special},
30
[4] = {bold = true, foreground = hl_colors.Special},
31
[5] = {foreground = hl_colors.Identifier},
33
[7] = {underline = true, bold = true, foreground = hl_colors.Special},
34
[8] = {foreground = hl_colors.Special, underline = true}
36
curbuf = request('vim_get_current_buffer')
43
local function add_hl(...)
44
return request('buffer_add_highlight', curbuf, ...)
47
local function clear_hl(...)
48
return request('buffer_clear_highlight', curbuf, ...)
52
it('works', function()
59
these are some lines |
69
add_hl(-1, "String", 0 , 10, 14)
70
add_hl(-1, "Statement", 1 , 5, -1)
73
these are {1:some} lines |
74
with {2:colorful tex^t} |
85
these are {1:some} lines |
87
with {2:colorful text} |
97
these are some lines |
108
describe('support adding multiple sources', function()
110
before_each(function()
113
in order to demonstrate
115
from different sources]])
117
execute("hi ImportantWord gui=bold cterm=bold")
118
id1 = add_hl(0, "ImportantWord", 0, 2, 8)
119
add_hl(id1, "ImportantWord", 1, 12, -1)
120
add_hl(id1, "ImportantWord", 2, 0, 9)
121
add_hl(id1, "ImportantWord", 3, 5, 14)
123
id2 = add_hl(0, "Special", 0, 2, 8)
124
add_hl(id2, "Identifier", 1, 3, 8)
125
add_hl(id2, "Special", 1, 14, 20)
126
add_hl(id2, "Underlined", 2, 6, 12)
127
add_hl(id2, "Underlined", 3, 0, 9)
131
a {4:longer} example |
132
in {5:order} to {6:de}{4:monstr}{6:ate} |
133
{6:combin}{7:ing}{8: hi}ghlights |
134
{8:from }{7:diff}{6:erent} source^s |
138
:hi ImportantWord gui=bold cterm=bold |
142
it('and clearing the first added', function()
145
a {3:longer} example |
146
in {5:order} to de{3:monstr}ate |
147
combin{8:ing hi}ghlights |
148
{8:from diff}erent source^s |
152
:hi ImportantWord gui=bold cterm=bold |
156
it('and clearing the second added', function()
159
a {6:longer} example |
160
in order to {6:demonstrate} |
161
{6:combining} highlights |
162
from {6:different} source^s |
166
:hi ImportantWord gui=bold cterm=bold |
170
it('and clearing line ranges', function()
176
in {5:order} to de{3:monstr}ate |
177
{6:combining} highlights |
178
from {6:different} source^s |
182
:hi ImportantWord gui=bold cterm=bold |
186
it('and renumbering lines', function()
189
a {4:longer} example |
191
in {5:order} to {6:de}{4:monstr}{6:ate} |
192
{8:from }{7:diff}{6:erent} sources |
201
a {4:longer} example |
203
{8:from }{7:diff}{6:erent} sources |
204
^in {5:order} to {6:de}{4:monstr}{6:ate} |
213
it('prioritizes latest added highlight', function()
215
three overlapping colors]])
216
add_hl(0, "Identifier", 0, 6, 17)
217
add_hl(0, "String", 0, 14, 23)
218
local id = add_hl(0, "Special", 0, 0, 9)
221
{3:three ove}{5:rlapp}{1:ing color}^s |
233
three {5:overlapp}{1:ing color}^s |
244
it('works with multibyte text', function()
246
Ta båten över sjön!]])
247
add_hl(-1, "Identifier", 0, 3, 9)
248
add_hl(-1, "String", 0, 16, 21)
251
Ta {5:båten} över {1:sjön}^! |