mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-02 01:40:13 -05:00
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.
This commit is contained in:
parent
5bec83c406
commit
d9e1aefb91
9 changed files with 34 additions and 34 deletions
10
render.c
10
render.c
|
|
@ -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));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue