summaryrefslogtreecommitdiff
path: root/src/screen.c
diff options
context:
space:
mode:
authorBerke Güzel <wenekar1@gmail.com>2026-10-13 14:46:44 +0300
committerBerke Güzel <wenekar1@gmail.com>2026-10-13 14:46:44 +0300
commit1e69599900a753e2d7275d7ba714202b7d9c843e (patch)
tree13416f651319145aa5dbdd85b9947bec4858b366 /src/screen.c
parent5ab6b560e8528c27ba934b90f94b1828b7771e27 (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.c')
-rw-r--r--src/screen.c32
1 files changed, 14 insertions, 18 deletions
diff --git a/src/screen.c b/src/screen.c
index d0f573c..fbfebfc 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -91,7 +91,7 @@ static void screen_push_row_inner(struct term *t, struct srow *row)
if (fill > 0) {
text_row_unshare(tr);
memset(tr->text + tr->text_len, ' ', (size_t)fill);
- text_commit(row, fill, fill, fill, HLINE_NARROW, tr->fill.fg, tr->fill.bg, 0);
+ text_commit(row, fill, fill, fill, HLINE_NARROW, (struct text_pen){ tr->fill.fg, tr->fill.bg, 0 });
}
term_hist_push_text(&t->hist, tr, wrapped);
return;
@@ -193,22 +193,20 @@ const struct cell *term_screen_view_row(const struct term *t, int y)
{
if (!t || y < 0 || y >= t->rows)
return NULL;
- uint64_t id;
- int seg, scr_y;
- if (term_hist_view_row_pos(&t->view, &t->hist, t->cols, t->rows, screen_top_line(t), y,
- &id, &seg, &scr_y)) {
+ struct hist_view_pos pos;
+ if (term_hist_view_row_pos(&t->view, &t->hist, t->cols, t->rows, screen_top_line(t), y, &pos)) {
struct cell *out = t->view_row_scratch;
- int got = term_hist_decode_segment(&t->hist, id, seg, t->cols, out, t->gstore);
+ int got = term_hist_decode_segment(&t->hist, pos.id, pos.seg, t->cols, out, t->gstore);
if (got < t->cols) {
fill_cells(out + got, t->cols - got, TERM_COLOR_FG, TERM_COLOR_BG);
- int line_rows = term_hist_line_rows(&t->hist, id, t->cols);
- if (seg + 1 < line_rows || (id + 1 == hist_end_id(&t->hist) && hist_is_open(&t->hist)))
+ int line_rows = term_hist_line_rows(&t->hist, pos.id, t->cols);
+ if (pos.seg + 1 < line_rows || (pos.id + 1 == hist_end_id(&t->hist) && hist_is_open(&t->hist)))
set_cells_wrap_pad(out + got, t->cols - got);
}
return out;
}
const struct screen *s = term_active_screen(t);
- struct srow *srow = screen_row_at(s, scr_y);
+ struct srow *srow = screen_row_at(s, pos.screen_y);
if (!srow)
return NULL;
struct cell *out = t->view_row_scratch;
@@ -237,18 +235,16 @@ uint64_t term_screen_view_row_key(const struct term *t, int y)
{
if (!t || y < 0 || y >= t->rows)
return 0;
- uint64_t id;
- int seg, scr_y;
- if (term_hist_view_row_pos(&t->view, &t->hist, t->cols, t->rows, screen_top_line(t), y,
- &id, &seg, &scr_y)) {
- uint64_t line_ver = (id + 1 == hist_end_id(&t->hist) && hist_is_open(&t->hist))
- ? (term_hist_line_cells(&t->hist, id) << 32) : 0;
- if (id == t->hist.base_cell_id)
+ struct hist_view_pos pos;
+ if (term_hist_view_row_pos(&t->view, &t->hist, t->cols, t->rows, screen_top_line(t), y, &pos)) {
+ uint64_t line_ver = (pos.id + 1 == hist_end_id(&t->hist) && hist_is_open(&t->hist))
+ ? (term_hist_line_cells(&t->hist, pos.id) << 32) : 0;
+ if (pos.id == t->hist.base_cell_id)
line_ver ^= mix64(t->hist.base_cell);
- return mix64(((uint64_t)id << 16) ^ (uint64_t)seg ^ line_ver ^ 0x517cc1b727220a95ull);
+ return mix64(((uint64_t)pos.id << 16) ^ (uint64_t)pos.seg ^ line_ver ^ 0x517cc1b727220a95ull);
}
const struct screen *s = term_active_screen(t);
- const struct srow *row = screen_row_at(s, scr_y);
+ const struct srow *row = screen_row_at(s, pos.screen_y);
if (!row)
return 0;
return mix64(row->uid ^ ((uint64_t)row->version << 32));