diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2021-01-25 09:00:43 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2021-01-26 19:46:50 +0000 |
| commit | f9a43209f2481cf31fe39c08fdfa7ce27cbfcab2 (patch) | |
| tree | 68651a3b25ba3c6257949d450687d5e4f42a16f3 | |
| parent | changelog: high cpu usage while holding down e.g. arrow keys in search mode (diff) | |
search: ad-hoc workaround for combining characters with positive x-offsets
When rendering the search input box, do the same ad-hoc workaround for
combining characters with a positive x-offset as we do when rendering
normal grid cells.
In this case, we don’t *know* when we’re dealing with combining
characters. But we can detect zero-width characters. For these, check
their glyph’s x-offset. If positive, adjust it like we do when
rendering combining glyphs in the main grid, to ensure the glyph is
positioned over the _previous_ character, not the next.
| -rw-r--r-- | CHANGELOG.md | 1 | ||||
| -rw-r--r-- | render.c | 10 |
2 files changed, 9 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 4bf9f586..7e20731e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -61,6 +61,7 @@ * Scrollback search not matching composed characters. * High CPU usage when holding down e.g. arrow keys while in scrollback search mode. +* Rendering of composed characters in the scrollback search box. ### Security @@ -2212,7 +2212,7 @@ render_search_box(struct terminal *term) /* Calculate the width of each character */ int widths[text_len + 1]; for (size_t i = 0; i < text_len; i++) - widths[i] = max(1, wcwidth(text[i])); + widths[i] = max(0, wcwidth(text[i])); widths[text_len] = 0; const size_t total_cells = wcswidth(text, text_len); @@ -2403,10 +2403,16 @@ render_search_box(struct terminal *term) x + glyph->x, y + font_baseline(term) - glyph->y, glyph->width, glyph->height); } else { + int combining_ofs = width == 0 + ? (glyph->x < 0 + ? width * term->cell_width + : (width - 1) * term->cell_width) + : 0; /* Not a zero-width character - no additional offset */ pixman_image_t *src = pixman_image_create_solid_fill(&fg); pixman_image_composite32( PIXMAN_OP_OVER, src, glyph->pix, buf->pix[0], 0, 0, 0, 0, - x + glyph->x, y + font_baseline(term) - glyph->y, + x + combining_ofs + glyph->x, + y + font_baseline(term) - glyph->y, glyph->width, glyph->height); pixman_image_unref(src); } |
