mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
grid: reflow: don't special case the first cell in a multi-column character
Wrap *all* cell copying logic in a for-loop for the characters width. This _should_, in theory, mean reflow of e.g. cursor coordinates in the middle of a multi-column character works correctly. Also fix reflow of cmd start/end integration.
This commit is contained in:
parent
6a181c9f72
commit
eced7cf1d6
1 changed files with 60 additions and 58 deletions
118
grid.c
118
grid.c
|
|
@ -984,7 +984,7 @@ grid_resize_and_reflow(
|
||||||
} else
|
} else
|
||||||
underline_range = underline_range_terminator = NULL;
|
underline_range = underline_range_terminator = NULL;
|
||||||
|
|
||||||
for (int c = 0; c < col_count; c++) {
|
for (int c = 0; c < col_count;) {
|
||||||
const struct cell *old = &old_row->cells[c];
|
const struct cell *old = &old_row->cells[c];
|
||||||
|
|
||||||
/* Row full, emit newline and get a new, fresh, row */
|
/* Row full, emit newline and get a new, fresh, row */
|
||||||
|
|
@ -1017,84 +1017,86 @@ grid_resize_and_reflow(
|
||||||
line_wrap();
|
line_wrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unlikely(c == 0))
|
new_row->shell_integration.prompt_marker = old_row->shell_integration.prompt_marker;
|
||||||
new_row->shell_integration.prompt_marker = old_row->shell_integration.prompt_marker;
|
|
||||||
|
|
||||||
new_row->cells[new_col_idx] = *old;
|
for (int i = 0; i < width; i++) {
|
||||||
|
if (unlikely(uri_range != NULL && uri_range != uri_range_terminator)) {
|
||||||
|
if (unlikely(uri_range->start == c)) {
|
||||||
|
reflow_range_start(
|
||||||
|
uri_range, ROW_RANGE_URI, new_row, new_col_idx);
|
||||||
|
}
|
||||||
|
|
||||||
if (unlikely(uri_range != NULL && uri_range != uri_range_terminator)) {
|
if (unlikely(uri_range->end == c)) {
|
||||||
if (uri_range->start == c) {
|
reflow_range_end(
|
||||||
reflow_range_start(
|
uri_range, ROW_RANGE_URI, new_row, new_col_idx);
|
||||||
uri_range, ROW_RANGE_URI, new_row, new_col_idx);
|
grid_row_uri_range_destroy(uri_range);
|
||||||
|
uri_range++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uri_range->end == c) {
|
if (unlikely(underline_range != NULL && underline_range != underline_range_terminator)) {
|
||||||
reflow_range_end(
|
if (unlikely(underline_range->start == c)) {
|
||||||
uri_range, ROW_RANGE_URI, new_row, new_col_idx);
|
reflow_range_start(
|
||||||
grid_row_uri_range_destroy(uri_range);
|
underline_range, ROW_RANGE_UNDERLINE, new_row, new_col_idx);
|
||||||
uri_range++;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (unlikely(underline_range != NULL && underline_range != underline_range_terminator)) {
|
if (unlikely(underline_range->end == c)) {
|
||||||
if (underline_range->start == c) {
|
reflow_range_end(
|
||||||
reflow_range_start(
|
underline_range, ROW_RANGE_UNDERLINE, new_row, new_col_idx);
|
||||||
underline_range, ROW_RANGE_UNDERLINE, new_row, new_col_idx);
|
grid_row_underline_range_destroy(underline_range);
|
||||||
|
underline_range++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (underline_range->end == c) {
|
if (unlikely(tp != NULL)) {
|
||||||
reflow_range_end(
|
if (unlikely(tp->col == c)) {
|
||||||
underline_range, ROW_RANGE_UNDERLINE, new_row, new_col_idx);
|
do {
|
||||||
grid_row_underline_range_destroy(underline_range);
|
xassert(tp->row == old_row_idx);
|
||||||
underline_range++;
|
|
||||||
|
tp->row = new_row_idx;
|
||||||
|
tp->col = new_col_idx;
|
||||||
|
|
||||||
|
next_tp++;
|
||||||
|
tp = *next_tp;
|
||||||
|
} while (tp->row == old_row_idx && tp->col == c);
|
||||||
|
|
||||||
|
if (tp->row != old_row_idx)
|
||||||
|
tp = NULL;
|
||||||
|
|
||||||
|
LOG_DBG("next TP (tp=%p): %dx%d",
|
||||||
|
(void*)tp, (*next_tp)->row, (*next_tp)->col);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (unlikely(tp != NULL)) {
|
if (unlikely(old_row->shell_integration.cmd_start >= 0 &&
|
||||||
if (tp->col == c) {
|
old_row->shell_integration.cmd_start == c))
|
||||||
do {
|
{
|
||||||
xassert(tp->row == old_row_idx);
|
|
||||||
|
|
||||||
tp->row = new_row_idx;
|
|
||||||
tp->col = new_col_idx;
|
|
||||||
|
|
||||||
next_tp++;
|
|
||||||
tp = *next_tp;
|
|
||||||
} while (tp->row == old_row_idx && tp->col == c);
|
|
||||||
|
|
||||||
if (tp->row != old_row_idx)
|
|
||||||
tp = NULL;
|
|
||||||
|
|
||||||
LOG_DBG("next TP (tp=%p): %dx%d",
|
|
||||||
(void*)tp, (*next_tp)->row, (*next_tp)->col);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (unlikely(old_row->shell_integration.cmd_start >= 0)) {
|
|
||||||
if (old_row->shell_integration.cmd_start == c) {
|
|
||||||
new_row->shell_integration.cmd_start = new_col_idx;
|
new_row->shell_integration.cmd_start = new_col_idx;
|
||||||
} else if (old_row->shell_integration.cmd_end == c) {
|
}
|
||||||
|
|
||||||
|
if (unlikely(old_row->shell_integration.cmd_end >= 0 &&
|
||||||
|
old_row->shell_integration.cmd_end == c))
|
||||||
|
{
|
||||||
new_row->shell_integration.cmd_end = new_col_idx;
|
new_row->shell_integration.cmd_end = new_col_idx;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
new_col_idx++;
|
|
||||||
|
|
||||||
if (unlikely(width > 1)) {
|
|
||||||
if (unlikely(width > new_cols)) {
|
if (unlikely(width > new_cols)) {
|
||||||
/* Wide character no longer fits on a row, replace
|
/* Wide character no longer fits on a row, replace
|
||||||
it with a single space */
|
it with a single space */
|
||||||
new_row->cells[new_col_idx - 1].wc = 0;
|
new_row->cells[new_col_idx++].wc = 0;
|
||||||
|
c++;
|
||||||
|
|
||||||
/* Walk past the SPACER cells */
|
/* Walk past the SPACER cells */
|
||||||
for (int i = 1; i < width; i++, c++, old++)
|
for (int i = 1; i < width; i++, c++, old++)
|
||||||
;
|
;
|
||||||
} else {
|
|
||||||
/* Copy spacers */
|
/* Continue with next character in the *old* grid */
|
||||||
xassert(new_col_idx + width - 1 <= new_cols);
|
break;
|
||||||
for (int i = 1; i < width; i++, c++)
|
|
||||||
new_row->cells[new_col_idx++] = *(++old);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
new_row->cells[new_col_idx++] = *old;
|
||||||
|
old++;
|
||||||
|
c++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue