highlight: refactor to use stateful representation

This allows us to keep track of the source higlight groups,
and not only the final combined highlights.
This commit is contained in:
Björn Linse
2018-04-08 09:51:22 +02:00
parent 696e24f311
commit 989b585e10
16 changed files with 326 additions and 164 deletions

View File

@@ -1851,3 +1851,22 @@ Object nvim_get_proc(Integer pid, Error *err)
#endif
return rvobj;
}
/// NB: if your UI doesn't use hlstate, this will not return hlstate first time
Array nvim__inspect_cell(Integer row, Integer col, Error *err)
{
Array ret = ARRAY_DICT_INIT;
if (row < 0 || row >= screen_Rows
|| col < 0 || col >= screen_Columns) {
return ret;
}
size_t off = LineOffset[(size_t)row] + (size_t)col;
ADD(ret, STRING_OBJ(cstr_to_string((char *)ScreenLines[off])));
int attr = ScreenAttrs[off];
ADD(ret, DICTIONARY_OBJ(hl_get_attr_by_id(attr, true, err)));
// will not work first time
if (!highlight_use_hlstate()) {
ADD(ret, ARRAY_OBJ(hl_inspect(attr)));
}
return ret;
}