diff options
| author | CismonX <admin@cismon.net> | 2023-07-19 23:00:14 +0000 |
|---|---|---|
| committer | CismonX <admin@cismon.net> | 2023-07-20 00:47:40 +0000 |
| commit | c3b119ea81a7b6bf01cf8ba064ab9df8f7c92f1e (patch) | |
| tree | f8fcea916575c172b2178fd6b4ce1eec7b76b204 | |
| parent | render: OSD: don’t mark surface as being opaque, when it’s not (diff) | |
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.
| -rw-r--r-- | vt.c | 30 |
1 files changed, 22 insertions, 8 deletions
@@ -437,6 +437,27 @@ UNITTEST } 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 action_esc_dispatch(struct terminal *term, uint8_t final) { LOG_DBG("ESC: %s", esc_as_string(term, final)); @@ -478,14 +499,7 @@ action_esc_dispatch(struct terminal *term, uint8_t final) break; case 'H': - tll_foreach(term->tab_stops, it) { - 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); + tab_set(term); break; case 'M': |
