diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2021-05-14 12:41:02 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2021-05-14 12:41:02 +0000 |
| commit | d9e1aefb9173857f0632227de5ac368a505c69bf (patch) | |
| tree | 0801f95aa3d86f607889148c4649be2e1a2ef612 /render.c | |
| parent | grid: add compile-time define to enable timing of the reflow operation (diff) | |
term: rename CELL_MULT_COL_SPACER -> CELL_SPACER, and change its definition
Instead of using CELL_SPACER for *all* cells that previously used
CELL_MULT_COL_SPACER, include the remaining number of spacers
following, and including, itself. This is encoded by adding to the
CELL_SPACER value.
So, a double width character will now store the character itself in
the first cell (just like before), and CELL_SPACER+1 in the second
cell.
A three-cell character would store the character itself, then
CELL_SPACER+2, and finally CELL_SPACER+1.
In other words, the last spacer is always CELL_SPACER+1.
CELL_SPACER+0 is used when padding at the right margin. I.e. when
writing e.g. a double width character in the last column, we insert a
CELL_SPACER+0 pad character, and then write the double width character
in the first column on the next row.
Diffstat (limited to 'render.c')
| -rw-r--r-- | render.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -594,7 +594,7 @@ render_cell(struct terminal *term, pixman_image_t *pix, if (has_cursor && term->cursor_style == CURSOR_BLOCK && term->kbd_focus) draw_cursor(term, cell, font, pix, &fg, &bg, x, y, cell_cols); - if (cell->wc == 0 || cell->wc == CELL_MULT_COL_SPACER || + if (cell->wc == 0 || cell->wc >= CELL_SPACER || (unlikely(cell->attrs.conceal) && !is_selected)) { goto draw_cursor; @@ -1237,7 +1237,7 @@ render_ime_preedit_for_seat(struct terminal *term, struct seat *seat, /* Make sure we don't start in the middle of a character */ while (ime_ofs < cells_needed && - seat->ime.preedit.cells[ime_ofs].wc == CELL_MULT_COL_SPACER) + seat->ime.preedit.cells[ime_ofs].wc >= CELL_SPACER) { ime_ofs++; } @@ -1249,7 +1249,7 @@ render_ime_preedit_for_seat(struct terminal *term, struct seat *seat, struct row *row = grid_row_in_view(term->grid, row_idx); /* Don't start pre-edit text in the middle of a double-width character */ - while (col_idx > 0 && row->cells[col_idx].wc == CELL_MULT_COL_SPACER) { + while (col_idx > 0 && row->cells[col_idx].wc >= CELL_SPACER) { cells_used++; col_idx--; } @@ -1268,11 +1268,11 @@ render_ime_preedit_for_seat(struct terminal *term, struct seat *seat, row->dirty = true; /* Render pre-edit text */ - xassert(seat->ime.preedit.cells[ime_ofs].wc != CELL_MULT_COL_SPACER); + xassert(seat->ime.preedit.cells[ime_ofs].wc < CELL_SPACER); for (int i = 0, idx = ime_ofs; idx < seat->ime.preedit.count; i++, idx++) { const struct cell *cell = &seat->ime.preedit.cells[idx]; - if (cell->wc == CELL_MULT_COL_SPACER) + if (cell->wc >= CELL_SPACER) continue; int width = max(1, wcwidth(cell->wc)); |
