diff options
| author | Berke Güzel <wenekar1@gmail.com> | 2026-10-13 14:46:44 +0300 |
|---|---|---|
| committer | Berke Güzel <wenekar1@gmail.com> | 2026-10-13 14:46:44 +0300 |
| commit | 1e69599900a753e2d7275d7ba714202b7d9c843e (patch) | |
| tree | 13416f651319145aa5dbdd85b9947bec4858b366 /src/screen.h | |
| parent | 5ab6b560e8528c27ba934b90f94b1828b7771e27 (diff) | |
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
Diffstat (limited to 'src/screen.h')
| -rw-r--r-- | src/screen.h | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/src/screen.h b/src/screen.h index 8498e9d..5f92929 100644 --- a/src/screen.h +++ b/src/screen.h @@ -230,10 +230,10 @@ static inline struct srow *text_append_row(struct term *t) start = text_row_last_pen(&prev->text); } if (row->kind == ROW_TEXT) { - uint32_t sl = pen_sl(&start); - pen_set(&row->text.start, start.fg, start.bg, sl); - pen_set(&row->text.runs.base, start.fg, start.bg, sl); - pen_set(&row->text.runs.pen, start.fg, start.bg, sl); + struct text_pen p = text_pen_from_attr(&start); + pen_set_text(&row->text.start, p); + pen_set_text(&row->text.runs.base, p); + pen_set_text(&row->text.runs.pen, p); return row; } row->kind = ROW_TEXT; @@ -242,10 +242,9 @@ static inline struct srow *text_append_row(struct term *t) } /* Take nbytes bytes that a writer put at the end of the row text: chars - * characters in cells columns, with the pen fg, bg, sl (flags | link << 16). - * Runs count characters. */ + * characters in cells columns, with the pen. Runs count characters. */ static inline void text_commit(struct srow *row, int nbytes, int chars, int cells, uint8_t hflags, - uint32_t fg, uint32_t bg, uint32_t sl) + struct text_pen pen) { struct text_row *tr = &row->text; tr->text_len = (uint16_t)(tr->text_len + nbytes); @@ -253,8 +252,8 @@ static inline void text_commit(struct srow *row, int nbytes, int chars, int cell tr->wide = (uint16_t)(tr->wide + cells - chars); tr->flags = (uint8_t)((tr->flags & hflags & HLINE_NARROW) | ((tr->flags | hflags) & ~HLINE_NARROW) | - ((sl >> 16) ? HLINE_HAS_LINK : 0)); - hist_runs_add_pen(&tr->runs, fg, bg, sl, (uint32_t)chars); + ((pen.sl >> 16) ? HLINE_HAS_LINK : 0)); + hist_runs_add_pen(&tr->runs, pen, (uint32_t)chars); if (tr->cells > row->len) row->len = tr->cells; row->version++; @@ -263,10 +262,10 @@ static inline void text_commit(struct srow *row, int nbytes, int chars, int cell } static inline void text_append(struct srow *row, const uint8_t *bytes, int nbytes, int chars, - int cells, uint8_t hflags, uint32_t fg, uint32_t bg, uint32_t sl) + int cells, uint8_t hflags, struct text_pen pen) { bytes_copy_small(row->text.text + row->text.text_len, (const char *)bytes, nbytes); - text_commit(row, nbytes, chars, cells, hflags, fg, bg, sl); + text_commit(row, nbytes, chars, cells, hflags, pen); } static inline struct cell *row_cells(const struct term *t, int p) @@ -340,7 +339,7 @@ static inline bool using_default_colors(const struct term *t) return t->cur_fg == TERM_COLOR_FG && t->cur_bg == TERM_COLOR_BG; } -static inline void mark_row_blank(struct term *t, int p, uint32_t fg, uint32_t bg) +static inline void mark_row_blank(struct term *t, int p) { struct srow *row = &t->scr.slot[p]; uint8_t tail_padded = ((row->kind == ROW_CELLS && row->len == 0) || row->kind == ROW_TEXT) @@ -349,8 +348,6 @@ static inline void mark_row_blank(struct term *t, int p, uint32_t fg, uint32_t b row->len = 0; row->flags = tail_padded; row->version++; - (void)fg; - (void)bg; } static inline void term_row_fill_gap(struct srow *row, int x) @@ -384,7 +381,7 @@ static inline void erase_span(struct term *t, int p, int from, int to) if (from >= to) return; if (pristine && from == 0 && to >= len) { - mark_row_blank(t, p, t->cur_fg, t->cur_bg); + mark_row_blank(t, p); return; } struct cell *cells = row_cells(t, p); @@ -410,7 +407,7 @@ static inline void erase_span(struct term *t, int p, int from, int to) return; } if (from == 0) { - mark_row_blank(t, p, t->cur_fg, t->cur_bg); + mark_row_blank(t, p); } else { row->len = (uint16_t)from; row->flags &= ~RF_TAIL_PADDED; |
