mirror of
https://github.com/neovim/neovim.git
synced 2025-09-28 05:58:33 +00:00
refactor(grid): make screen rendering more multibyte than ever before
Problem: buffer text with composing chars are converted from UTF-8 to an array of up to seven UTF-32 values and then converted back to UTF-8 strings. Solution: Convert buffer text directly to UTF-8 based schar_T values. The limit of the text size is now in schar_T bytes, which is currently 31+1 but easily could be raised as it no longer multiplies the size of the entire screen grid when not used, the full size is only required for temporary scratch buffers. Also does some general cleanup to win_line text handling, which was unnecessarily complicated due to multibyte rendering being an "opt-in" feature long ago. Nowadays, a char is just a char, regardless if it consists of one ASCII byte or multiple bytes.
This commit is contained in:
@@ -139,7 +139,7 @@ static int msg_grid_pos_at_flush = 0;
|
||||
|
||||
static void ui_ext_msg_set_pos(int row, bool scrolled)
|
||||
{
|
||||
char buf[MAX_MCO + 1];
|
||||
char buf[MB_MAXCHAR + 1];
|
||||
size_t size = (size_t)utf_char2bytes(curwin->w_p_fcs_chars.msgsep, buf);
|
||||
buf[size] = '\0';
|
||||
ui_call_msg_set_pos(msg_grid.handle, row, scrolled,
|
||||
@@ -1471,7 +1471,7 @@ void msg_putchar(int c)
|
||||
|
||||
void msg_putchar_attr(int c, int attr)
|
||||
{
|
||||
char buf[MB_MAXBYTES + 1];
|
||||
char buf[MB_MAXCHAR + 1];
|
||||
|
||||
if (IS_SPECIAL(c)) {
|
||||
buf[0] = (char)K_SPECIAL;
|
||||
@@ -1560,12 +1560,6 @@ int msg_outtrans_len(const char *msgstr, int len, int attr)
|
||||
mode_displayed = false;
|
||||
}
|
||||
|
||||
// If the string starts with a composing character first draw a space on
|
||||
// which the composing char can be drawn.
|
||||
if (utf_iscomposing(utf_ptr2char(msgstr))) {
|
||||
msg_puts_attr(" ", attr);
|
||||
}
|
||||
|
||||
// Go over the string. Special characters are translated and printed.
|
||||
// Normal characters are printed several at a time.
|
||||
while (--len >= 0 && !got_int) {
|
||||
|
Reference in New Issue
Block a user