mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-03 07:15:29 -04:00
Merge branch 'reflow-osc8-performance'
This commit is contained in:
commit
e335d57bc7
3 changed files with 78 additions and 55 deletions
111
grid.c
111
grid.c
|
|
@ -289,45 +289,28 @@ grid_resize_without_reflow(
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
reflow_uri_ranges(const struct row *old_row, struct row *new_row,
|
reflow_uri_range_start(struct row_uri_range *range, struct row *new_row,
|
||||||
int old_col_idx, int new_col_idx)
|
int new_col_idx)
|
||||||
{
|
{
|
||||||
if (old_row->extra == NULL)
|
struct row_uri_range new_range = {
|
||||||
return;
|
.start = new_col_idx,
|
||||||
|
.end = -1,
|
||||||
|
.id = range->id,
|
||||||
|
.uri = xstrdup(range->uri),
|
||||||
|
};
|
||||||
|
grid_row_add_uri_range(new_row, new_range);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
static void
|
||||||
* Check for URI range start/end points on the “old” row, and
|
reflow_uri_range_end(struct row_uri_range *range, struct row *new_row,
|
||||||
* open/close a corresponding URI range on the “new” row.
|
int new_col_idx)
|
||||||
*/
|
{
|
||||||
|
xassert(tll_length(new_row->extra->uri_ranges) > 0);
|
||||||
|
struct row_uri_range *new_range = &tll_back(new_row->extra->uri_ranges);
|
||||||
|
|
||||||
tll_foreach(old_row->extra->uri_ranges, it) {
|
xassert(new_range->id == range->id);
|
||||||
if (it->item.start == old_col_idx) {
|
xassert(new_range->end < 0);
|
||||||
struct row_uri_range new_range = {
|
new_range->end = new_col_idx;
|
||||||
.start = new_col_idx,
|
|
||||||
.end = -1,
|
|
||||||
.id = it->item.id,
|
|
||||||
.uri = xstrdup(it->item.uri),
|
|
||||||
};
|
|
||||||
grid_row_add_uri_range(new_row, new_range);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (it->item.end == old_col_idx) {
|
|
||||||
xassert(new_row->extra != NULL);
|
|
||||||
|
|
||||||
bool found_it = false;
|
|
||||||
tll_foreach(new_row->extra->uri_ranges, it2) {
|
|
||||||
if (it2->item.id != it->item.id)
|
|
||||||
continue;
|
|
||||||
if (it2->item.end >= 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
it2->item.end = new_col_idx;
|
|
||||||
found_it = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
xassert(found_it);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct row *
|
static struct row *
|
||||||
|
|
@ -364,21 +347,22 @@ _line_wrap(struct grid *old_grid, struct row **new_grid, struct row *row,
|
||||||
* ranges on the previous row, and re-open them on the
|
* ranges on the previous row, and re-open them on the
|
||||||
* next/current row.
|
* next/current row.
|
||||||
*/
|
*/
|
||||||
tll_foreach(row->extra->uri_ranges, it) {
|
if (tll_length(row->extra->uri_ranges) > 0) {
|
||||||
if (it->item.end >= 0)
|
struct row_uri_range *range = &tll_back(row->extra->uri_ranges);
|
||||||
continue;
|
if (range->end < 0) {
|
||||||
|
|
||||||
/* Terminate URI range on the previous row */
|
/* Terminate URI range on the previous row */
|
||||||
it->item.end = col_count - 1;
|
range->end = col_count - 1;
|
||||||
|
|
||||||
/* Open a new range on the new/current row */
|
/* Open a new range on the new/current row */
|
||||||
struct row_uri_range new_range = {
|
struct row_uri_range new_range = {
|
||||||
.start = 0,
|
.start = 0,
|
||||||
.end = -1,
|
.end = -1,
|
||||||
.id = it->item.id,
|
.id = range->id,
|
||||||
.uri = xstrdup(it->item.uri),
|
.uri = xstrdup(range->uri),
|
||||||
};
|
};
|
||||||
grid_row_add_uri_range(new_row, new_range);
|
grid_row_add_uri_range(new_row, new_range);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new_row;
|
return new_row;
|
||||||
|
|
@ -548,6 +532,8 @@ grid_resize_and_reflow(
|
||||||
*/
|
*/
|
||||||
int empty_count = 0;
|
int empty_count = 0;
|
||||||
|
|
||||||
|
struct row_uri_range *uri_range = NULL;
|
||||||
|
|
||||||
/* Walk current line of the old grid */
|
/* Walk current line of the old grid */
|
||||||
for (int c = 0; c < old_cols; c++) {
|
for (int c = 0; c < old_cols; c++) {
|
||||||
const struct cell *old_cell = &old_row->cells[c];
|
const struct cell *old_cell = &old_row->cells[c];
|
||||||
|
|
@ -564,10 +550,16 @@ grid_resize_and_reflow(
|
||||||
* sure we handle it */
|
* sure we handle it */
|
||||||
bool on_uri = false;
|
bool on_uri = false;
|
||||||
if (old_row->extra != NULL) {
|
if (old_row->extra != NULL) {
|
||||||
tll_foreach(old_row->extra->uri_ranges, it) {
|
if (uri_range != NULL)
|
||||||
if (unlikely(it->item.start == c || it->item.end == c)) {
|
on_uri = uri_range->end == c;
|
||||||
|
|
||||||
|
else if (tll_length(old_row->extra->uri_ranges) > 0) {
|
||||||
|
struct row_uri_range *range = &tll_front(
|
||||||
|
old_row->extra->uri_ranges);
|
||||||
|
|
||||||
|
if (range->start == c) {
|
||||||
|
uri_range = range;
|
||||||
on_uri = true;
|
on_uri = true;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -641,8 +633,19 @@ grid_resize_and_reflow(
|
||||||
} while (tp->row == old_row_idx && tp->col == c);
|
} while (tp->row == old_row_idx && tp->col == c);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unlikely(on_uri))
|
if (unlikely(on_uri)) {
|
||||||
reflow_uri_ranges(old_row, new_row, c, new_col_idx);
|
if (uri_range->start == c)
|
||||||
|
reflow_uri_range_start(uri_range, new_row, new_col_idx);
|
||||||
|
if (uri_range->end == c) {
|
||||||
|
reflow_uri_range_end(uri_range, new_row, new_col_idx);
|
||||||
|
|
||||||
|
xassert(&tll_front(old_row->extra->uri_ranges) == uri_range);
|
||||||
|
grid_row_uri_range_destroy(uri_range);
|
||||||
|
tll_pop_front(old_row->extra->uri_ranges);
|
||||||
|
|
||||||
|
uri_range = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
new_col_idx++;
|
new_col_idx++;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
8
grid.h
8
grid.h
|
|
@ -78,6 +78,12 @@ grid_row_in_view(struct grid *grid, int row_no)
|
||||||
|
|
||||||
void grid_row_add_uri_range(struct row *row, struct row_uri_range range);
|
void grid_row_add_uri_range(struct row *row, struct row_uri_range range);
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
grid_row_uri_range_destroy(struct row_uri_range *range)
|
||||||
|
{
|
||||||
|
free(range->uri);
|
||||||
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
grid_row_reset_extra(struct row *row)
|
grid_row_reset_extra(struct row *row)
|
||||||
{
|
{
|
||||||
|
|
@ -85,7 +91,7 @@ grid_row_reset_extra(struct row *row)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
tll_foreach(row->extra->uri_ranges, it) {
|
tll_foreach(row->extra->uri_ranges, it) {
|
||||||
free(it->item.uri);
|
grid_row_uri_range_destroy(&it->item);
|
||||||
tll_remove(row->extra->uri_ranges, it);
|
tll_remove(row->extra->uri_ranges, it);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
14
terminal.c
14
terminal.c
|
|
@ -3106,6 +3106,20 @@ term_osc8_close(struct terminal *term)
|
||||||
.uri = xstrdup(term->vt.osc8.uri),
|
.uri = xstrdup(term->vt.osc8.uri),
|
||||||
};
|
};
|
||||||
grid_row_add_uri_range(row, range);
|
grid_row_add_uri_range(row, range);
|
||||||
|
|
||||||
|
#if defined(_DEBUG)
|
||||||
|
tll_foreach(row->extra->uri_ranges, it1) {
|
||||||
|
tll_foreach(row->extra->uri_ranges, it2) {
|
||||||
|
if (&it1->item == &it2->item)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
xassert(it1->item.start != it2->item.start);
|
||||||
|
xassert(it1->item.start != it2->item.end);
|
||||||
|
xassert(it1->item.end != it2->item.start);
|
||||||
|
xassert(it1->item.end != it2->item.end);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
start_col = 0;
|
start_col = 0;
|
||||||
} while (r++ != end.row);
|
} while (r++ != end.row);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue