mirror of
https://github.com/neovim/neovim.git
synced 2025-09-25 04:28:33 +00:00
feat(decorations): support signs
Add the following options to extmarks: - sign_text - sign_hl_group - number_hl_group - line_hl_group - cursorline_hl_group Note: ranges are unsupported and decorations are only applied to start_row
This commit is contained in:
@@ -1643,3 +1643,39 @@ sctx_T api_set_sctx(uint64_t channel_id)
|
||||
}
|
||||
return old_current_sctx;
|
||||
}
|
||||
|
||||
// adapted from sign.c:sign_define_init_text.
|
||||
// TODO(lewis6991): Consider merging
|
||||
int init_sign_text(char_u **sign_text, char_u *text)
|
||||
{
|
||||
char_u *s;
|
||||
|
||||
char_u *endp = text + (int)STRLEN(text);
|
||||
|
||||
// Count cells and check for non-printable chars
|
||||
int cells = 0;
|
||||
for (s = text; s < endp; s += utfc_ptr2len(s)) {
|
||||
if (!vim_isprintc(utf_ptr2char(s))) {
|
||||
break;
|
||||
}
|
||||
cells += utf_ptr2cells(s);
|
||||
}
|
||||
// Currently must be empty, one or two display cells
|
||||
if (s != endp || cells > 2) {
|
||||
return FAIL;
|
||||
}
|
||||
if (cells < 1) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
// Allocate one byte more if we need to pad up
|
||||
// with a space.
|
||||
size_t len = (size_t)(endp - text + ((cells == 1) ? 1 : 0));
|
||||
*sign_text = vim_strnsave(text, len);
|
||||
|
||||
if (cells == 1) {
|
||||
STRCPY(*sign_text + len - 1, " ");
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
Reference in New Issue
Block a user