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