diff options
| author | bfredl <bjorn.linse@gmail.com> | 2024-12-18 14:49:38 +0100 |
|---|---|---|
| committer | bfredl <bjorn.linse@gmail.com> | 2025-01-02 12:55:11 +0100 |
| commit | e3bfcf2fd4a4ebf00b104b082cfe83c8144a842d (patch) | |
| tree | 8c4e09f0995db6668e13b3508b112779bea1312d /src/nvim | |
| parent | 9d9ee3476e6478850ce8822c85154f0c98570371 (diff) | |
| download | rneovim-e3bfcf2fd4a4ebf00b104b082cfe83c8144a842d.tar.gz rneovim-e3bfcf2fd4a4ebf00b104b082cfe83c8144a842d.tar.bz2 rneovim-e3bfcf2fd4a4ebf00b104b082cfe83c8144a842d.zip | |
feat(terminal): support grapheme clusters, including emoji
Diffstat (limited to 'src/nvim')
| -rw-r--r-- | src/nvim/terminal.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c index 673a6ef4be..0743eda374 100644 --- a/src/nvim/terminal.c +++ b/src/nvim/terminal.c @@ -65,6 +65,7 @@ #include "nvim/ex_docmd.h" #include "nvim/getchar.h" #include "nvim/globals.h" +#include "nvim/grid.h" #include "nvim/highlight.h" #include "nvim/highlight_defs.h" #include "nvim/highlight_group.h" @@ -1347,7 +1348,7 @@ static int term_sb_pop(int cols, VTermScreenCell *cells, void *data) // copy to vterm state memcpy(cells, sbrow->cells, sizeof(cells[0]) * cols_to_copy); for (size_t col = cols_to_copy; col < (size_t)cols; col++) { - cells[col].chars[0] = 0; + cells[col].schar = 0; cells[col].width = 1; } @@ -1857,12 +1858,8 @@ static void fetch_row(Terminal *term, int row, int end_col) while (col < end_col) { VTermScreenCell cell; fetch_cell(term, row, col, &cell); - if (cell.chars[0]) { - int cell_len = 0; - for (int i = 0; i < VTERM_MAX_CHARS_PER_CELL && cell.chars[i]; i++) { - cell_len += utf_char2bytes((int)cell.chars[i], ptr + cell_len); - } - ptr += cell_len; + if (cell.schar) { + schar_get_adv(&ptr, cell.schar); line_len = (size_t)(ptr - term->textbuf); } else { *ptr++ = ' '; @@ -1883,7 +1880,7 @@ static bool fetch_cell(Terminal *term, int row, int col, VTermScreenCell *cell) } else { // fill the pointer with an empty cell *cell = (VTermScreenCell) { - .chars = { 0 }, + .schar = 0, .width = 1, }; return false; |