diff options
author | bfredl <bjorn.linse@gmail.com> | 2025-01-03 10:43:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-03 10:43:22 +0100 |
commit | 6aceab7c201f93d96b4359f0e1d97bd6f2f29ea6 (patch) | |
tree | e48d52290f6123315ccf29cd782cc757e1097137 /src/nvim | |
parent | 43d552c56648bc3125c7509b3d708b6bf6c0c09c (diff) | |
parent | e3bfcf2fd4a4ebf00b104b082cfe83c8144a842d (diff) | |
download | rneovim-6aceab7c201f93d96b4359f0e1d97bd6f2f29ea6.tar.gz rneovim-6aceab7c201f93d96b4359f0e1d97bd6f2f29ea6.tar.bz2 rneovim-6aceab7c201f93d96b4359f0e1d97bd6f2f29ea6.zip |
Merge pull request #31635 from bfredl/vtermpirates
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; |