diff options
Diffstat (limited to 'src/screen.c')
| -rw-r--r-- | src/screen.c | 68 |
1 files changed, 11 insertions, 57 deletions
diff --git a/src/screen.c b/src/screen.c index 99e788c..d9dfe31 100644 --- a/src/screen.c +++ b/src/screen.c @@ -145,50 +145,6 @@ int term_history_rows(const struct term *t) return rows; } -const struct cell *term_ring_row(const struct term *t, int row) -{ - if (!t) - return NULL; - int total = term_screen_history_rows(t); - if (row < 0 || row >= total + t->rows) - return NULL; - - if (row < total) { - uint64_t id; - int seg; - if (!term_hist_view_find_row(&t->view, &t->hist, row, t->cols, &id, &seg)) - return NULL; - struct cell *out = t->view_row_scratch; - int got = term_hist_decode_segment(&t->hist, id, 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 || (row + 1 == total && hist_is_open(&t->hist))) - set_cells_wrap_pad(out + got, t->cols - got); - } - return out; - } - - int y = row - total; - const struct screen *s = term_active_screen(t); - struct srow *srow = screen_row_at(s, y); - if (!srow) - return NULL; - - struct cell *out = t->view_row_scratch; - if (srow->kind == ROW_CELLS) { - if (srow->len >= t->cols || (srow->flags & RF_TAIL_PADDED)) - return srow->cells; - if (srow->len > 0) - memcpy(out, srow->cells, (size_t)srow->len * sizeof(struct cell)); - fill_cells(out + srow->len, t->cols - srow->len, TERM_COLOR_FG, TERM_COLOR_BG); - return out; - } - - text_row_cells(srow, out, t->cols); - return out; -} - const struct cell *term_screen_view_row(const struct term *t, int y) { if (!t || y < 0 || y >= t->rows) @@ -205,8 +161,7 @@ const struct cell *term_screen_view_row(const struct term *t, int y) } return out; } - const struct screen *s = term_active_screen(t); - struct srow *srow = screen_row_at(s, pos.screen_y); + struct srow *srow = screen_row_at(&t->scr, pos.screen_y); if (!srow) return NULL; struct cell *out = t->view_row_scratch; @@ -243,8 +198,7 @@ uint64_t term_screen_view_row_key(const struct term *t, int y) line_ver ^= mix64(t->hist.base_cell); 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, pos.screen_y); + const struct srow *row = screen_row_at(&t->scr, pos.screen_y); if (!row) return 0; return mix64(row->uid ^ ((uint64_t)row->version << 32)); @@ -544,7 +498,8 @@ void term_screen_erase(struct term *t, int mode) t->pending_wrap = false; if (mode == 3) { term_hist_clear(&t->hist); - term_hist_view_clear(&t->view); + t->view.anchor = (struct view_anchor){0}; + t->view.index_cols = 0; term_select_clear(t); t->full_gen++; return; @@ -573,12 +528,12 @@ void term_screen_erase(struct term *t, int mode) if (last_active >= 0 && !t->alternate) { term_screen_scroll_region(t, 0, rows - 1, last_active + 1, false, true); if (tail_clean) { - term_hist_view_reset_bottom(&t->view); + t->view.anchor = (struct view_anchor){0}; return; } } term_screen_erase_all(t); - term_hist_view_reset_bottom(&t->view); + t->view.anchor = (struct view_anchor){0}; t->full_gen++; } else if (mode == 0) { int cur_p = phys_row(t, t->cursor_y); @@ -674,7 +629,7 @@ void term_screen_scroll_region(struct term *t, int top, int bottom, int count, /* Whole active screen scroll: optimize using ring rotation. */ if (top == 0 && bottom == t->rows - 1) { - struct screen *s = term_active_screen(t); + struct screen *s = &t->scr; int rows = s->rows; int orig_top = s->top; bool def = using_default_colors(t); @@ -770,7 +725,7 @@ void term_screen_scroll_region(struct term *t, int top, int bottom, int count, return; } - struct screen *s = term_active_screen(t); + struct screen *s = &t->scr; bool def = using_default_colors(t); if (count == height) { @@ -880,7 +835,7 @@ void term_screen_set_alternate(struct term *t, bool enabled) t->left_margin = 0; t->right_margin = t->cols - 1; /* The alternate screen has no history to show. */ - term_hist_view_reset_bottom(&t->view); + t->view.anchor = (struct view_anchor){0}; term_select_clear(t); t->full_gen++; } else { @@ -907,7 +862,7 @@ void term_screen_set_alternate(struct term *t, bool enabled) t->left_margin = 0; t->right_margin = t->cols - 1; /* The alternate screen has no history to show. */ - term_hist_view_reset_bottom(&t->view); + t->view.anchor = (struct view_anchor){0}; term_select_clear(t); t->full_gen++; } @@ -986,7 +941,6 @@ struct term *term_new(const struct term_options *opt) return NULL; } t->hist.wrap_cols = (uint16_t)cols; - term_hist_view_init(&t->view); t->gstore = term_gstore_new(t); t->view_scratch_cap = cols > 256 ? cols : 256; @@ -1338,7 +1292,7 @@ static bool term_resize_internal(struct term *t, int cols, int rows) term_gstore_pin(t->gstore); if (t->alternate || cols == t->scr.cols) { - struct screen *active_scr = term_active_screen(t); + struct screen *active_scr = &t->scr; int old_cols = active_scr->cols; int old_rows = active_scr->rows; |
