From 1e69599900a753e2d7275d7ba714202b7d9c843e Mon Sep 17 00:00:00 2001 From: Berke Güzel Date: Tue, 13 Oct 2026 14:46:44 +0300 Subject: Eliminate pen style and history stream parameter smuggling - Introduce struct text_pen bundling (fg, bg, sl) across screen and core - Reduce text_append from 9 to 7 parameters - Reduce text_commit from 8 to 6 parameters - Reduce hist_runs_add_pen from 5 to 3 parameters - Reduce sc_text_ascii and sc_ascii_fast from 6 to 4 parameters - Remove unused fg, bg parameters from mark_row_blank - Introduce struct hist_stream_state in src/hist.c, reducing stream_lines from 9 to 5 params and lf_rows from 10 to 6 params - Introduce struct hist_view_pos in src/hist_view.h, reducing term_hist_view_row_pos from 9 to 7 params --- src/text.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/text.c') diff --git a/src/text.c b/src/text.c index ad3e7f2..c68011f 100644 --- a/src/text.c +++ b/src/text.c @@ -140,9 +140,7 @@ static inline bool try_text_run(struct term *t, const char *buf, size_t len, if (t->cursor_x != 0 && t->cursor_x != term_row(t, t->cursor_y)->len) return false; - uint32_t fg = t->inverse ? t->cur_bg : t->cur_fg; - uint32_t bg = t->inverse ? t->cur_fg : t->cur_bg; - uint32_t flags = term_flags_pad(t); + struct text_pen pen = term_text_pen(t); bool wrote = false; do { struct srow *text = t->insert_mode || t->lr_margin_mode ? NULL : text_append_row(t); @@ -156,7 +154,7 @@ static inline bool try_text_run(struct term *t, const char *buf, size_t len, wrote = true; text_commit(text, r.out, r.chars, r.cols, (uint8_t)((r.narrow ? HLINE_NARROW : 0) | (r.wide ? HLINE_HAS_WIDE : 0)), - fg, bg, flags); + pen); t->last_char = r.last; sc_text_advance(t, x, r.cols, avail); i += (size_t)r.bytes; @@ -165,7 +163,7 @@ static inline bool try_text_run(struct term *t, const char *buf, size_t len, if (span.avail < 2) break; struct text_run_result r = term_text_run(span.cells, buf + i, (int)(len - i), - span.avail, fg, bg, flags, t->last_char, + span.avail, pen.fg, pen.bg, pen.sl, t->last_char, &t->text_width); if (!r.bytes) break; -- cgit v1.2.3