mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-11 05:33:55 -04: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
26
selection.c
26
selection.c
|
|
@ -234,7 +234,7 @@ find_word_boundary_left(struct terminal *term, struct coord *pos,
|
|||
const struct row *r = grid_row_in_view(term->grid, pos->row);
|
||||
wchar_t c = r->cells[pos->col].wc;
|
||||
|
||||
while (c == CELL_MULT_COL_SPACER) {
|
||||
while (c >= CELL_SPACER) {
|
||||
xassert(pos->col > 0);
|
||||
if (pos->col == 0)
|
||||
return;
|
||||
|
|
@ -268,7 +268,7 @@ find_word_boundary_left(struct terminal *term, struct coord *pos,
|
|||
const struct row *row = grid_row_in_view(term->grid, next_row);
|
||||
|
||||
c = row->cells[next_col].wc;
|
||||
while (c == CELL_MULT_COL_SPACER) {
|
||||
while (c >= CELL_SPACER) {
|
||||
xassert(next_col > 0);
|
||||
if (--next_col < 0)
|
||||
return;
|
||||
|
|
@ -306,7 +306,7 @@ find_word_boundary_right(struct terminal *term, struct coord *pos,
|
|||
const struct row *r = grid_row_in_view(term->grid, pos->row);
|
||||
wchar_t c = r->cells[pos->col].wc;
|
||||
|
||||
while (c == CELL_MULT_COL_SPACER) {
|
||||
while (c >= CELL_SPACER) {
|
||||
xassert(pos->col > 0);
|
||||
if (pos->col == 0)
|
||||
return;
|
||||
|
|
@ -340,7 +340,7 @@ find_word_boundary_right(struct terminal *term, struct coord *pos,
|
|||
const struct row *row = grid_row_in_view(term->grid, next_row);
|
||||
|
||||
c = row->cells[next_col].wc;
|
||||
while (c == CELL_MULT_COL_SPACER) {
|
||||
while (c >= CELL_SPACER) {
|
||||
if (++next_col >= term->cols) {
|
||||
next_col = 0;
|
||||
if (++next_row >= term->rows)
|
||||
|
|
@ -554,7 +554,7 @@ set_pivot_point_for_block_and_char_wise(struct terminal *term,
|
|||
const struct row *row = term->grid->rows[pivot_start->row & (term->grid->num_rows - 1)];
|
||||
const struct cell *cell = &row->cells[pivot_start->col];
|
||||
|
||||
if (cell->wc != CELL_MULT_COL_SPACER)
|
||||
if (cell->wc < CELL_SPACER)
|
||||
break;
|
||||
|
||||
/* Multi-column chars don’t cross rows */
|
||||
|
|
@ -579,7 +579,7 @@ set_pivot_point_for_block_and_char_wise(struct terminal *term,
|
|||
const struct row *row = term->grid->rows[pivot_end->row & (term->grid->num_rows - 1)];
|
||||
const wchar_t wc = row->cells[pivot_end->col].wc;
|
||||
|
||||
keep_going = wc == CELL_MULT_COL_SPACER;
|
||||
keep_going = wc >= CELL_SPACER;
|
||||
|
||||
if (pivot_end->col == 0) {
|
||||
if (pivot_end->row - term->grid->view <= 0)
|
||||
|
|
@ -596,7 +596,7 @@ set_pivot_point_for_block_and_char_wise(struct terminal *term,
|
|||
const wchar_t wc = pivot_start->col < term->cols - 1
|
||||
? row->cells[pivot_start->col + 1].wc : 0;
|
||||
|
||||
keep_going = wc == CELL_MULT_COL_SPACER;
|
||||
keep_going = wc >= CELL_SPACER;
|
||||
|
||||
if (pivot_start->col >= term->cols - 1) {
|
||||
if (pivot_start->row - term->grid->view >= term->rows - 1)
|
||||
|
|
@ -609,9 +609,9 @@ set_pivot_point_for_block_and_char_wise(struct terminal *term,
|
|||
}
|
||||
|
||||
xassert(term->grid->rows[pivot_start->row & (term->grid->num_rows - 1)]->
|
||||
cells[pivot_start->col].wc != CELL_MULT_COL_SPACER);
|
||||
cells[pivot_start->col].wc < CELL_SPACER);
|
||||
xassert(term->grid->rows[pivot_end->row & (term->grid->num_rows - 1)]->
|
||||
cells[pivot_end->col].wc != CELL_MULT_COL_SPACER);
|
||||
cells[pivot_end->col].wc < CELL_SPACER);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -743,17 +743,17 @@ selection_update(struct terminal *term, int col, int row)
|
|||
(new_start.row == new_end.row && new_start.col <= new_end.col))
|
||||
{
|
||||
while (new_start.col >= 1 &&
|
||||
row_start->cells[new_start.col].wc == CELL_MULT_COL_SPACER)
|
||||
row_start->cells[new_start.col].wc >= CELL_SPACER)
|
||||
new_start.col--;
|
||||
while (new_end.col < term->cols - 1 &&
|
||||
row_end->cells[new_end.col + 1].wc == CELL_MULT_COL_SPACER)
|
||||
row_end->cells[new_end.col + 1].wc >= CELL_SPACER)
|
||||
new_end.col++;
|
||||
} else {
|
||||
while (new_end.col >= 1 &&
|
||||
row_end->cells[new_end.col].wc == CELL_MULT_COL_SPACER)
|
||||
row_end->cells[new_end.col].wc >= CELL_SPACER)
|
||||
new_end.col--;
|
||||
while (new_start.col < term->cols - 1 &&
|
||||
row_start->cells[new_start.col + 1].wc == CELL_MULT_COL_SPACER)
|
||||
row_start->cells[new_start.col + 1].wc >= CELL_SPACER)
|
||||
new_start.col++;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue