mirror of
https://github.com/neovim/neovim.git
synced 2025-10-10 03:46:31 +00:00
test/screen: make snapshot_util() work properly in rgb_cterm mode
This commit is contained in:
@@ -1362,6 +1362,7 @@ function Screen:linegrid_check_attrs(attrs)
|
|||||||
if self._rgb_cterm then
|
if self._rgb_cterm then
|
||||||
attr_rgb, attr_cterm, info = unpack(v)
|
attr_rgb, attr_cterm, info = unpack(v)
|
||||||
attr = {attr_rgb, attr_cterm}
|
attr = {attr_rgb, attr_cterm}
|
||||||
|
info = info or {}
|
||||||
elseif self._options.ext_hlstate then
|
elseif self._options.ext_hlstate then
|
||||||
attr, info = unpack(v)
|
attr, info = unpack(v)
|
||||||
else
|
else
|
||||||
@@ -1400,11 +1401,12 @@ end
|
|||||||
function Screen:_pprint_hlitem(item)
|
function Screen:_pprint_hlitem(item)
|
||||||
-- print(inspect(item))
|
-- print(inspect(item))
|
||||||
local multi = self._rgb_cterm or self._options.ext_hlstate
|
local multi = self._rgb_cterm or self._options.ext_hlstate
|
||||||
local attrdict = "{"..self:_pprint_attrs(multi and item[1] or item).."}"
|
local cterm = (not self._rgb_cterm and not self._options.rgb)
|
||||||
|
local attrdict = "{"..self:_pprint_attrs(multi and item[1] or item, cterm).."}"
|
||||||
local attrdict2, hlinfo
|
local attrdict2, hlinfo
|
||||||
local descdict = ""
|
local descdict = ""
|
||||||
if self._rgb_cterm then
|
if self._rgb_cterm then
|
||||||
attrdict2 = ", {"..self:_pprint_attrs(item[2]).."}"
|
attrdict2 = ", {"..self:_pprint_attrs(item[2], true).."}"
|
||||||
hlinfo = item[3]
|
hlinfo = item[3]
|
||||||
else
|
else
|
||||||
attrdict2 = ""
|
attrdict2 = ""
|
||||||
@@ -1433,13 +1435,15 @@ function Screen:_pprint_hlinfo(states)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function Screen:_pprint_attrs(attrs)
|
function Screen:_pprint_attrs(attrs, cterm)
|
||||||
local items = {}
|
local items = {}
|
||||||
for f, v in pairs(attrs) do
|
for f, v in pairs(attrs) do
|
||||||
local desc = tostring(v)
|
local desc = tostring(v)
|
||||||
if f == "foreground" or f == "background" or f == "special" then
|
if f == "foreground" or f == "background" or f == "special" then
|
||||||
if Screen.colornames[v] ~= nil then
|
if Screen.colornames[v] ~= nil then
|
||||||
desc = "Screen.colors."..Screen.colornames[v]
|
desc = "Screen.colors."..Screen.colornames[v]
|
||||||
|
elseif cterm then
|
||||||
|
desc = tostring(v)
|
||||||
else
|
else
|
||||||
desc = string.format("tonumber('0x%06x')",v)
|
desc = string.format("tonumber('0x%06x')",v)
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user