feat(decoration): allow conceal_char to be a composing char

decor->text.str pointer must go. This removes it for conceal char,
in preparation for a larger PR which will also handle the sign case.

By actually allowing composing chars for a conceal chars, this
becomes a feature and not just a refactor, as a bonus.
This commit is contained in:
bfredl
2023-11-26 21:07:29 +01:00
parent 6c14ae6bfa
commit ae3685798d
12 changed files with 103 additions and 69 deletions

View File

@@ -18,7 +18,7 @@
#include "nvim/arabic.h"
#include "nvim/ascii.h"
#include "nvim/buffer_defs.h"
#include "nvim/drawscreen.h"
#include "nvim/decoration.h"
#include "nvim/globals.h"
#include "nvim/grid.h"
#include "nvim/highlight.h"
@@ -111,18 +111,16 @@ bool schar_cache_clear_if_full(void)
// note: critical max is really (1<<24)-1. This gives us some marginal
// until next time update_screen() is called
if (glyph_cache.h.n_keys > (1<<21)) {
set_clear(glyph, &glyph_cache);
schar_cache_clear();
return true;
}
return false;
}
/// For testing. The condition in schar_cache_clear_force is hard to
/// reach, so this function can be used to force a cache clear in a test.
void schar_cache_clear_force(void)
void schar_cache_clear(void)
{
decor_check_invalid_glyphs();
set_clear(glyph, &glyph_cache);
must_redraw = UPD_CLEAR;
}
bool schar_high(schar_T sc)
@@ -159,6 +157,13 @@ static char schar_get_first_byte(schar_T sc)
return schar_high(sc) ? glyph_cache.keys[schar_idx(sc)] : *(char *)&sc;
}
int schar_get_first_codepoint(schar_T sc)
{
char sc_buf[MAX_SCHAR_SIZE];
schar_get(sc_buf, sc);
return utf_ptr2char(sc_buf);
}
/// @return ascii char or NUL if not ascii
char schar_get_ascii(schar_T sc)
{