diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2020-12-06 11:17:52 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2020-12-07 19:44:14 +0000 |
| commit | 194fbff883e605a3a9afac4ecc66c6cf3cc6b7fa (patch) | |
| tree | 6d0102aa088c9ff4218e01e93e2a9dccb0aaa02a /ime.c | |
| parent | render: search: don’t access term->search.buf[] directly (diff) | |
ime: store wchar version of pre-edit string in terminal struct
Diffstat (limited to 'ime.c')
| -rw-r--r-- | ime.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -150,15 +150,16 @@ done(void *data, struct zwp_text_input_v3 *zwp_text_input_v3, if (wchars > 0) { /* First, convert to unicode */ - wchar_t wcs[wchars + 1]; - mbstowcs(wcs, seat->ime.preedit.pending.text, wchars); + term->ime.preedit.text = xmalloc((wchars + 1) * sizeof(wchar_t)); + mbstowcs(term->ime.preedit.text, seat->ime.preedit.pending.text, wchars); + term->ime.preedit.text[wchars] = L'\0'; /* Next, count number of cells needed */ size_t cell_count = 0; size_t widths[wchars + 1]; for (size_t i = 0; i < wchars; i++) { - int width = max(wcwidth(wcs[i]), 1); + int width = max(wcwidth(term->ime.preedit.text[i]), 1); widths[i] = width; cell_count += width; } @@ -174,7 +175,7 @@ done(void *data, struct zwp_text_input_v3 *zwp_text_input_v3, int width = widths[i]; - cell->wc = wcs[i]; + cell->wc = term->ime.preedit.text[i]; cell->attrs = (struct attributes){.clean = 0, .underline = 1}; for (int j = 1; j < width; j++) { |
