2015-02-15 06:21:13 -07:00
local Screen = require ( ' test.functional.ui.screen ' )
2016-04-23 16:53:11 -07:00
local helpers = require ( ' test.functional.helpers ' ) ( after_each )
2015-11-17 15:31:22 -07:00
local clear , feed = helpers.clear , helpers.feed
2019-01-08 12:37:35 -07:00
local expect = helpers.expect
2017-04-08 15:43:46 -07:00
local eq = helpers.eq
2020-10-19 11:17:51 -07:00
local poke_eventloop = helpers.poke_eventloop
2017-04-08 15:43:46 -07:00
local exc_exec = helpers.exc_exec
2019-01-08 12:37:35 -07:00
local feed_command = helpers.feed_command
2023-06-10 20:29:39 -07:00
local exec = helpers.exec
2014-11-09 13:54:33 -07:00
2023-06-10 20:29:39 -07:00
before_each ( clear )
2014-11-09 13:54:33 -07:00
2023-06-10 20:29:39 -07:00
describe ( ' :highlight ' , function ( )
2014-11-09 13:54:33 -07:00
it ( ' is working ' , function ( )
2015-02-15 06:21:13 -07:00
local screen = Screen.new ( 35 , 10 )
screen : attach ( )
2014-11-09 13:54:33 -07:00
-- Basic test if ":highlight" doesn't crash
2019-01-08 12:37:35 -07:00
feed_command ( ' set more ' )
2017-04-08 15:43:46 -07:00
feed ( ' :highlight<CR> ' )
2015-02-15 06:21:13 -07:00
-- FIXME(tarruda): We need to be sure the prompt is displayed before
-- continuing, or risk a race condition where some of the following input
-- is discarded resulting in test failure
screen : expect ( [ [
: highlight |
SpecialKey xxx ctermfg = 4 |
guifg = Blue |
EndOfBuffer xxx links to NonText |
|
2015-04-08 04:34:27 -07:00
TermCursor xxx cterm = reverse |
gui = reverse |
TermCursorNC xxx cleared |
2015-02-15 06:21:13 -07:00
NonText xxx ctermfg = 12 |
2015-03-05 02:07:55 -07:00
-- More --^ |
2015-02-15 06:21:13 -07:00
] ] )
feed ( ' q ' )
2020-10-19 11:17:51 -07:00
poke_eventloop ( ) -- wait until we're back to normal
2019-01-08 12:37:35 -07:00
feed_command ( ' hi Search ' )
feed_command ( ' hi Normal ' )
2014-11-09 13:54:33 -07:00
-- Test setting colors.
-- Test clearing one color and all doesn't generate error or warning
2019-01-08 12:37:35 -07:00
feed_command ( ' hi NewGroup cterm=italic ctermfg=DarkBlue ctermbg=Grey gui=NONE guifg=#00ff00 guibg=Cyan ' )
feed_command ( ' hi Group2 cterm=NONE ' )
feed_command ( ' hi Group3 cterm=bold ' )
feed_command ( ' redir! @a ' )
feed_command ( ' hi NewGroup ' )
feed_command ( ' hi Group2 ' )
feed_command ( ' hi Group3 ' )
feed_command ( ' hi clear NewGroup ' )
feed_command ( ' hi NewGroup ' )
feed_command ( ' hi Group2 ' )
feed_command ( ' hi Group2 NONE ' )
feed_command ( ' hi Group2 ' )
feed_command ( ' hi clear ' )
feed_command ( ' hi Group3 ' )
feed ( ' <cr> ' )
2017-04-08 15:43:46 -07:00
eq ( ' Vim(highlight):E475: Invalid argument: cterm= \' asdf ' ,
exc_exec ( [[hi Crash cterm='asdf]] ) )
2019-01-08 12:37:35 -07:00
feed_command ( ' redir END ' )
2014-11-09 13:54:33 -07:00
-- Filter ctermfg and ctermbg, the numbers depend on the terminal
2019-01-08 12:37:35 -07:00
feed_command ( ' 0put a ' )
feed_command ( [[%s/ctermfg=\d*/ctermfg=2/]] )
feed_command ( [[%s/ctermbg=\d*/ctermbg=3/]] )
2014-11-09 13:54:33 -07:00
-- Fix the fileformat
2019-01-08 12:37:35 -07:00
feed_command ( ' set ff& ' )
feed_command ( ' $d ' )
2014-11-09 13:54:33 -07:00
-- Assert buffer contents.
expect ( [ [
2017-04-08 14:12:26 -07:00
2019-01-08 12:37:35 -07:00
2015-02-15 06:21:13 -07:00
NewGroup xxx cterm = italic
ctermfg = 2
ctermbg = 3
guifg =# 00 ff00
guibg = Cyan
2019-01-08 12:37:35 -07:00
2014-11-09 13:54:33 -07:00
Group2 xxx cleared
2019-01-08 12:37:35 -07:00
2015-02-13 08:06:08 -07:00
Group3 xxx cterm = bold
2019-01-08 12:37:35 -07:00
2014-11-09 13:54:33 -07:00
NewGroup xxx cleared
2019-01-08 12:37:35 -07:00
2014-11-09 13:54:33 -07:00
Group2 xxx cleared
2019-01-08 12:37:35 -07:00
2014-11-09 13:54:33 -07:00
Group2 xxx cleared
2019-01-08 12:37:35 -07:00
2017-04-08 15:43:46 -07:00
Group3 xxx cleared ] ] )
2014-11-09 13:54:33 -07:00
end )
end )
2023-06-10 20:29:39 -07:00
describe ( ' Visual selection highlight ' , function ( )
-- oldtest: Test_visual_sbr()
it ( " when 'showbreak' is set " , function ( )
local screen = Screen.new ( 60 , 6 )
screen : set_default_attr_ids ( {
[ 0 ] = { bold = true , foreground = Screen.colors . Blue } , -- NonText
[ 1 ] = { background = Screen.colors . LightGrey } , -- Visual
[ 2 ] = { bold = true } , -- ModeMsg
} )
screen : attach ( )
exec ( [ [
set showbreak =>
call setline ( 1 , ' Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. ' )
exe " normal! z1 \ <CR> "
] ] )
feed ( ' v$ ' )
screen : expect ( [ [
{ 0 : > } { 1 : n , no sea takimata sanctus est Lorem ipsum dolor sit amet . } ^ |
|
|
|
|
{ 2 : -- VISUAL --} |
] ] )
end )
end )