diff options
| author | Berke Güzel <wenekar1@gmail.com> | 2026-10-13 19:22:05 +0300 |
|---|---|---|
| committer | Berke Güzel <wenekar1@gmail.com> | 2026-10-13 19:22:05 +0300 |
| commit | 01e1c61e9fcf4a0b0164a7fe5395a209a50f6905 (patch) | |
| tree | 1f1eb33e49eab338650a42e8f602af75d8d28a24 /src/core.c | |
| parent | 2d02d39d2cd32e9eb559638865d2746f02c08556 (diff) | |
Optimize hot loops with direct access, LUTs, and closed-form formulas
Diffstat (limited to 'src/core.c')
| -rw-r--r-- | src/core.c | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -14,7 +14,19 @@ static uint16_t cluster_presentation(const uint32_t *cps, int len) { + if (len <= 1) + return 0; bool pictographic = unicode_extended_pictographic(cps[0]); + if (len == 2) { + uint32_t c1 = cps[1]; + if (c1 == 0xFE0F) return CELL_EMOJI; + if (c1 == 0xFE0E) return CELL_TEXT; + if (c1 == 0x20E3 || grapheme_regional_indicator(c1) || + (pictographic && (c1 == 0x200D || grapheme_emoji_modifier(c1) || + (c1 >= 0xE0020 && c1 <= 0xE007F)))) + return CELL_EMOJI; + return 0; + } bool emoji = false; for (int i = 1; i < len; i++) { if (cps[i] == 0xFE0F) @@ -320,6 +332,19 @@ void term_sc_tab(struct term *t, int n) int dir = n >= 0 ? 1 : -1; int count = n >= 0 ? n : -n; if (count > t->cols) count = t->cols; + if (!t->custom_tabs) { + if (dir > 0) { + int next = ((t->cursor_x / 8) + count) * 8; + t->cursor_x = next < t->cols ? next : t->cols - 1; + } else { + int prev = t->cursor_x > 0 ? (((t->cursor_x - 1) / 8 - (count - 1)) * 8) : 0; + t->cursor_x = prev > 0 ? prev : 0; + } + t->pending_wrap = false; + struct srow *cur = term_row(t, t->cursor_y); + if (cur) cur->version++; + return; + } while (count-- > 0) { int x = t->cursor_x + dir; while (x > 0 && x < t->cols - 1 && !t->tabs[x]) |
