local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local clear, feed, command = helpers.clear, helpers.feed, helpers.command
local eq = helpers.eq
local insert = helpers.insert
local poke_eventloop = helpers.poke_eventloop
local exec = helpers.exec
describe('Screen', function()
local screen
before_each(function()
clear()
screen = Screen.new(nil,10)
screen:attach()
screen:set_default_attr_ids( {
[0] = {bold=true, foreground=Screen.colors.Blue},
[1] = {foreground = Screen.colors.LightGrey, background = Screen.colors.DarkGray},
[2] = {bold = true, reverse = true},
[3] = {reverse = true},
[4] = {bold = true},
[5] = {background = Screen.colors.Yellow},
[6] = {background = Screen.colors.LightGrey},
} )
end)
describe("match and conceal", function()
before_each(function()
command("let &conceallevel=1")
end)
describe("multiple", function()
before_each(function()
insert([[
&&
&&
&&
&&
&&
&&
]])
command("syn match dAmpersand '[&][&]' conceal cchar=∧")
end)
it("double characters.", function()
screen:expect([[
{1:∧} |
{1:∧} |
{1:∧} |
{1:∧} |
{1:∧} |
{1:∧} |
^ |
{0:~ }|
{0:~ }|
|
]])
end)
it('double characters and move the cursor one line up.', function()
feed("k")
screen:expect([[
{1:∧} |
{1:∧} |
{1:∧} |
{1:∧} |
{1:∧} |
^&& |
|
{0:~ }|
{0:~ }|
|
]])
end)
it('double characters and move the cursor to the beginning of the file.', function()
feed("gg")
screen:expect([[
^&& |
{1:∧} |
{1:∧} |
{1:∧} |
{1:∧} |
{1:∧} |
|
{0:~ }|
{0:~ }|
|
]])
end)
it('double characters and move the cursor to the second line in the file.', function()
feed("ggj")
screen:expect([[
{1:∧} |
^&& |
{1:∧} |
{1:∧} |
{1:∧} |
{1:∧} |
|
{0:~ }|
{0:~ }|
|
]])
end)
it('double characters and then move the cursor to the beginning of the file and back to the end of the file.', function()
feed("ggG")
screen:expect([[
{1:∧} |
{1:∧} |
{1:∧} |
{1:∧} |
{1:∧} |
{1:∧} |
^ |
{0:~ }|
{0:~ }|
|
]])
end)
end) -- multiple
it("keyword instances in initially in the document.", function()
feed("2ilambda<cr><ESC>")
command("let &conceallevel=1")
command("syn keyword kLambda lambda conceal cchar=λ")
screen:expect([[
{1:λ} |
{1:λ} |
^ |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
|
]])
end) -- Keyword
describe("regions in the document", function()
before_each(function()
feed("2")
insert("<r> a region of text </r>\n")
command("let &conceallevel=1")
end)
it('initially and conceal it.', function()
command("syn region rText start='<r>' end='</r>' conceal cchar=R")
screen:expect([[
{1:R} |
{1:R} |
^ |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
|
]])
end)
it('initially and conceal its start tag and end tag.', function()
-- concealends has a known bug (todo.txt) where the first match won't
-- be replaced with cchar.
command("syn region rText matchgroup=rMatch start='<r>' end='</r>' concealends cchar=-")
screen:expect([[
{1: } a region of text {1:-} |
{1: } a region of text {1:-} |
^ |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
|
]])
end)
it('that are nested and conceal the nested region\'s start and end tags.', function()
command("syn region rText contains=rText matchgroup=rMatch start='<r>' end='</r>' concealends cchar=-")
insert("<r> A region with <r> a nested <r> nested region.</r> </r> </r>\n")
screen:expect([[
{1: } a region of text {1:-} |
{1: } a region of text {1:-} |
{1: } A region with {1: } a nested {1: } nested region.{1:-} |
{1:-} {1:-} |
^ |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
|
]])
end)
end) -- regions in the document
describe("a region of text", function()
before_each(function()
command("syntax conceal on")
feed("2")
insert("<r> a region of text </r>\n")
command("syn region rText start='<r>' end='</r>' cchar=-")
end)
it("and turn on implicit concealing"
|