diff options
Diffstat (limited to 'test/functional/terminal/highlight_spec.lua')
-rw-r--r-- | test/functional/terminal/highlight_spec.lua | 124 |
1 files changed, 85 insertions, 39 deletions
diff --git a/test/functional/terminal/highlight_spec.lua b/test/functional/terminal/highlight_spec.lua index 8d7c7451d3..377f335c5c 100644 --- a/test/functional/terminal/highlight_spec.lua +++ b/test/functional/terminal/highlight_spec.lua @@ -5,6 +5,7 @@ local feed, clear, nvim = helpers.feed, helpers.clear, helpers.nvim local nvim_dir, execute = helpers.nvim_dir, helpers.execute local eq, eval = helpers.eq, helpers.eval +if helpers.pending_win32(pending) then return end describe('terminal window highlighting', function() local screen @@ -16,33 +17,32 @@ describe('terminal window highlighting', function() [1] = {foreground = 45}, [2] = {background = 46}, [3] = {foreground = 45, background = 46}, - [4] = {bold = true, italic = true, underline = true} - }) - screen:set_default_attr_ignore({ - [1] = {bold = true}, - [2] = {foreground = 12}, - [3] = {bold = true, reverse = true}, - [5] = {background = 11}, - [6] = {foreground = 130}, - [7] = {reverse = true}, + [4] = {bold = true, italic = true, underline = true}, + [5] = {bold = true}, + [6] = {foreground = 12}, + [7] = {bold = true, reverse = true}, [8] = {background = 11}, + [9] = {foreground = 130}, + [10] = {reverse = true}, + [11] = {background = 11}, }) - screen:attach(false) + screen:attach({rgb=false}) execute('enew | call termopen(["'..nvim_dir..'/tty-test"]) | startinsert') screen:expect([[ tty ready | + {10: } | | | | | - | - -- TERMINAL -- | + {5:-- TERMINAL --} | ]]) end) local function descr(title, attr_num, set_attrs_fn) local function sub(s) - return s:gsub('NUM', attr_num) + local str = s:gsub('NUM', attr_num) + return str end describe(title, function() @@ -54,16 +54,15 @@ describe('terminal window highlighting', function() end) local function pass_attrs() - local s = sub([[ + screen:expect(sub([[ tty ready | - {NUM:text}text | + {NUM:text}text{10: } | | | | | - -- TERMINAL -- | - ]]) - screen:expect(s) + {5:-- TERMINAL --} | + ]])) end it('will pass the corresponding attributes', pass_attrs) @@ -82,11 +81,11 @@ describe('terminal window highlighting', function() line6 | line7 | line8 | - | - -- TERMINAL -- | + {10: } | + {5:-- TERMINAL --} | ]]) feed('<c-\\><c-n>gg') - local s = sub([[ + screen:expect(sub([[ ^tty ready | {NUM:text}textline1 | line2 | @@ -94,8 +93,7 @@ describe('terminal window highlighting', function() line4 | line5 | | - ]]) - screen:expect(s) + ]])) end) end) end @@ -121,28 +119,26 @@ describe('terminal window highlighting with custom palette', function() clear() screen = Screen.new(50, 7) screen:set_default_attr_ids({ - [1] = {foreground = 1193046, special = Screen.colors.Black} - }) - screen:set_default_attr_ignore({ - [1] = {bold = true}, + [1] = {foreground = 1193046, special = Screen.colors.Black}, [2] = {foreground = 12}, [3] = {bold = true, reverse = true}, [5] = {background = 11}, [6] = {foreground = 130}, [7] = {reverse = true}, [8] = {background = 11}, + [9] = {bold = true}, }) - screen:attach(true) + screen:attach({rgb=true}) nvim('set_var', 'terminal_color_3', '#123456') execute('enew | call termopen(["'..nvim_dir..'/tty-test"]) | startinsert') screen:expect([[ tty ready | + {7: } | | | | | - | - -- TERMINAL -- | + {9:-- TERMINAL --} | ]]) end) @@ -153,12 +149,12 @@ describe('terminal window highlighting with custom palette', function() thelpers.feed_data('text') screen:expect([[ tty ready | - {1:text}text | + {1:text}text{7: } | | | | | - -- TERMINAL -- | + {9:-- TERMINAL --} | ]]) end) end) @@ -176,8 +172,8 @@ describe('synIDattr()', function() it('returns cterm-color if RGB-capable UI is _not_ attached', function() eq('252', eval('synIDattr(hlID("Normal"), "fg")')) eq('252', eval('synIDattr(hlID("Normal"), "fg#")')) - eq('-1', eval('synIDattr(hlID("Normal"), "bg")')) - eq('-1', eval('synIDattr(hlID("Normal"), "bg#")')) + eq('', eval('synIDattr(hlID("Normal"), "bg")')) + eq('', eval('synIDattr(hlID("Normal"), "bg#")')) eq('79', eval('synIDattr(hlID("Keyword"), "fg")')) eq('79', eval('synIDattr(hlID("Keyword"), "fg#")')) eq('', eval('synIDattr(hlID("Keyword"), "sp")')) @@ -190,7 +186,7 @@ describe('synIDattr()', function() end) it('returns gui-color if RGB-capable UI is attached', function() - screen:attach(true) + screen:attach({rgb=true}) eq('#ff0000', eval('synIDattr(hlID("Normal"), "fg")')) eq('Black', eval('synIDattr(hlID("Normal"), "bg")')) eq('Salmon', eval('synIDattr(hlID("Keyword"), "fg")')) @@ -198,16 +194,66 @@ describe('synIDattr()', function() end) it('returns #RRGGBB value for fg#/bg#/sp#', function() - screen:attach(true) - eq('#ff0000', eval('synIDattr(hlID("Normal"), "fg#")')) - eq('#000000', eval('synIDattr(hlID("Normal"), "bg#")')) + screen:attach({rgb=true}) + eq('#ff0000', eval('synIDattr(hlID("Normal"), "fg#")')) + eq('#000000', eval('synIDattr(hlID("Normal"), "bg#")')) eq('#fa8072', eval('synIDattr(hlID("Keyword"), "fg#")')) eq('#800000', eval('synIDattr(hlID("Keyword"), "sp#")')) end) it('returns color number if non-GUI', function() - screen:attach(false) + screen:attach({rgb=false}) eq('252', eval('synIDattr(hlID("Normal"), "fg")')) eq('79', eval('synIDattr(hlID("Keyword"), "fg")')) end) end) + +describe('fg/bg special colors', function() + local screen + before_each(function() + clear() + screen = Screen.new(50, 7) + execute('highlight Normal ctermfg=145 ctermbg=16 guifg=#ff0000 guibg=Black') + execute('highlight Visual ctermfg=bg ctermbg=fg guifg=bg guibg=fg guisp=bg') + end) + + it('resolve to "Normal" values', function() + eq(eval('synIDattr(hlID("Normal"), "bg")'), + eval('synIDattr(hlID("Visual"), "fg")')) + eq(eval('synIDattr(hlID("Normal"), "bg#")'), + eval('synIDattr(hlID("Visual"), "fg#")')) + eq(eval('synIDattr(hlID("Normal"), "fg")'), + eval('synIDattr(hlID("Visual"), "bg")')) + eq(eval('synIDattr(hlID("Normal"), "fg#")'), + eval('synIDattr(hlID("Visual"), "bg#")')) + eq('bg', eval('synIDattr(hlID("Visual"), "fg", "gui")')) + eq('bg', eval('synIDattr(hlID("Visual"), "fg#", "gui")')) + eq('fg', eval('synIDattr(hlID("Visual"), "bg", "gui")')) + eq('fg', eval('synIDattr(hlID("Visual"), "bg#", "gui")')) + eq('bg', eval('synIDattr(hlID("Visual"), "sp", "gui")')) + eq('bg', eval('synIDattr(hlID("Visual"), "sp#", "gui")')) + end) + + it('resolve to "Normal" values in RGB-capable UI', function() + screen:attach({rgb=true}) + eq('bg', eval('synIDattr(hlID("Visual"), "fg")')) + eq(eval('synIDattr(hlID("Normal"), "bg#")'), + eval('synIDattr(hlID("Visual"), "fg#")')) + eq('fg', eval('synIDattr(hlID("Visual"), "bg")')) + eq(eval('synIDattr(hlID("Normal"), "fg#")'), + eval('synIDattr(hlID("Visual"), "bg#")')) + eq('bg', eval('synIDattr(hlID("Visual"), "sp")')) + eq(eval('synIDattr(hlID("Normal"), "bg#")'), + eval('synIDattr(hlID("Visual"), "sp#")')) + end) + + it('resolve after the "Normal" group is modified', function() + screen:attach({rgb=true}) + local new_guibg = '#282c34' + local new_guifg = '#abb2bf' + execute('highlight Normal guifg='..new_guifg..' guibg='..new_guibg) + eq(new_guibg, eval('synIDattr(hlID("Visual"), "fg#")')) + eq(new_guifg, eval('synIDattr(hlID("Visual"), "bg#")')) + eq(new_guibg, eval('synIDattr(hlID("Visual"), "sp#")')) + end) +end) |