mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-04 04:06:06 -05:00
ime: calculate wchar widths once
This commit is contained in:
parent
4d90b200f1
commit
98bd798dae
1 changed files with 8 additions and 3 deletions
11
ime.c
11
ime.c
|
|
@ -181,8 +181,13 @@ done(void *data, struct zwp_text_input_v3 *zwp_text_input_v3,
|
|||
|
||||
/* Next, count number of cells needed */
|
||||
size_t cell_count = 0;
|
||||
for (size_t i = 0; i < wchars; i++)
|
||||
cell_count += max(wcwidth(wcs[i]), 1);
|
||||
size_t widths[wchars + 1];
|
||||
|
||||
for (size_t i = 0; i < wchars; i++) {
|
||||
int width = max(wcwidth(wcs[i]), 1);
|
||||
widths[i] = width;
|
||||
cell_count += width;
|
||||
}
|
||||
|
||||
/* Allocate cells */
|
||||
term->ime.preedit.cells = xmalloc(
|
||||
|
|
@ -193,7 +198,7 @@ done(void *data, struct zwp_text_input_v3 *zwp_text_input_v3,
|
|||
for (size_t i = 0, cell_idx = 0; i < wchars; i++) {
|
||||
struct cell *cell = &term->ime.preedit.cells[cell_idx];
|
||||
|
||||
int width = max(wcwidth(wcs[i]), 1);
|
||||
int width = widths[i];
|
||||
|
||||
cell->wc = wcs[i];
|
||||
cell->attrs = (struct attributes){.clean = 0, .underline = 1};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue