mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-07 08:21:02 -04:00
unicode-combining: completely remove unicode combining characters when feature is disabled
This commit is contained in:
parent
66e5abdda3
commit
3474624c2c
5 changed files with 26 additions and 2 deletions
8
grid.c
8
grid.c
|
|
@ -34,12 +34,16 @@ grid_row_alloc(int cols, bool initialize)
|
||||||
|
|
||||||
if (initialize) {
|
if (initialize) {
|
||||||
row->cells = calloc(cols, sizeof(row->cells[0]));
|
row->cells = calloc(cols, sizeof(row->cells[0]));
|
||||||
|
#if FOOT_UNICODE_COMBINING
|
||||||
row->comb_chars = calloc(cols, sizeof(row->comb_chars[0]));
|
row->comb_chars = calloc(cols, sizeof(row->comb_chars[0]));
|
||||||
|
#endif
|
||||||
for (size_t c = 0; c < cols; c++)
|
for (size_t c = 0; c < cols; c++)
|
||||||
row->cells[c].attrs.clean = 1;
|
row->cells[c].attrs.clean = 1;
|
||||||
} else {
|
} else {
|
||||||
row->cells = malloc(cols * sizeof(row->cells[0]));
|
row->cells = malloc(cols * sizeof(row->cells[0]));
|
||||||
|
#if FOOT_UNICODE_COMBINING
|
||||||
row->comb_chars = malloc(cols * sizeof(row->comb_chars[0]));
|
row->comb_chars = malloc(cols * sizeof(row->comb_chars[0]));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return row;
|
return row;
|
||||||
|
|
@ -51,7 +55,9 @@ grid_row_free(struct row *row)
|
||||||
if (row == NULL)
|
if (row == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
#if FOOT_UNICODE_COMBINING
|
||||||
free(row->comb_chars);
|
free(row->comb_chars);
|
||||||
|
#endif
|
||||||
free(row->cells);
|
free(row->cells);
|
||||||
free(row);
|
free(row);
|
||||||
}
|
}
|
||||||
|
|
@ -208,6 +214,7 @@ grid_reflow(struct grid *grid, int new_rows, int new_cols,
|
||||||
new_row->cells[new_col_idx] = *old_cell;
|
new_row->cells[new_col_idx] = *old_cell;
|
||||||
new_row->cells[new_col_idx].attrs.clean = 1;
|
new_row->cells[new_col_idx].attrs.clean = 1;
|
||||||
|
|
||||||
|
#if FOOT_UNICODE_COMBINING
|
||||||
struct combining_chars *old_comb_chars
|
struct combining_chars *old_comb_chars
|
||||||
= &old_row->comb_chars[c - empty_count + i];
|
= &old_row->comb_chars[c - empty_count + i];
|
||||||
struct combining_chars *new_comb_chars
|
struct combining_chars *new_comb_chars
|
||||||
|
|
@ -216,6 +223,7 @@ grid_reflow(struct grid *grid, int new_rows, int new_cols,
|
||||||
new_comb_chars->count = old_comb_chars->count;
|
new_comb_chars->count = old_comb_chars->count;
|
||||||
for (size_t j = 0; j < ALEN(new_comb_chars->chars); j++)
|
for (size_t j = 0; j < ALEN(new_comb_chars->chars); j++)
|
||||||
new_comb_chars->chars[j] = old_comb_chars->chars[j];
|
new_comb_chars->chars[j] = old_comb_chars->chars[j];
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Translate tracking point(s) */
|
/* Translate tracking point(s) */
|
||||||
if (is_tracking_point && i >= empty_count) {
|
if (is_tracking_point && i >= empty_count) {
|
||||||
|
|
|
||||||
2
render.c
2
render.c
|
|
@ -442,6 +442,7 @@ render_cell(struct terminal *term, pixman_image_t *pix,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if FOOT_UNICODE_COMBINING
|
||||||
/* Combining characters */
|
/* Combining characters */
|
||||||
const struct combining_chars *comb_chars = &row->comb_chars[col];
|
const struct combining_chars *comb_chars = &row->comb_chars[col];
|
||||||
for (size_t i = 0; i < comb_chars->count; i++) {
|
for (size_t i = 0; i < comb_chars->count; i++) {
|
||||||
|
|
@ -461,6 +462,7 @@ render_cell(struct terminal *term, pixman_image_t *pix,
|
||||||
g->width, g->height);
|
g->width, g->height);
|
||||||
pixman_image_unref(src);
|
pixman_image_unref(src);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Underline */
|
/* Underline */
|
||||||
if (cell->attrs.underline) {
|
if (cell->attrs.underline) {
|
||||||
|
|
|
||||||
10
selection.c
10
selection.c
|
|
@ -142,8 +142,12 @@ min_bufsize_for_extraction(const struct terminal *term)
|
||||||
{
|
{
|
||||||
const struct coord *start = &term->selection.start;
|
const struct coord *start = &term->selection.start;
|
||||||
const struct coord *end = &term->selection.end;
|
const struct coord *end = &term->selection.end;
|
||||||
const size_t chars_per_cell
|
const size_t chars_per_cell =
|
||||||
= 1 + ALEN(term->grid->cur_row->comb_chars[0].chars);
|
#if FOOT_UNICODE_COMBINING
|
||||||
|
1 + ALEN(term->grid->cur_row->comb_chars[0].chars);
|
||||||
|
#else
|
||||||
|
1;
|
||||||
|
#endif
|
||||||
|
|
||||||
switch (term->selection.kind) {
|
switch (term->selection.kind) {
|
||||||
case SELECTION_NONE:
|
case SELECTION_NONE:
|
||||||
|
|
@ -237,12 +241,14 @@ extract_one(struct terminal *term, struct row *row, struct cell *cell,
|
||||||
assert(ctx->idx + 1 <= ctx->size);
|
assert(ctx->idx + 1 <= ctx->size);
|
||||||
ctx->buf[ctx->idx++] = cell->wc;
|
ctx->buf[ctx->idx++] = cell->wc;
|
||||||
|
|
||||||
|
#if FOOT_UNICODE_COMBINING
|
||||||
const struct combining_chars *comb_chars = &row->comb_chars[col];
|
const struct combining_chars *comb_chars = &row->comb_chars[col];
|
||||||
|
|
||||||
assert(cell->wc != 0);
|
assert(cell->wc != 0);
|
||||||
assert(ctx->idx + comb_chars->count <= ctx->size);
|
assert(ctx->idx + comb_chars->count <= ctx->size);
|
||||||
for (size_t i = 0; i < comb_chars->count; i++)
|
for (size_t i = 0; i < comb_chars->count; i++)
|
||||||
ctx->buf[ctx->idx++] = comb_chars->chars[i];
|
ctx->buf[ctx->idx++] = comb_chars->chars[i];
|
||||||
|
#endif
|
||||||
|
|
||||||
ctx->last_row = row;
|
ctx->last_row = row;
|
||||||
ctx->last_cell = cell;
|
ctx->last_cell = cell;
|
||||||
|
|
|
||||||
|
|
@ -2295,7 +2295,10 @@ term_print(struct terminal *term, wchar_t wc, int width)
|
||||||
cell->wc = term->vt.last_printed = wc;
|
cell->wc = term->vt.last_printed = wc;
|
||||||
cell->attrs = term->vt.attrs;
|
cell->attrs = term->vt.attrs;
|
||||||
|
|
||||||
|
#if FOOT_UNICODE_COMBINING
|
||||||
row->comb_chars[term->grid->cursor.point.col].count = 0;
|
row->comb_chars[term->grid->cursor.point.col].count = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
row->dirty = true;
|
row->dirty = true;
|
||||||
cell->attrs.clean = 0;
|
cell->attrs.clean = 0;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -77,16 +77,21 @@ struct damage {
|
||||||
int lines;
|
int lines;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if FOOT_UNICODE_COMBINING
|
||||||
struct combining_chars {
|
struct combining_chars {
|
||||||
uint8_t count;
|
uint8_t count;
|
||||||
wchar_t chars[2]; /* TODO: how many do we need? */
|
wchar_t chars[2]; /* TODO: how many do we need? */
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
struct row {
|
struct row {
|
||||||
struct cell *cells;
|
struct cell *cells;
|
||||||
bool dirty;
|
bool dirty;
|
||||||
bool linebreak;
|
bool linebreak;
|
||||||
|
|
||||||
|
#if FOOT_UNICODE_COMBINING
|
||||||
struct combining_chars *comb_chars;
|
struct combining_chars *comb_chars;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
struct sixel {
|
struct sixel {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue