mirror of
https://github.com/neovim/neovim.git
synced 2025-10-22 17:11:49 +00:00
test: screen_setup(): Support cols
parameter.
This commit is contained in:
@@ -34,12 +34,15 @@ local function disable_mouse() feed_termcode('[?1002l') end
|
|||||||
local default_command = '["'..nvim_dir..'/tty-test'..'"]'
|
local default_command = '["'..nvim_dir..'/tty-test'..'"]'
|
||||||
|
|
||||||
|
|
||||||
local function screen_setup(extra_height, command)
|
local function screen_setup(extra_rows, command, cols)
|
||||||
|
extra_rows = extra_rows and extra_rows or 0
|
||||||
|
command = command and command or default_command
|
||||||
|
cols = cols and cols or 50
|
||||||
|
|
||||||
nvim('command', 'highlight TermCursor cterm=reverse')
|
nvim('command', 'highlight TermCursor cterm=reverse')
|
||||||
nvim('command', 'highlight TermCursorNC ctermbg=11')
|
nvim('command', 'highlight TermCursorNC ctermbg=11')
|
||||||
if not extra_height then extra_height = 0 end
|
|
||||||
if not command then command = default_command end
|
local screen = Screen.new(cols, 7 + extra_rows)
|
||||||
local screen = Screen.new(50, 7 + extra_height)
|
|
||||||
screen:set_default_attr_ids({
|
screen:set_default_attr_ids({
|
||||||
[1] = {reverse = true}, -- focused cursor
|
[1] = {reverse = true}, -- focused cursor
|
||||||
[2] = {background = 11}, -- unfocused cursor
|
[2] = {background = 11}, -- unfocused cursor
|
||||||
@@ -61,23 +64,22 @@ local function screen_setup(extra_height, command)
|
|||||||
execute('setlocal scrollback=10')
|
execute('setlocal scrollback=10')
|
||||||
execute('startinsert')
|
execute('startinsert')
|
||||||
if command == default_command then
|
if command == default_command then
|
||||||
-- wait for "tty ready" to be printed before each test or the terminal may
|
-- Wait for "tty ready" to be printed before each test or the terminal may
|
||||||
-- still be in canonical mode(will echo characters for example)
|
-- still be in canonical mode (will echo characters for example).
|
||||||
--
|
local empty_line = (' '):rep(cols + 1)
|
||||||
local empty_line = ' '
|
|
||||||
local expected = {
|
local expected = {
|
||||||
'tty ready ',
|
'tty ready'..(' '):rep(cols - 8),
|
||||||
'{1: } ',
|
'{1: }' ..(' '):rep(cols),
|
||||||
empty_line,
|
empty_line,
|
||||||
empty_line,
|
empty_line,
|
||||||
empty_line,
|
empty_line,
|
||||||
empty_line,
|
empty_line,
|
||||||
}
|
}
|
||||||
for _ = 1, extra_height do
|
for _ = 1, extra_rows do
|
||||||
table.insert(expected, empty_line)
|
table.insert(expected, empty_line)
|
||||||
end
|
end
|
||||||
|
|
||||||
table.insert(expected, '{3:-- TERMINAL --} ')
|
table.insert(expected, '{3:-- TERMINAL --}' .. ((' '):rep(cols - 13)))
|
||||||
screen:expect(table.concat(expected, '\n'))
|
screen:expect(table.concat(expected, '\n'))
|
||||||
else
|
else
|
||||||
wait()
|
wait()
|
||||||
|
@@ -17,7 +17,7 @@ describe('terminal scrollback', function()
|
|||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
clear()
|
clear()
|
||||||
screen = thelpers.screen_setup()
|
screen = thelpers.screen_setup(nil, nil, 30)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
after_each(function()
|
after_each(function()
|
||||||
@@ -145,7 +145,7 @@ describe('terminal scrollback', function()
|
|||||||
line2 |
|
line2 |
|
||||||
line3 |
|
line3 |
|
||||||
line4 |
|
line4 |
|
||||||
rows: 5, cols: 50 |
|
rows: 5, cols: 30 |
|
||||||
{1: } |
|
{1: } |
|
||||||
{3:-- TERMINAL --} |
|
{3:-- TERMINAL --} |
|
||||||
]])
|
]])
|
||||||
@@ -161,8 +161,8 @@ describe('terminal scrollback', function()
|
|||||||
|
|
||||||
it('will hide the top 3 lines', function()
|
it('will hide the top 3 lines', function()
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
rows: 5, cols: 50 |
|
rows: 5, cols: 30 |
|
||||||
rows: 3, cols: 50 |
|
rows: 3, cols: 30 |
|
||||||
{1: } |
|
{1: } |
|
||||||
{3:-- TERMINAL --} |
|
{3:-- TERMINAL --} |
|
||||||
]])
|
]])
|
||||||
@@ -170,8 +170,8 @@ describe('terminal scrollback', function()
|
|||||||
feed('<c-\\><c-n>3k')
|
feed('<c-\\><c-n>3k')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
^line4 |
|
^line4 |
|
||||||
rows: 5, cols: 50 |
|
rows: 5, cols: 30 |
|
||||||
rows: 3, cols: 50 |
|
rows: 3, cols: 30 |
|
||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
end)
|
end)
|
||||||
@@ -188,7 +188,7 @@ describe('terminal scrollback', function()
|
|||||||
local function will_delete_last_two_lines()
|
local function will_delete_last_two_lines()
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
tty ready |
|
tty ready |
|
||||||
rows: 4, cols: 50 |
|
rows: 4, cols: 30 |
|
||||||
{1: } |
|
{1: } |
|
||||||
|
|
|
|
||||||
{3:-- TERMINAL --} |
|
{3:-- TERMINAL --} |
|
||||||
@@ -206,8 +206,8 @@ describe('terminal scrollback', function()
|
|||||||
|
|
||||||
it('will delete the last line and hide the first', function()
|
it('will delete the last line and hide the first', function()
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
rows: 4, cols: 50 |
|
rows: 4, cols: 30 |
|
||||||
rows: 3, cols: 50 |
|
rows: 3, cols: 30 |
|
||||||
{1: } |
|
{1: } |
|
||||||
{3:-- TERMINAL --} |
|
{3:-- TERMINAL --} |
|
||||||
]])
|
]])
|
||||||
@@ -215,14 +215,14 @@ describe('terminal scrollback', function()
|
|||||||
feed('<c-\\><c-n>gg')
|
feed('<c-\\><c-n>gg')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
^tty ready |
|
^tty ready |
|
||||||
rows: 4, cols: 50 |
|
rows: 4, cols: 30 |
|
||||||
rows: 3, cols: 50 |
|
rows: 3, cols: 30 |
|
||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
feed('a')
|
feed('a')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
rows: 4, cols: 50 |
|
rows: 4, cols: 30 |
|
||||||
rows: 3, cols: 50 |
|
rows: 3, cols: 30 |
|
||||||
{1: } |
|
{1: } |
|
||||||
{3:-- TERMINAL --} |
|
{3:-- TERMINAL --} |
|
||||||
]])
|
]])
|
||||||
@@ -246,7 +246,7 @@ describe('terminal scrollback', function()
|
|||||||
screen:try_resize(screen._width, screen._height - 3)
|
screen:try_resize(screen._width, screen._height - 3)
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
line4 |
|
line4 |
|
||||||
rows: 3, cols: 50 |
|
rows: 3, cols: 30 |
|
||||||
{1: } |
|
{1: } |
|
||||||
{3:-- TERMINAL --} |
|
{3:-- TERMINAL --} |
|
||||||
]])
|
]])
|
||||||
@@ -258,8 +258,8 @@ describe('terminal scrollback', function()
|
|||||||
screen:try_resize(screen._width, screen._height + 1)
|
screen:try_resize(screen._width, screen._height + 1)
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
line4 |
|
line4 |
|
||||||
rows: 3, cols: 50 |
|
rows: 3, cols: 30 |
|
||||||
rows: 4, cols: 50 |
|
rows: 4, cols: 30 |
|
||||||
{1: } |
|
{1: } |
|
||||||
{3:-- TERMINAL --} |
|
{3:-- TERMINAL --} |
|
||||||
]])
|
]])
|
||||||
@@ -279,9 +279,9 @@ describe('terminal scrollback', function()
|
|||||||
line2 |
|
line2 |
|
||||||
line3 |
|
line3 |
|
||||||
line4 |
|
line4 |
|
||||||
rows: 3, cols: 50 |
|
rows: 3, cols: 30 |
|
||||||
rows: 4, cols: 50 |
|
rows: 4, cols: 30 |
|
||||||
rows: 7, cols: 50 |
|
rows: 7, cols: 30 |
|
||||||
{1: } |
|
{1: } |
|
||||||
{3:-- TERMINAL --} |
|
{3:-- TERMINAL --} |
|
||||||
]])
|
]])
|
||||||
@@ -293,8 +293,8 @@ describe('terminal scrollback', function()
|
|||||||
line2 |
|
line2 |
|
||||||
line3 |
|
line3 |
|
||||||
line4 |
|
line4 |
|
||||||
rows: 3, cols: 50 |
|
rows: 3, cols: 30 |
|
||||||
rows: 4, cols: 50 |
|
rows: 4, cols: 30 |
|
||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
end
|
end
|
||||||
@@ -315,10 +315,10 @@ describe('terminal scrollback', function()
|
|||||||
line2 |
|
line2 |
|
||||||
line3 |
|
line3 |
|
||||||
line4 |
|
line4 |
|
||||||
rows: 3, cols: 50 |
|
rows: 3, cols: 30 |
|
||||||
rows: 4, cols: 50 |
|
rows: 4, cols: 30 |
|
||||||
rows: 7, cols: 50 |
|
rows: 7, cols: 30 |
|
||||||
rows: 11, cols: 50 |
|
rows: 11, cols: 30 |
|
||||||
{1: } |
|
{1: } |
|
||||||
|
|
|
|
||||||
{3:-- TERMINAL --} |
|
{3:-- TERMINAL --} |
|
||||||
@@ -336,7 +336,7 @@ end)
|
|||||||
describe('terminal prints more lines than the screen height and exits', function()
|
describe('terminal prints more lines than the screen height and exits', function()
|
||||||
it('will push extra lines to scrollback', function()
|
it('will push extra lines to scrollback', function()
|
||||||
clear()
|
clear()
|
||||||
local screen = Screen.new(50, 7)
|
local screen = Screen.new(30, 7)
|
||||||
screen:attach({rgb=false})
|
screen:attach({rgb=false})
|
||||||
execute('call termopen(["'..nvim_dir..'/tty-test", "10"]) | startinsert')
|
execute('call termopen(["'..nvim_dir..'/tty-test", "10"]) | startinsert')
|
||||||
wait()
|
wait()
|
||||||
|
Reference in New Issue
Block a user