mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-16 05:34:00 -04:00
vt: improve handling of HTS
Do not insert existing positions into the tab stop list. This prevents a performance issue when iterating through an extremely long tab stop list. Also corrects the behaviour of CBT.
This commit is contained in:
parent
a49281ced3
commit
c3b119ea81
1 changed files with 22 additions and 8 deletions
30
vt.c
30
vt.c
|
|
@ -436,6 +436,27 @@ UNITTEST
|
||||||
xassert(term.vt.private == expected);
|
xassert(term.vt.private == expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
tab_set(struct terminal *term)
|
||||||
|
{
|
||||||
|
int col = term->grid->cursor.point.col;
|
||||||
|
|
||||||
|
if (tll_length(term->tab_stops) == 0 || tll_back(term->tab_stops) < col) {
|
||||||
|
tll_push_back(term->tab_stops, col);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
tll_foreach(term->tab_stops, it) {
|
||||||
|
if (it->item < col) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (it->item > col) {
|
||||||
|
tll_insert_before(term->tab_stops, it, col);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
action_esc_dispatch(struct terminal *term, uint8_t final)
|
action_esc_dispatch(struct terminal *term, uint8_t final)
|
||||||
{
|
{
|
||||||
|
|
@ -478,14 +499,7 @@ action_esc_dispatch(struct terminal *term, uint8_t final)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'H':
|
case 'H':
|
||||||
tll_foreach(term->tab_stops, it) {
|
tab_set(term);
|
||||||
if (it->item >= term->grid->cursor.point.col) {
|
|
||||||
tll_insert_before(term->tab_stops, it, term->grid->cursor.point.col);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tll_push_back(term->tab_stops, term->grid->cursor.point.col);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'M':
|
case 'M':
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue