From dcebf9c7f954a55350b68d0ead1935612c4e2e05 Mon Sep 17 00:00:00 2001 From: Berke Güzel Date: Thu, 15 Oct 2026 13:04:01 +0300 Subject: Rename the library to wsap_vtcore ncurses installs and defines struct term. In a file that includes both headers, an ncurses TERMINAL * and this library's terminal are silently the same type. The name wsap_vtcore avoids the clash. The public header is now . Every global symbol uses the wsap_vtcore_ prefix, every macro uses WSAP_VTCORE_, and the shared library is libwsap_vtcore.so.0. The default terminal name is now "wsap_vtcore". The ISA override variable is WSAP_VTCORE_ISA. No other behavior changes. The amalgamation writes wsap_vtcore.c and wsap_vtcore.h. Co-Authored-By: Claude Haiku 5.5 --- tests/model.c | 226 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 113 insertions(+), 113 deletions(-) (limited to 'tests/model.c') diff --git a/tests/model.c b/tests/model.c index 6c9f288..bd8c6c7 100644 --- a/tests/model.c +++ b/tests/model.c @@ -13,7 +13,7 @@ * current terminal, and the macro names the phase that removes it. */ #include "model.h" -#include "term/unicode/unicode.h" +#include "wsap_vtcore/unicode/unicode.h" #include #include @@ -31,10 +31,10 @@ #define STR_KEEP 1024 struct cell { - uint32_t cp[TERM_GRAPHEME_MAX_LEN]; + uint32_t cp[WSAP_VTCORE_GRAPHEME_MAX_LEN]; uint8_t n, width; uint16_t attrs; - term_color fg, bg; + wsap_vtcore_color fg, bg; bool pad; /* the blank that a wide glyph left at a row end */ }; @@ -50,8 +50,8 @@ struct row { }; struct pen { - term_color fg, bg, ul; - uint16_t attrs; /* TERM_ATTR_* style bits and the underline style */ + wsap_vtcore_color fg, bg, ul; + uint16_t attrs; /* WSAP_VTCORE_ATTR_* style bits and the underline style */ bool inverse; }; @@ -99,7 +99,7 @@ struct model { bool tabs[MAX_TABS]; struct keyboard keyboard[2]; /* The last printed glyph, for REP and cluster joins. */ - uint32_t last[TERM_GRAPHEME_MAX_LEN]; + uint32_t last[WSAP_VTCORE_GRAPHEME_MAX_LEN]; int last_n; int prompt; /* screen row of the last OSC 133;A, or -1 */ unsigned flags; @@ -124,14 +124,14 @@ struct model { /* ---- cells and rows ---- */ -static struct cell blank(term_color fg, term_color bg) +static struct cell blank(wsap_vtcore_color fg, wsap_vtcore_color bg) { return (struct cell){ .cp = { ' ' }, .n = 1, .width = 1, .fg = fg, .bg = bg }; } static struct cell default_blank(void) { - return blank(TERM_COLOR_FG, TERM_COLOR_BG); + return blank(WSAP_VTCORE_COLOR_FG, WSAP_VTCORE_COLOR_BG); } static struct row *row_new(int cols) @@ -154,12 +154,12 @@ static void row_cut(struct row *r, int n, int cols) static bool pristine(const struct model *m) { - return m->pen.fg == TERM_COLOR_FG && m->pen.bg == TERM_COLOR_BG; + return m->pen.fg == WSAP_VTCORE_COLOR_FG && m->pen.bg == WSAP_VTCORE_COLOR_BG; } static bool is_ri(uint32_t cp) { - return cp - 0x1F1E6u <= 0x19u && term_grapheme_regional_indicator(cp); + return cp - 0x1F1E6u <= 0x19u && wsap_vtcore_grapheme_regional_indicator(cp); } /* ---- replies ---- */ @@ -185,7 +185,7 @@ static void __attribute__((format(printf, 2, 3))) reply(struct model *m, const c static int history_limit(int requested) { - return requested == 0 ? TERM_SCROLLBACK_DEFAULT : requested < 0 ? 0 : requested; + return requested == 0 ? WSAP_VTCORE_SCROLLBACK_DEFAULT : requested < 0 ? 0 : requested; } static void hist_reflow_tail(struct model *m); @@ -229,7 +229,7 @@ static void hist_push(struct model *m, struct row *r) hist_reflow_tail(m); } -static void term_hist_clear(struct model *m) +static void wsap_vtcore_hist_clear(struct model *m) { for (int i = 0; i < m->hist_len; i++) free(m->hist[i]); m->hist_len = 0; @@ -355,7 +355,7 @@ static int last_text_row(const struct model *m) static void erase_display(struct model *m, int mode) { if (mode == 3) { - term_hist_clear(m); + wsap_vtcore_hist_clear(m); return; } if (mode == 2) { @@ -418,17 +418,17 @@ static void fill_gap(struct row *r, int x) static uint16_t presentation(const uint32_t *cps, int n) { - bool pictographic = term_unicode_extended_pictographic(cps[0]); + bool pictographic = wsap_vtcore_unicode_extended_pictographic(cps[0]); bool emoji = false; for (int i = 1; i < n; i++) { - if (cps[i] == 0xFE0F) return TERM_ATTR_EMOJI; - if (cps[i] == 0xFE0E) return TERM_ATTR_TEXT; - if (cps[i] == 0x20E3 || term_grapheme_regional_indicator(cps[i]) || - (pictographic && (cps[i] == 0x200D || term_grapheme_emoji_modifier(cps[i]) || + if (cps[i] == 0xFE0F) return WSAP_VTCORE_ATTR_EMOJI; + if (cps[i] == 0xFE0E) return WSAP_VTCORE_ATTR_TEXT; + if (cps[i] == 0x20E3 || wsap_vtcore_grapheme_regional_indicator(cps[i]) || + (pictographic && (cps[i] == 0x200D || wsap_vtcore_grapheme_emoji_modifier(cps[i]) || (cps[i] >= 0xE0020 && cps[i] <= 0xE007F)))) emoji = true; } - return emoji ? TERM_ATTR_EMOJI : 0; + return emoji ? WSAP_VTCORE_ATTR_EMOJI : 0; } static void wrap_to_next_row(struct model *m) @@ -443,10 +443,10 @@ static void wrap_to_next_row(struct model *m) static void put_glyph(struct model *m, const uint32_t *cps, int n, uint16_t attrs) { if (n > 1) - attrs = (uint16_t)((attrs & ~(TERM_ATTR_EMOJI | TERM_ATTR_TEXT)) | presentation(cps, n)); - int width = term_unicode_width(cps[0]) == 2 ? 2 : 1; - if (attrs & TERM_ATTR_EMOJI) width = 2; - if (attrs & TERM_ATTR_TEXT) width = 1; + attrs = (uint16_t)((attrs & ~(WSAP_VTCORE_ATTR_EMOJI | WSAP_VTCORE_ATTR_TEXT)) | presentation(cps, n)); + int width = wsap_vtcore_unicode_width(cps[0]) == 2 ? 2 : 1; + if (attrs & WSAP_VTCORE_ATTR_EMOJI) width = 2; + if (attrs & WSAP_VTCORE_ATTR_TEXT) width = 1; if (m->pending) wrap_to_next_row(m); int right = m->cols - 1; struct row *r = m->scr[m->y]; @@ -496,14 +496,14 @@ static void put_glyph(struct model *m, const uint32_t *cps, int n, uint16_t attr static bool joins(uint32_t cp, int width) { if (cp < 0x300) return false; - return width == 0 || term_grapheme_emoji_modifier(cp) || - (width == 1 && term_unicode_spacing_mark(cp)); + return width == 0 || wsap_vtcore_grapheme_emoji_modifier(cp) || + (width == 1 && wsap_vtcore_unicode_spacing_mark(cp)); } static bool cluster_joins(const uint32_t *cps, int n, uint32_t cp, int width) { if (joins(cp, width)) return true; - if (cps[n - 1] == 0x200D) return term_unicode_extended_pictographic(cp); + if (cps[n - 1] == 0x200D) return wsap_vtcore_unicode_extended_pictographic(cp); return n == 1 && is_ri(cp) && is_ri(cps[0]); } @@ -528,10 +528,10 @@ static bool extend_cluster(struct model *m, uint32_t cp, int width) return joins(cp, width); if (!cluster_joins(prev->cp, prev->n, cp, width)) return false; - if (prev->n >= TERM_GRAPHEME_MAX_LEN) + if (prev->n >= WSAP_VTCORE_GRAPHEME_MAX_LEN) return true; struct cell old = *prev; - uint32_t cps[TERM_GRAPHEME_MAX_LEN]; + uint32_t cps[WSAP_VTCORE_GRAPHEME_MAX_LEN]; memcpy(cps, old.cp, (size_t)old.n * sizeof(*cps)); cps[old.n] = cp; int n = old.n + 1; @@ -542,7 +542,7 @@ static bool extend_cluster(struct model *m, uint32_t cp, int width) m->pending = false; memcpy(m->last, cps, (size_t)n * sizeof(*cps)); m->last_n = n; - put_glyph(m, cps, n, (uint16_t)(old.attrs & ~(TERM_ATTR_EMOJI | TERM_ATTR_TEXT))); + put_glyph(m, cps, n, (uint16_t)(old.attrs & ~(WSAP_VTCORE_ATTR_EMOJI | WSAP_VTCORE_ATTR_TEXT))); r = m->scr[m->y]; x = m->pending ? m->cols - 1 : m->x - 1; if (x > 0 && r->c[x].width == 0) x--; @@ -591,7 +591,7 @@ static void print_cp(struct model *m, uint32_t cp) emit(m, cp); return; } - int width = term_unicode_width(cp); + int width = wsap_vtcore_unicode_width(cp); if (!extend_cluster(m, cp, width)) emit(m, cp); } @@ -655,7 +655,7 @@ static void restore_cursor(struct model *m, const struct saved *s) static struct saved initial_saved(void) { return (struct saved){ - .pen = { .fg = TERM_COLOR_FG, .bg = TERM_COLOR_BG }, + .pen = { .fg = WSAP_VTCORE_COLOR_FG, .bg = WSAP_VTCORE_COLOR_BG }, .g = { 'B', 'B' }, }; } @@ -723,28 +723,28 @@ static void insert_chars(struct model *m, int n) static void pen_reset(struct pen *p) { - *p = (struct pen){ .fg = TERM_COLOR_FG, .bg = TERM_COLOR_BG }; + *p = (struct pen){ .fg = WSAP_VTCORE_COLOR_FG, .bg = WSAP_VTCORE_COLOR_BG }; } static void set_underline(uint16_t *attrs, int style) { static const uint16_t flags[] = { - 0, TERM_ATTR_UNDERLINE, TERM_ATTR_DOUBLE_UNDERLINE, - TERM_ATTR_CURLY_UNDERLINE, TERM_ATTR_DOTTED_UNDERLINE, TERM_ATTR_DASHED_UNDERLINE, + 0, WSAP_VTCORE_ATTR_UNDERLINE, WSAP_VTCORE_ATTR_DOUBLE_UNDERLINE, + WSAP_VTCORE_ATTR_CURLY_UNDERLINE, WSAP_VTCORE_ATTR_DOTTED_UNDERLINE, WSAP_VTCORE_ATTR_DASHED_UNDERLINE, }; if ((unsigned)style > 5) style = 1; - *attrs = (uint16_t)((*attrs & ~TERM_ATTR_UNDERLINE_MASK) | flags[style]); + *attrs = (uint16_t)((*attrs & ~WSAP_VTCORE_ATTR_UNDERLINE_MASK) | flags[style]); } /* 38, 48, and 58. Returns the parameters it used after the first. */ -static int extended_color(const struct model *m, int i, term_color *color, bool *ok) +static int extended_color(const struct model *m, int i, wsap_vtcore_color *color, bool *ok) { *ok = false; if (i + 1 >= m->nparam) return 0; if (i + 2 < m->nparam && m->param[i + 1] == 5) { int index = m->param[i + 2]; if (index >= 0 && index <= 255) { - *color = term_color_index(index); + *color = wsap_vtcore_color_index(index); *ok = true; } return 2; @@ -756,7 +756,7 @@ static int extended_color(const struct model *m, int i, term_color *color, bool colon++; int skip = colon >= 4 ? 1 : 0; if (i + 4 + skip >= m->nparam) return 0; - *color = term_color_rgb((uint8_t)m->param[i + 2 + skip], (uint8_t)m->param[i + 3 + skip], + *color = wsap_vtcore_color_rgb((uint8_t)m->param[i + 2 + skip], (uint8_t)m->param[i + 3 + skip], (uint8_t)m->param[i + 4 + skip]); *ok = true; return 4 + skip; @@ -771,13 +771,13 @@ static void sgr(struct model *m) } for (int i = 0; i < m->nparam; i++) { int v = m->param[i]; - term_color color; + wsap_vtcore_color color; bool ok; switch (v) { case 0: pen_reset(p); break; - case 1: p->attrs |= TERM_ATTR_BOLD; break; - case 2: p->attrs |= TERM_ATTR_FAINT; break; - case 3: p->attrs |= TERM_ATTR_ITALIC; break; + case 1: p->attrs |= WSAP_VTCORE_ATTR_BOLD; break; + case 2: p->attrs |= WSAP_VTCORE_ATTR_FAINT; break; + case 3: p->attrs |= WSAP_VTCORE_ATTR_ITALIC; break; case 4: { int style = 1; if (i + 1 < m->nparam && (m->sub & (1u << (i + 1)))) @@ -786,26 +786,26 @@ static void sgr(struct model *m) break; } case 7: p->inverse = true; break; - case 9: p->attrs |= TERM_ATTR_STRIKE; break; + case 9: p->attrs |= WSAP_VTCORE_ATTR_STRIKE; break; case 21: set_underline(&p->attrs, 2); break; - case 22: p->attrs &= (uint16_t)~(TERM_ATTR_BOLD | TERM_ATTR_FAINT); break; - case 23: p->attrs &= (uint16_t)~TERM_ATTR_ITALIC; break; + case 22: p->attrs &= (uint16_t)~(WSAP_VTCORE_ATTR_BOLD | WSAP_VTCORE_ATTR_FAINT); break; + case 23: p->attrs &= (uint16_t)~WSAP_VTCORE_ATTR_ITALIC; break; case 24: set_underline(&p->attrs, 0); break; case 27: p->inverse = false; break; - case 29: p->attrs &= (uint16_t)~TERM_ATTR_STRIKE; break; + case 29: p->attrs &= (uint16_t)~WSAP_VTCORE_ATTR_STRIKE; break; case 38: i += extended_color(m, i, &color, &ok); if (ok) p->fg = color; break; - case 39: p->fg = TERM_COLOR_FG; break; + case 39: p->fg = WSAP_VTCORE_COLOR_FG; break; case 48: i += extended_color(m, i, &color, &ok); if (ok) p->bg = color; break; - case 49: p->bg = TERM_COLOR_BG; break; - case 53: p->attrs |= TERM_ATTR_OVERLINE; break; - case 55: p->attrs &= (uint16_t)~TERM_ATTR_OVERLINE; break; + case 49: p->bg = WSAP_VTCORE_COLOR_BG; break; + case 53: p->attrs |= WSAP_VTCORE_ATTR_OVERLINE; break; + case 55: p->attrs &= (uint16_t)~WSAP_VTCORE_ATTR_OVERLINE; break; case 58: i += extended_color(m, i, &color, &ok); if (ok) p->ul = color; break; case 59: p->ul = 0; break; default: - if (v >= 30 && v <= 37) p->fg = term_color_index(v - 30); - else if (v >= 40 && v <= 47) p->bg = term_color_index(v - 40); - else if (v >= 90 && v <= 97) p->fg = term_color_index(v - 90 + 8); - else if (v >= 100 && v <= 107) p->bg = term_color_index(v - 100 + 8); + if (v >= 30 && v <= 37) p->fg = wsap_vtcore_color_index(v - 30); + else if (v >= 40 && v <= 47) p->bg = wsap_vtcore_color_index(v - 40); + else if (v >= 90 && v <= 97) p->fg = wsap_vtcore_color_index(v - 90 + 8); + else if (v >= 100 && v <= 107) p->bg = wsap_vtcore_color_index(v - 100 + 8); break; } } @@ -818,27 +818,27 @@ static void sgr_report(const struct model *m, char *out, size_t cap) size_t n = 0; out[0] = 0; #define ADD(...) do { int k = snprintf(out + n, cap - n, __VA_ARGS__); if (k > 0) n += (size_t)k; } while (0) - int ul = term_attr_underline(p->attrs); - if (!(p->attrs & (TERM_ATTR_BOLD | TERM_ATTR_FAINT | TERM_ATTR_ITALIC | TERM_ATTR_STRIKE | - TERM_ATTR_OVERLINE | TERM_ATTR_UNDERLINE_MASK)) && - !p->inverse && p->fg == TERM_COLOR_FG && p->bg == TERM_COLOR_BG && !p->ul) + int ul = wsap_vtcore_attr_underline(p->attrs); + if (!(p->attrs & (WSAP_VTCORE_ATTR_BOLD | WSAP_VTCORE_ATTR_FAINT | WSAP_VTCORE_ATTR_ITALIC | WSAP_VTCORE_ATTR_STRIKE | + WSAP_VTCORE_ATTR_OVERLINE | WSAP_VTCORE_ATTR_UNDERLINE_MASK)) && + !p->inverse && p->fg == WSAP_VTCORE_COLOR_FG && p->bg == WSAP_VTCORE_COLOR_BG && !p->ul) return; ADD("0"); - if (p->attrs & TERM_ATTR_BOLD) ADD(";1"); - if (p->attrs & TERM_ATTR_FAINT) ADD(";2"); - if (p->attrs & TERM_ATTR_ITALIC) ADD(";3"); + if (p->attrs & WSAP_VTCORE_ATTR_BOLD) ADD(";1"); + if (p->attrs & WSAP_VTCORE_ATTR_FAINT) ADD(";2"); + if (p->attrs & WSAP_VTCORE_ATTR_ITALIC) ADD(";3"); if (ul == 1) ADD(";4"); else if (ul) ADD(";4:%d", ul); if (p->inverse) ADD(";7"); - if (p->attrs & TERM_ATTR_STRIKE) ADD(";9"); - if (p->attrs & TERM_ATTR_OVERLINE) ADD(";53"); - const term_color colors[3] = { p->fg, p->bg, p->ul }; - const bool set[3] = { p->fg != TERM_COLOR_FG, p->bg != TERM_COLOR_BG, p->ul != 0 }; + if (p->attrs & WSAP_VTCORE_ATTR_STRIKE) ADD(";9"); + if (p->attrs & WSAP_VTCORE_ATTR_OVERLINE) ADD(";53"); + const wsap_vtcore_color colors[3] = { p->fg, p->bg, p->ul }; + const bool set[3] = { p->fg != WSAP_VTCORE_COLOR_FG, p->bg != WSAP_VTCORE_COLOR_BG, p->ul != 0 }; for (int k = 0; k < 3; k++) { if (!set[k]) continue; int base = 30 + 10 * k; - term_color c = colors[k]; - if (term_color_is_slot(c) && (c & 0x1FFu) < 256) { + wsap_vtcore_color c = colors[k]; + if (wsap_vtcore_color_is_slot(c) && (c & 0x1FFu) < 256) { int i = (int)(c & 0xFFu); if (i < 16 && k < 2) ADD(";%d", i < 8 ? base + i : base + 60 + i - 8); else ADD(";%d:5:%d", base + 8, i); @@ -856,24 +856,24 @@ static void sgr_report(const struct model *m, char *out, size_t cap) static void cara_cell(struct model *m, struct cell *c) { if (m->nparam <= 4) { - c->fg = TERM_COLOR_FG; - c->bg = TERM_COLOR_BG; - c->attrs &= TERM_ATTR_EMOJI | TERM_ATTR_TEXT | TERM_ATTR_LINK; + c->fg = WSAP_VTCORE_COLOR_FG; + c->bg = WSAP_VTCORE_COLOR_BG; + c->attrs &= WSAP_VTCORE_ATTR_EMOJI | WSAP_VTCORE_ATTR_TEXT | WSAP_VTCORE_ATTR_LINK; return; } for (int i = 4; i < m->nparam; i++) { int v = m->param[i]; - term_color color; + wsap_vtcore_color color; bool ok; switch (v) { case 0: - c->fg = TERM_COLOR_FG; - c->bg = TERM_COLOR_BG; - c->attrs &= TERM_ATTR_EMOJI | TERM_ATTR_TEXT | TERM_ATTR_LINK; + c->fg = WSAP_VTCORE_COLOR_FG; + c->bg = WSAP_VTCORE_COLOR_BG; + c->attrs &= WSAP_VTCORE_ATTR_EMOJI | WSAP_VTCORE_ATTR_TEXT | WSAP_VTCORE_ATTR_LINK; break; - case 1: c->attrs |= TERM_ATTR_BOLD; break; - case 2: c->attrs |= TERM_ATTR_FAINT; break; - case 3: c->attrs |= TERM_ATTR_ITALIC; break; + case 1: c->attrs |= WSAP_VTCORE_ATTR_BOLD; break; + case 2: c->attrs |= WSAP_VTCORE_ATTR_FAINT; break; + case 3: c->attrs |= WSAP_VTCORE_ATTR_ITALIC; break; case 4: { int style = 1; if (i + 1 < m->nparam && (m->sub & (1u << (i + 1)))) @@ -881,25 +881,25 @@ static void cara_cell(struct model *m, struct cell *c) set_underline(&c->attrs, style); break; } - case 7: { term_color t = c->fg; c->fg = c->bg; c->bg = t; break; } - case 9: c->attrs |= TERM_ATTR_STRIKE; break; + case 7: { wsap_vtcore_color t = c->fg; c->fg = c->bg; c->bg = t; break; } + case 9: c->attrs |= WSAP_VTCORE_ATTR_STRIKE; break; case 21: set_underline(&c->attrs, 2); break; - case 22: c->attrs &= (uint16_t)~(TERM_ATTR_BOLD | TERM_ATTR_FAINT); break; - case 23: c->attrs &= (uint16_t)~TERM_ATTR_ITALIC; break; + case 22: c->attrs &= (uint16_t)~(WSAP_VTCORE_ATTR_BOLD | WSAP_VTCORE_ATTR_FAINT); break; + case 23: c->attrs &= (uint16_t)~WSAP_VTCORE_ATTR_ITALIC; break; case 24: set_underline(&c->attrs, 0); break; - case 29: c->attrs &= (uint16_t)~TERM_ATTR_STRIKE; break; + case 29: c->attrs &= (uint16_t)~WSAP_VTCORE_ATTR_STRIKE; break; case 38: i += extended_color(m, i, &color, &ok); if (ok) c->fg = color; break; - case 39: c->fg = TERM_COLOR_FG; break; + case 39: c->fg = WSAP_VTCORE_COLOR_FG; break; case 48: i += extended_color(m, i, &color, &ok); if (ok) c->bg = color; break; - case 49: c->bg = TERM_COLOR_BG; break; - case 53: c->attrs |= TERM_ATTR_OVERLINE; break; - case 55: c->attrs &= (uint16_t)~TERM_ATTR_OVERLINE; break; + case 49: c->bg = WSAP_VTCORE_COLOR_BG; break; + case 53: c->attrs |= WSAP_VTCORE_ATTR_OVERLINE; break; + case 55: c->attrs &= (uint16_t)~WSAP_VTCORE_ATTR_OVERLINE; break; case 58: i += extended_color(m, i, &color, &ok); break; default: - if (v >= 30 && v <= 37) c->fg = term_color_index(v - 30); - else if (v >= 40 && v <= 47) c->bg = term_color_index(v - 40); - else if (v >= 90 && v <= 97) c->fg = term_color_index(v - 90 + 8); - else if (v >= 100 && v <= 107) c->bg = term_color_index(v - 100 + 8); + if (v >= 30 && v <= 37) c->fg = wsap_vtcore_color_index(v - 30); + else if (v >= 40 && v <= 47) c->bg = wsap_vtcore_color_index(v - 40); + else if (v >= 90 && v <= 97) c->fg = wsap_vtcore_color_index(v - 90 + 8); + else if (v >= 100 && v <= 107) c->bg = wsap_vtcore_color_index(v - 100 + 8); break; } } @@ -1187,7 +1187,7 @@ static void reflow(struct model *m, int cols, int rows) } m->cols = cols; - term_hist_clear(m); + wsap_vtcore_hist_clear(m); for (int i = start - history; i < start; i++) { hist_push(m, r.out[i]); r.out[i] = NULL; @@ -1291,7 +1291,7 @@ static void resize_plain(struct model *m, int cols, int rows) static bool resize(struct model *m, int cols, int rows) { - if (cols > TERM_MAX_COLS) return false; + if (cols > WSAP_VTCORE_MAX_COLS) return false; if (cols == m->cols && rows == m->rows) return true; if (cols > MAX_TABS) return false; m->top = 0; @@ -1352,7 +1352,7 @@ static void soft_reset(struct model *m) m->bracketed = false; m->autowrap = m->visible = true; m->blink = true; - m->style = TERM_CURSOR_BLOCK; + m->style = WSAP_VTCORE_CURSOR_BLOCK; m->top = 0; m->bottom = m->rows - 1; m->decsace = 0; @@ -1630,11 +1630,11 @@ static void csi_dispatch(struct model *m, unsigned char final) } else if (!m->prefix && m->inter == ' ') { int ps = m->nparam ? m->param[0] : 0; if (ps == 0) { - m->style = TERM_CURSOR_BLOCK; + m->style = WSAP_VTCORE_CURSOR_BLOCK; m->blink = true; } else if (ps <= 6) { - m->style = ps < 3 ? TERM_CURSOR_BLOCK : ps < 5 ? TERM_CURSOR_UNDERLINE - : TERM_CURSOR_BAR; + m->style = ps < 3 ? WSAP_VTCORE_CURSOR_BLOCK : ps < 5 ? WSAP_VTCORE_CURSOR_UNDERLINE + : WSAP_VTCORE_CURSOR_BAR; m->blink = ps & 1; } } @@ -1676,8 +1676,8 @@ static void dcs_finish(struct model *m) size_t n = len - 2; char body[256]; if (n == 2 && !memcmp(spec, " q", 2)) { - int shape = m->style == TERM_CURSOR_BLOCK ? (m->blink ? 1 : 2) - : m->style == TERM_CURSOR_UNDERLINE ? (m->blink ? 3 : 4) + int shape = m->style == WSAP_VTCORE_CURSOR_BLOCK ? (m->blink ? 1 : 2) + : m->style == WSAP_VTCORE_CURSOR_UNDERLINE ? (m->blink ? 3 : 4) : (m->blink ? 5 : 6); reply(m, "\033P1$r%d q\033\\", shape); } else if (n == 1 && spec[0] == 'm') { @@ -1779,7 +1779,7 @@ static void control(struct model *m, unsigned char c) case 0x1b: m->state = ESC; break; case '\n': case 0x0b: case 0x0c: m->pending = false; - if (m->lnm || (m->flags & TERM_FEED_ONLCR)) m->x = 0; + if (m->lnm || (m->flags & WSAP_VTCORE_FEED_ONLCR)) m->x = 0; line_feed(m); break; case '\r': m->pending = false; m->x = 0; break; @@ -1972,17 +1972,17 @@ static void feed_byte(struct model *m, unsigned char c) /* ---- public ---- */ -struct model *model_new(struct term_vector2i size, int history, const char *name) +struct model *model_new(struct wsap_vtcore_vector2i size, int history, const char *name) { struct model *m = calloc(1, sizeof(*m)); if (!m) abort(); - snprintf(m->name, sizeof(m->name), "%s", name && *name ? name : "term"); + snprintf(m->name, sizeof(m->name), "%s", name && *name ? name : "wsap_vtcore"); m->cols = size.x < 1 ? 80 : size.x; m->rows = size.y < 1 ? 24 : size.y; m->limit = history_limit(history); m->scr = rows_new(m->rows, m->cols); m->autowrap = m->visible = m->blink = true; - m->style = TERM_CURSOR_BLOCK; + m->style = WSAP_VTCORE_CURSOR_BLOCK; m->bottom = m->rows - 1; m->g[0] = m->g[1] = 'B'; m->saved = initial_saved(); @@ -1998,7 +1998,7 @@ void model_free(struct model *m) if (!m) return; free_rows(m->scr, m->rows); free_rows(m->normal, m->normal_rows); - term_hist_clear(m); + wsap_vtcore_hist_clear(m); free(m->hist); free(m->reply); for (int i = 0; i < m->out_cap; i++) free(m->out[i]); @@ -2012,15 +2012,15 @@ void model_feed(struct model *m, const char *s, size_t len, unsigned flags) for (size_t i = 0; i < len; i++) feed_byte(m, (unsigned char)s[i]); } -bool model_resize(struct model *m, struct term_vector2i size) +bool model_resize(struct model *m, struct wsap_vtcore_vector2i size) { if (size.x < 1 || size.y < 1) return false; return resize(m, size.x, size.y); } -struct term_vector2i model_size(const struct model *m) +struct wsap_vtcore_vector2i model_size(const struct model *m) { - return (struct term_vector2i){ .x = m->cols, .y = m->rows }; + return (struct wsap_vtcore_vector2i){ .x = m->cols, .y = m->rows }; } int model_history(const struct model *m) @@ -2071,22 +2071,22 @@ const struct model_cell *model_row(const struct model *m, int row) return mm->out[row]; } -struct term_cursor model_cursor(const struct model *m) +struct wsap_vtcore_cursor model_cursor(const struct model *m) { - return (struct term_cursor){ + return (struct wsap_vtcore_cursor){ .pos = { .x = m->x, .y = m->y }, - .style = (enum term_cursor_style)m->style, + .style = (enum wsap_vtcore_cursor_style)m->style, .visible = m->visible, .blink = m->blink, }; } -struct term_modes model_modes(const struct model *m) +struct wsap_vtcore_modes model_modes(const struct model *m) { - return (struct term_modes){ + return (struct wsap_vtcore_modes){ .keyboard = m->keyboard[m->alternate].flags, - .mouse = (enum term_mouse)m->mouse, - .mouse_encoding = (enum term_mouse_encoding)m->mouse_enc, + .mouse = (enum wsap_vtcore_mouse)m->mouse, + .mouse_encoding = (enum wsap_vtcore_mouse_encoding)m->mouse_enc, .app_cursor = m->app_cursor, .app_keypad = m->app_keypad, .backarrow_bs = m->backarrow, -- cgit v1.2.3