diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2015-01-26 19:32:20 +0100 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2015-02-02 14:56:58 -0300 |
commit | f468fb70cb6d82dca5b9a23706b4b6b70a3beab6 (patch) | |
tree | a662a544bf596fe0fb9ccb71aa76df0c581e3c66 /test | |
parent | ae2b747e647c3cab5962861e8c3d047869c25551 (diff) | |
download | rneovim-f468fb70cb6d82dca5b9a23706b4b6b70a3beab6.tar.gz rneovim-f468fb70cb6d82dca5b9a23706b4b6b70a3beab6.tar.bz2 rneovim-f468fb70cb6d82dca5b9a23706b4b6b70a3beab6.zip |
api/vim: allow guis and tests to retrieve the entire color table
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/ui/highlight_spec.lua | 12 | ||||
-rw-r--r-- | test/functional/ui/mouse_spec.lua | 12 | ||||
-rw-r--r-- | test/functional/ui/screen.lua | 22 |
3 files changed, 29 insertions, 17 deletions
diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua index 417c27db04..52ab3cb5bf 100644 --- a/test/functional/ui/highlight_spec.lua +++ b/test/functional/ui/highlight_spec.lua @@ -29,14 +29,12 @@ end) describe('Default highlight groups', function() -- Test the default attributes for highlight groups shown by the :highlight -- command - local screen, hlgroup_colors + local screen - setup(function() - hlgroup_colors = { - NonText = nvim('name_to_color', 'Blue'), - Question = nvim('name_to_color', 'SeaGreen') - } - end) + local hlgroup_colors = { + NonText = Screen.colors.Blue, + Question = Screen.colors.SeaGreen + } before_each(function() clear() diff --git a/test/functional/ui/mouse_spec.lua b/test/functional/ui/mouse_spec.lua index 77e6be45ed..296487fc9c 100644 --- a/test/functional/ui/mouse_spec.lua +++ b/test/functional/ui/mouse_spec.lua @@ -4,14 +4,12 @@ local clear, feed, nvim = helpers.clear, helpers.feed, helpers.nvim local insert, execute = helpers.insert, helpers.execute describe('Mouse input', function() - local screen, hlgroup_colors + local screen - setup(function() - hlgroup_colors = { - NonText = nvim('name_to_color', 'Blue'), - Visual = nvim('name_to_color', 'LightGrey'), - } - end) + local hlgroup_colors = { + NonText = Screen.colors.Blue, + Visual = Screen.colors.LightGrey + } before_each(function() clear() diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua index a70ee4c0a7..cd8c2bc399 100644 --- a/test/functional/ui/screen.lua +++ b/test/functional/ui/screen.lua @@ -65,7 +65,7 @@ -- attribute(which normally is), here's how the call to "expect" should look -- like: -- --- NonText = nvim('name_to_color', 'Blue'), +-- NonText = Screen.colors.Blue -- screen:expect([[ -- hello screen \ -- ~ \ @@ -86,7 +86,7 @@ -- -- Multiple expect:s will likely share a group of attribute sets to test. -- Therefore these could be specified at the beginning of a test like this: --- NonText = nvim('name_to_color', 'Blue') +-- NonText = Screen.colors.Blue -- screen:set_default_attr_ids( { -- [1] = {reverse = true, bold = true}, -- [2] = {reverse = true} @@ -119,6 +119,16 @@ if os.getenv('VALGRIND') then default_screen_timeout = 7500 end +local colors = request('vim_get_color_map') +local colornames = {} +for name, rgb in pairs(colors) do + -- we disregard the case that colornames might not be unique, as + -- this is just a helper to get any canonical name of a color + colornames[rgb] = name +end + +Screen.colors = colors + function Screen.debug(command) if not command then command = 'pynvim -n -g -c ' @@ -479,7 +489,13 @@ end function pprint_attrs(attrs) local items = {} for f, v in pairs(attrs) do - table.insert(items, f.." = "..tostring(v)) + local desc = tostring(v) + if f == "foreground" or f == "background" then + if colornames[v] ~= nil then + desc = "Screen.colors."..colornames[v] + end + end + table.insert(items, f.." = "..desc) end return table.concat(items, ", ") end |