mirror of
https://github.com/neovim/neovim.git
synced 2025-12-01 22:43:03 +00:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user