Increased test coverage for RGB and cterm

This commit is contained in:
Matthieu Coudron
2017-08-27 00:33:36 +02:00
parent ba7277cfb4
commit e3a2cca387
4 changed files with 53 additions and 46 deletions

View File

@@ -78,7 +78,7 @@ Dictionary nvim_get_hl_by_name(String name, Error *err)
/// Retrieves highlight description from its id
///
/// @param hl_id highlight id as returned by hlID()
/// @param hl_id highlight id as returned by |hlID()|
/// @see nvim_get_hl_by_name
Dictionary nvim_get_hl_by_id(Integer hl_id, Error *err)
FUNC_API_SINCE(3)
@@ -89,7 +89,7 @@ Dictionary nvim_get_hl_by_id(Integer hl_id, Error *err)
return dic;
}
int attrcode = syn_id2attr((int)hl_id);
return get_attr_by_id(attrcode, err);
return hl_get_attr_by_id(attrcode, err);
}
/// Passes input keys to Nvim.

View File

@@ -8221,6 +8221,32 @@ RgbValue name_to_color(const uint8_t *name)
return -1;
}
/// Retrieves attribute description from its id
///
/// @param attr_id attribute id
Dictionary hl_get_attr_by_id(Integer attr_id, Error *err)
{
HlAttrs attrs = HLATTRS_INIT;
Dictionary dic = ARRAY_DICT_INIT;
if (attr_id == 0) {
goto end;
}
attrentry_T *aep = syn_cterm_attr2entry((int)attr_id);
if (!aep) {
api_set_error(err, kErrorTypeException,
"Invalid attribute id %d", attr_id);
return dic;
}
attrs = attrentry2hlattrs(aep, p_tgc);
end:
return hlattrs2dict(attrs);
}
/**************************************
* End of Highlighting stuff *
**************************************/

View File

@@ -166,31 +166,6 @@ void ui_event(char *name, Array args)
}
}
/// Retrieves attribute description from its id
///
/// @param attr_id attribute id
Dictionary get_attr_by_id(Integer attr_id, Error *err)
{
HlAttrs attrs = HLATTRS_INIT;
Dictionary dic = ARRAY_DICT_INIT;
if (attr_id == 0) {
goto end;
}
attrentry_T *aep = syn_cterm_attr2entry((int)attr_id);
if (!aep) {
api_set_error(err, kErrorTypeException,
"Invalid attribute id %d", attr_id);
return dic;
}
attrs = attrentry2hlattrs(aep, p_tgc);
end:
return hlattrs2dict(attrs);
}
/// Converts an attrentry_T into an HlAttrs
///