local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local clear, feed = helpers.clear, helpers.feed
local source = helpers.source
local command = helpers.command
local assert_alive = helpers.assert_alive
local poke_eventloop = helpers.poke_eventloop
local exec = helpers.exec
local eval = helpers.eval
local eq = helpers.eq
local is_os = helpers.is_os
local meths = helpers.meths
local function new_screen(opt)
local screen = Screen.new(25, 5)
screen:attach(opt)
screen:set_default_attr_ids({
[1] = {bold = true, foreground = Screen.colors.Blue1},
[2] = {reverse = true},
[3] = {bold = true, reverse = true},
[4] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
[5] = {bold = true, foreground = Screen.colors.SeaGreen4},
[6] = {foreground = Screen.colors.Magenta},
[7] = {bold = true, foreground = Screen.colors.Brown},
[8] = {background = Screen.colors.LightGrey},
[9] = {bold = true},
})
return screen
end
local function test_cmdline(linegrid)
local screen
before_each(function()
clear()
screen = new_screen({rgb=true, ext_cmdline=true, ext_linegrid=linegrid})
end)
it('works', function()
feed(':')
screen:expect{grid=[[
^ |
{1:~ }|
{1:~ }|
{1:~ }|
|
]], cmdline={{
firstc = ":",
content = {{""}},
pos = 0,
}}}
feed('sign')
screen:expect{grid=[[
^ |
{1:~ }|
{1:~ }|
{1:~ }|
|
]], cmdline={{
firstc = ":",
content = {{"sign"}},
pos = 4,
}}}
feed('<Left>')
screen:expect{grid=[[
^ |
{1:~ }|
{1:~ }|
{1:~ }|
|
]], cmdline={{
firstc = ":",
content = {{"sign"}},
pos = 3,
}}}
feed('<bs>')
screen:expect{grid=[[
^ |
{1:~ }|
{1:~ }|
{1:~ }|
|
]], cmdline={{
firstc = ":",
content = {{"sin"}},
pos = 2,
}}}
feed('<Esc>')
screen:expect{grid=[[
^ |
{1:~ }|
{1:~ }|
{1:~ }|
|
]]}
end)
it("works with input()", function()
feed(':call input("input", "default")<cr>')
screen:expect{grid=[[
^ |
{1:~ }|
{1:~ }|
{1:~ }|
|
]], cmdline={{
prompt = "input",
content = {{
|