From d9e1aefb9173857f0632227de5ac368a505c69bf Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Fri, 14 May 2021 14:41:02 +0200 Subject: 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. --- ime.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ime.c') diff --git a/ime.c b/ime.c index b1852ed3..81e63884 100644 --- a/ime.c +++ b/ime.c @@ -199,7 +199,7 @@ done(void *data, struct zwp_text_input_v3 *zwp_text_input_v3, for (int j = 1; j < width; j++) { cell = &seat->ime.preedit.cells[cell_idx + j]; - cell->wc = CELL_MULT_COL_SPACER; + cell->wc = CELL_SPACER + width - j; cell->attrs = (struct attributes){.clean = 1}; } @@ -280,7 +280,7 @@ done(void *data, struct zwp_text_input_v3 *zwp_text_input_v3, /* Expand cursor end to end of glyph */ while (cell_end > cell_begin && cell_end < cell_count && - seat->ime.preedit.cells[cell_end].wc == CELL_MULT_COL_SPACER) + seat->ime.preedit.cells[cell_end].wc >= CELL_SPACER) { cell_end++; } -- cgit v1.3