2016-04-23 16:53:11 -07:00
|
|
|
local helpers = require('test.functional.helpers')(after_each)
|
2015-03-25 05:14:47 -07:00
|
|
|
local Screen = require('test.functional.ui.screen')
|
|
|
|
local thelpers = require('test.functional.terminal.helpers')
|
|
|
|
local feed, clear, nvim = helpers.feed, helpers.clear, helpers.nvim
|
2017-04-08 14:12:26 -07:00
|
|
|
local nvim_dir, command = helpers.nvim_dir, helpers.command
|
2015-03-25 05:14:47 -07:00
|
|
|
local hide_cursor = thelpers.hide_cursor
|
|
|
|
local show_cursor = thelpers.show_cursor
|
|
|
|
|
2016-08-15 16:42:12 -07:00
|
|
|
if helpers.pending_win32(pending) then return end
|
2015-03-25 05:14:47 -07:00
|
|
|
|
|
|
|
describe('terminal cursor', function()
|
|
|
|
local screen
|
|
|
|
|
|
|
|
before_each(function()
|
|
|
|
clear()
|
|
|
|
screen = thelpers.screen_setup()
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
|
|
it('moves the screen cursor when focused', function()
|
|
|
|
thelpers.feed_data('testing cursor')
|
|
|
|
screen:expect([[
|
|
|
|
tty ready |
|
|
|
|
testing cursor{1: } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-08-09 08:01:56 -07:00
|
|
|
{3:-- TERMINAL --} |
|
2015-03-25 05:14:47 -07:00
|
|
|
]])
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('is highlighted when not focused', function()
|
|
|
|
feed('<c-\\><c-n>')
|
|
|
|
screen:expect([[
|
|
|
|
tty ready |
|
2017-02-26 19:10:55 -07:00
|
|
|
{2:^ } |
|
|
|
|
|
|
2015-03-25 05:14:47 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
]])
|
|
|
|
end)
|
|
|
|
|
|
|
|
describe('with number column', function()
|
|
|
|
before_each(function()
|
|
|
|
feed('<c-\\><c-n>:set number<cr>')
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('is positioned correctly when unfocused', function()
|
|
|
|
screen:expect([[
|
2016-08-09 08:01:56 -07:00
|
|
|
{7: 1 }tty ready |
|
2017-02-26 19:10:55 -07:00
|
|
|
{7: 2 }{2:^ } |
|
2016-08-09 08:01:56 -07:00
|
|
|
{7: 3 } |
|
|
|
|
{7: 4 } |
|
|
|
|
{7: 5 } |
|
2017-02-26 19:10:55 -07:00
|
|
|
{7: 6 } |
|
2015-03-25 05:14:47 -07:00
|
|
|
:set number |
|
|
|
|
]])
|
|
|
|
end)
|
|
|
|
|
2017-03-28 17:13:50 -07:00
|
|
|
it('is positioned correctly when focused', function()
|
2015-03-25 05:14:47 -07:00
|
|
|
feed('i')
|
2017-03-28 17:13:50 -07:00
|
|
|
helpers.wait()
|
2015-03-25 05:14:47 -07:00
|
|
|
screen:expect([[
|
2017-03-28 17:13:50 -07:00
|
|
|
{7: 1 }tty ready |
|
|
|
|
{7: 2 }{1: } |
|
|
|
|
{7: 3 } |
|
|
|
|
{7: 4 } |
|
|
|
|
{7: 5 } |
|
|
|
|
{7: 6 } |
|
|
|
|
{3:-- TERMINAL --} |
|
2015-03-25 05:14:47 -07:00
|
|
|
]])
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
|
|
|
describe('when invisible', function()
|
|
|
|
it('is not highlighted and is detached from screen cursor', function()
|
|
|
|
hide_cursor()
|
|
|
|
screen:expect([[
|
|
|
|
tty ready |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-08-09 08:01:56 -07:00
|
|
|
{3:-- TERMINAL --} |
|
2015-03-25 05:14:47 -07:00
|
|
|
]])
|
|
|
|
show_cursor()
|
|
|
|
screen:expect([[
|
|
|
|
tty ready |
|
|
|
|
{1: } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-08-09 08:01:56 -07:00
|
|
|
{3:-- TERMINAL --} |
|
2015-03-25 05:14:47 -07:00
|
|
|
]])
|
|
|
|
-- same for when the terminal is unfocused
|
|
|
|
feed('<c-\\><c-n>')
|
|
|
|
hide_cursor()
|
|
|
|
screen:expect([[
|
|
|
|
tty ready |
|
2017-02-26 19:10:55 -07:00
|
|
|
^ |
|
2015-03-25 05:14:47 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
]])
|
|
|
|
show_cursor()
|
|
|
|
screen:expect([[
|
|
|
|
tty ready |
|
2017-02-26 19:10:55 -07:00
|
|
|
{2:^ } |
|
|
|
|
|
|
2015-03-25 05:14:47 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
]])
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
|
|
describe('cursor with customized highlighting', function()
|
|
|
|
local screen
|
|
|
|
|
|
|
|
before_each(function()
|
|
|
|
clear()
|
2015-04-08 04:34:27 -07:00
|
|
|
nvim('command', 'highlight TermCursor ctermfg=45 ctermbg=46 cterm=NONE')
|
|
|
|
nvim('command', 'highlight TermCursorNC ctermfg=55 ctermbg=56 cterm=NONE')
|
2015-03-25 05:14:47 -07:00
|
|
|
screen = Screen.new(50, 7)
|
|
|
|
screen:set_default_attr_ids({
|
|
|
|
[1] = {foreground = 45, background = 46},
|
2016-08-09 08:01:56 -07:00
|
|
|
[2] = {foreground = 55, background = 56},
|
|
|
|
[3] = {bold = true},
|
2015-03-25 05:14:47 -07:00
|
|
|
})
|
2016-06-08 02:26:06 -07:00
|
|
|
screen:attach({rgb=false})
|
2017-04-08 14:12:26 -07:00
|
|
|
command('call termopen(["'..nvim_dir..'/tty-test"]) | startinsert')
|
2015-03-25 05:14:47 -07:00
|
|
|
end)
|
|
|
|
|
|
|
|
it('overrides the default highlighting', function()
|
|
|
|
screen:expect([[
|
|
|
|
tty ready |
|
|
|
|
{1: } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-08-09 08:01:56 -07:00
|
|
|
{3:-- TERMINAL --} |
|
2015-03-25 05:14:47 -07:00
|
|
|
]])
|
|
|
|
feed('<c-\\><c-n>')
|
|
|
|
screen:expect([[
|
|
|
|
tty ready |
|
2017-02-26 19:10:55 -07:00
|
|
|
{2:^ } |
|
|
|
|
|
|
2015-03-25 05:14:47 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
]])
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|