diff options
Diffstat (limited to 'src/screen.h')
| -rw-r--r-- | src/screen.h | 106 |
1 files changed, 53 insertions, 53 deletions
diff --git a/src/screen.h b/src/screen.h index df464a7..1b5d8eb 100644 --- a/src/screen.h +++ b/src/screen.h @@ -1,5 +1,5 @@ -#ifndef TERM_SCREEN_H -#define TERM_SCREEN_H +#ifndef WSAP_VTCORE_SCREEN_H +#define WSAP_VTCORE_SCREEN_H #include <assert.h> #include "compat.h" @@ -7,38 +7,38 @@ #include "kernels.h" #include "simd.h" -void term_screen_scroll_region(struct term *t, int top, int bottom, int count, bool down, bool history); -void term_screen_set_alternate(struct term *t, bool enabled); -void term_screen_erase(struct term *t, int mode); -void term_screen_erase_all(struct term *t); -void term_screen_erase_line(struct term *t, int mode); -void term_screen_delete_chars(struct term *t, int count); -void term_screen_insert_chars(struct term *t, int count); +void wsap_vtcore_screen_scroll_region(struct wsap_vtcore *t, int top, int bottom, int count, bool down, bool history); +void wsap_vtcore_screen_set_alternate(struct wsap_vtcore *t, bool enabled); +void wsap_vtcore_screen_erase(struct wsap_vtcore *t, int mode); +void wsap_vtcore_screen_erase_all(struct wsap_vtcore *t); +void wsap_vtcore_screen_erase_line(struct wsap_vtcore *t, int mode); +void wsap_vtcore_screen_delete_chars(struct wsap_vtcore *t, int count); +void wsap_vtcore_screen_insert_chars(struct wsap_vtcore *t, int count); -const struct cell *term_screen_view_row(const struct term *t, int y); -uint64_t term_screen_view_row_key(const struct term *t, int y); +const struct cell *wsap_vtcore_screen_view_row(const struct wsap_vtcore *t, int y); +uint64_t wsap_vtcore_screen_view_row_key(const struct wsap_vtcore *t, int y); /* The selected columns [c0, c1] of each view row; c1 < c0 when none. */ /* False when memory runs out; c0 and c1 are then not complete. */ -bool term_selection_view_spans(const struct term *t, int *c0, int *c1); +bool wsap_vtcore_selection_view_spans(const struct wsap_vtcore *t, int *c0, int *c1); -int term_screen_history_rows(const struct term *t); +int wsap_vtcore_screen_history_rows(const struct wsap_vtcore *t); /* Rows of history above the live screen. The view owns the offset. */ -int term_view_offset(const struct term *t); +int wsap_vtcore_view_offset(const struct wsap_vtcore *t); -static inline bool screen_has_history(const struct term *t) +static inline bool screen_has_history(const struct wsap_vtcore *t) { return !t->alternate && t->hist.line_limit > 0; } -static inline int phys_row(const struct term *t, int y) +static inline int phys_row(const struct wsap_vtcore *t, int y) { int p = t->scr.top + y; return p >= t->scr.rows ? p - t->scr.rows : p; } -#if defined(TERM_KERNEL_AVX2) -TERM_TARGET_AVX2 +#if defined(WSAP_VTCORE_KERNEL_AVX2) +WSAP_VTCORE_TARGET_AVX2 static inline void set_cells_wrap_pad_avx2(struct cell *cells, int count) { const __m256i mask = _mm256_setr_epi32(0, 0, 0, (int)CELL_WRAP_PAD, @@ -61,8 +61,8 @@ static inline void set_cells_wrap_pad(struct cell *cells, int count) { if (count <= 0) return; -#if defined(TERM_KERNEL_AVX2) - if (term_use_avx2() && count >= 4) { +#if defined(WSAP_VTCORE_KERNEL_AVX2) + if (wsap_vtcore_use_avx2() && count >= 4) { set_cells_wrap_pad_avx2(cells, count); return; } @@ -115,12 +115,12 @@ static inline void init_ascii_text_row(struct text_row *tr, uint8_t *text, uint1 #endif /* The extra lanes cover unused fill data and run padding. */ #if defined(__x86_64__) || defined(_M_X64) - __m128i pen = _mm_setr_epi32(TERM_COLOR_FG, TERM_COLOR_BG, 0, TERM_COLOR_FG); + __m128i pen = _mm_setr_epi32(WSAP_VTCORE_COLOR_FG, WSAP_VTCORE_COLOR_BG, 0, WSAP_VTCORE_COLOR_FG); _mm_storeu_si128((__m128i *)&tr->start, pen); _mm_storeu_si128((__m128i *)&tr->runs.base, pen); _mm_storeu_si128((__m128i *)&tr->runs.pen, pen); #elif defined(__aarch64__) - uint32x4_t pen = { TERM_COLOR_FG, TERM_COLOR_BG, 0, TERM_COLOR_FG }; + uint32x4_t pen = { WSAP_VTCORE_COLOR_FG, WSAP_VTCORE_COLOR_BG, 0, WSAP_VTCORE_COLOR_FG }; vst1q_u32((uint32_t *)&tr->start, pen); vst1q_u32((uint32_t *)&tr->runs.base, pen); vst1q_u32((uint32_t *)&tr->runs.pen, pen); @@ -154,7 +154,7 @@ static inline struct srow *screen_row_at(const struct screen *s, int y) return screen_get_row(s, y); } -static inline struct srow *term_row(const struct term *t, int y) +static inline struct srow *wsap_vtcore_row(const struct wsap_vtcore *t, int y) { return screen_get_row(&t->scr, y); } @@ -165,7 +165,7 @@ static inline int text_row_decode(const struct srow *row, struct cell *out, int { srow_materialize_text((struct srow *)row); const struct text_row *tr = &row->text; - int n = term_hist_text_decode(tr, out, cols, NULL); + int n = wsap_vtcore_hist_text_decode(tr, out, cols, NULL); int fill = tr->fill_to < cols ? tr->fill_to : cols; if (n < fill) { fill_cells(out + n, fill - n, tr->fill.fg, tr->fill.bg); @@ -179,7 +179,7 @@ static inline void text_row_cells(const struct srow *row, struct cell *out, int { int n = text_row_decode(row, out, cols); if (n < cols) - fill_cells(out + n, cols - n, TERM_COLOR_FG, TERM_COLOR_BG); + fill_cells(out + n, cols - n, WSAP_VTCORE_COLOR_FG, WSAP_VTCORE_COLOR_BG); } /* Turn a text row into a cells row. Only the write core does this. Its @@ -190,7 +190,7 @@ static inline void srow_settle(struct srow *row, int cols) if (row->kind == ROW_TEXT) { int n = text_row_decode(row, row->cells, cols); if (n < cols && !(row->flags & RF_TAIL_PADDED)) - fill_cells(row->cells + n, cols - n, TERM_COLOR_FG, TERM_COLOR_BG); + fill_cells(row->cells + n, cols - n, WSAP_VTCORE_COLOR_FG, WSAP_VTCORE_COLOR_BG); row->flags |= RF_TAIL_PADDED; row->kind = ROW_CELLS; } @@ -203,9 +203,9 @@ static inline void srow_settle(struct srow *row, int cols) * history, so they keep the history format. NULL when neither holds. The * caller has handled a pending wrap, insert mode, and margins. */ -static inline struct srow *text_append_row(struct term *t) +static inline struct srow *text_append_row(struct wsap_vtcore *t) { - struct srow *row = term_row(t, t->cursor_y); + struct srow *row = wsap_vtcore_row(t, t->cursor_y); if (row->kind == ROW_TEXT) { text_row_unshare(&row->text); if (t->cursor_x != row->text.cells) @@ -220,7 +220,7 @@ static inline struct srow *text_append_row(struct term *t) * history can copy its runs. */ struct pen_attr start = pen_attr_default(); if (t->cursor_y > 0) { - const struct srow *prev = term_row(t, t->cursor_y - 1); + const struct srow *prev = wsap_vtcore_row(t, t->cursor_y - 1); if (prev->kind == ROW_TEXT && (prev->flags & RF_WRAPPED)) start = prev->text.runs.pen; } @@ -263,7 +263,7 @@ static inline void text_append(struct srow *row, const uint8_t *bytes, int nbyte text_commit(row, nbytes, chars, cells, hflags, pen); } -static inline struct cell *row_cells(const struct term *t, int p) +static inline struct cell *row_cells(const struct wsap_vtcore *t, int p) { struct srow *row = &t->scr.slot[p]; if (row->kind != ROW_CELLS) @@ -276,14 +276,14 @@ static inline struct cell *row_cells(const struct term *t, int p) * or a resize can never leave a stale id behind. */ /* The logical line of screen row 0, and the row's segment in it. */ -static inline struct line_pos screen_top_line(const struct term *t) +static inline struct line_pos screen_top_line(const struct wsap_vtcore *t) { if (!screen_has_history(t)) return (struct line_pos){ t->scr.top_id, t->scr.top_seg }; uint64_t end = hist_end_id(&t->hist); if (!hist_is_open(&t->hist)) return (struct line_pos){ end, 0 }; - return (struct line_pos){ end - 1, (uint32_t)term_hist_line_rows(&t->hist, end - 1, t->cols) }; + return (struct line_pos){ end - 1, (uint32_t)wsap_vtcore_hist_line_rows(&t->hist, end - 1, t->cols) }; } static inline struct line_pos line_pos_next(struct line_pos p, const struct srow *row) @@ -293,7 +293,7 @@ static inline struct line_pos line_pos_next(struct line_pos p, const struct srow } /* The oldest line that history or the screen still holds. */ -static inline uint64_t first_retained_line(const struct term *t) +static inline uint64_t first_retained_line(const struct wsap_vtcore *t) { if (screen_has_history(t) && t->hist.lines) return hist_first_id(&t->hist); @@ -329,12 +329,12 @@ static inline void repair_wide_row(struct cell *row, int from, int to, int cols, } } -static inline bool using_default_colors(const struct term *t) +static inline bool using_default_colors(const struct wsap_vtcore *t) { - return t->cur_fg == TERM_COLOR_FG && t->cur_bg == TERM_COLOR_BG; + return t->cur_fg == WSAP_VTCORE_COLOR_FG && t->cur_bg == WSAP_VTCORE_COLOR_BG; } -static inline void mark_row_blank(struct term *t, int p) +static inline void mark_row_blank(struct wsap_vtcore *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) @@ -345,11 +345,11 @@ static inline void mark_row_blank(struct term *t, int p) row->version++; } -static inline void term_row_fill_gap(struct srow *row, int x) +static inline void wsap_vtcore_row_fill_gap(struct srow *row, int x) { if (x > row->len) { if (!(row->flags & RF_TAIL_PADDED)) - fill_cells(row->cells + row->len, x - row->len, TERM_COLOR_FG, TERM_COLOR_BG); + fill_cells(row->cells + row->len, x - row->len, WSAP_VTCORE_COLOR_FG, WSAP_VTCORE_COLOR_BG); row->len = (uint16_t)x; } } @@ -365,12 +365,12 @@ static inline void write_cell_span(struct cell *row, int x, } } -static inline void erase_span(struct term *t, int p, int from, int to) +static inline void erase_span(struct wsap_vtcore *t, int p, int from, int to) { bool pristine = using_default_colors(t); struct srow *row = &t->scr.slot[p]; int len = row->len; - if (to > TERM_MAX_COLS) to = TERM_MAX_COLS; + if (to > WSAP_VTCORE_MAX_COLS) to = WSAP_VTCORE_MAX_COLS; if (pristine && to > len) to = len; if (from >= to) return; @@ -385,7 +385,7 @@ static inline void erase_span(struct term *t, int p, int from, int to) row_set_wrapped(row, false); if (!pristine) { - term_row_fill_gap(row, from); + wsap_vtcore_row_fill_gap(row, from); fill_cells(cells + from, to - from, t->cur_fg, t->cur_bg); if (to > len) { row->len = (uint16_t)to; @@ -409,19 +409,19 @@ static inline void erase_span(struct term *t, int p, int from, int to) } } -static inline int erase_width(const struct term *t, int p) +static inline int erase_width(const struct wsap_vtcore *t, int p) { return t->scr.slot[p].len > t->cols ? t->scr.slot[p].len : t->cols; } -static inline void erase_row(struct term *t, int p) +static inline void erase_row(struct wsap_vtcore *t, int p) { erase_span(t, p, 0, erase_width(t, p)); } -static inline void clamp_selection_after_scroll(struct term *t) +static inline void clamp_selection_after_scroll(struct wsap_vtcore *t) { - if (TERM_EXPECT(!t->selection, 1)) + if (WSAP_VTCORE_EXPECT(!t->selection, 1)) return; uint64_t first_id = first_retained_line(t); if (t->sel_end.line_id < first_id) { @@ -433,7 +433,7 @@ static inline void clamp_selection_after_scroll(struct term *t) } /* Move a row that leaves the top of the normal screen into history. */ -void term_screen_push_row(struct term *t, struct srow *row); +void wsap_vtcore_screen_push_row(struct wsap_vtcore *t, struct srow *row); /* Count a row that leaves the top of a screen without history. */ static inline void screen_drop_top(struct screen *s, const struct srow *row) @@ -445,33 +445,33 @@ static inline void screen_drop_top(struct screen *s, const struct srow *row) /* Clear a row that enters at the bottom. With a colored pen it is a text row * that is all fill: blanks in the pen colors, which text can append over. */ -static inline void screen_new_row(struct term *t, struct srow *row) +static inline void screen_new_row(struct wsap_vtcore *t, struct srow *row) { row->uid = ++t->next_row_uid; row->version++; row->flags = ((row->kind == ROW_CELLS && row->len == 0) || row->kind == ROW_TEXT) ? (row->flags & RF_TAIL_PADDED) : 0; - if (TERM_EXPECT(using_default_colors(t), 1)) { + if (WSAP_VTCORE_EXPECT(using_default_colors(t), 1)) { row->kind = ROW_CELLS; row->len = 0; } else { row->kind = ROW_TEXT; - text_row_start(&row->text, &(struct pen_attr){ .fg = TERM_COLOR_FG, .bg = TERM_COLOR_BG }); + text_row_start(&row->text, &(struct pen_attr){ .fg = WSAP_VTCORE_COLOR_FG, .bg = WSAP_VTCORE_COLOR_BG }); row->text.fill_to = (uint16_t)t->scr.cols; row->text.fill = (struct pen_attr){ .fg = t->cur_fg, .bg = t->cur_bg }; row->len = (uint16_t)t->scr.cols; } } -static inline void term_screen_scroll_up(struct term *t) +static inline void wsap_vtcore_screen_scroll_up(struct wsap_vtcore *t) { struct screen *s = &t->scr; struct srow *row = &s->slot[s->top]; - if (TERM_EXPECT(screen_has_history(t), 1)) - term_screen_push_row(t, row); + if (WSAP_VTCORE_EXPECT(screen_has_history(t), 1)) + wsap_vtcore_screen_push_row(t, row); else screen_drop_top(s, row); - if (TERM_EXPECT(t->prompt_y > 0, 0) && !t->alternate) + if (WSAP_VTCORE_EXPECT(t->prompt_y > 0, 0) && !t->alternate) t->prompt_y--; s->top = s->top + 1 == s->rows ? 0 : s->top + 1; clamp_selection_after_scroll(t); |
