mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-21 05:33:45 -04:00
cell: we only need 4 bytes for the longest utf8 sequence
We don't *have* to NULL-terminate the utf8 string. So don't. This makes the cell glyph 4 bytes exactly, which is better for alignment and cache usage.
This commit is contained in:
parent
cf71534768
commit
b1f8dd75d6
3 changed files with 3 additions and 3 deletions
2
render.c
2
render.c
|
|
@ -101,7 +101,7 @@ render_cell(struct terminal *term, struct buffer *buf, const struct cell *cell,
|
||||||
|
|
||||||
cairo_status_t status = cairo_scaled_font_text_to_glyphs(
|
cairo_status_t status = cairo_scaled_font_text_to_glyphs(
|
||||||
attrs_to_font(term, &cell->attrs), x, y + term->fextents.ascent,
|
attrs_to_font(term, &cell->attrs), x, y + term->fextents.ascent,
|
||||||
cell->c, strlen(cell->c), &gseq.g, &new_glyphs,
|
cell->c, strnlen(cell->c, 4), &gseq.g, &new_glyphs,
|
||||||
NULL, NULL, NULL);
|
NULL, NULL, NULL);
|
||||||
|
|
||||||
if (status != CAIRO_STATUS_SUCCESS)
|
if (status != CAIRO_STATUS_SUCCESS)
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ struct attributes {
|
||||||
|
|
||||||
struct cell {
|
struct cell {
|
||||||
struct attributes attrs;
|
struct attributes attrs;
|
||||||
char c[5];
|
char c[4];
|
||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
|
|
||||||
struct scroll_region {
|
struct scroll_region {
|
||||||
|
|
|
||||||
2
vt.c
2
vt.c
|
|
@ -757,7 +757,7 @@ action_print(struct terminal *term, uint8_t c)
|
||||||
if (unlikely(term->charset[term->selected_charset] == CHARSET_GRAPHIC) &&
|
if (unlikely(term->charset[term->selected_charset] == CHARSET_GRAPHIC) &&
|
||||||
c >= 0x41 && c <= 0x7e)
|
c >= 0x41 && c <= 0x7e)
|
||||||
{
|
{
|
||||||
strcpy(cell->c, vt100_0[c - 0x41]);
|
strncpy(cell->c, vt100_0[c - 0x41], sizeof(cell->c));
|
||||||
} else {
|
} else {
|
||||||
//LOG_DBG("print: ASCII: %c", c);
|
//LOG_DBG("print: ASCII: %c", c);
|
||||||
cell->c[0] = c;
|
cell->c[0] = c;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue