diff options
| author | Berke Güzel <wenekar1@gmail.com> | 2026-10-15 13:04:01 +0300 |
|---|---|---|
| committer | Berke Güzel <wenekar1@gmail.com> | 2026-10-15 13:04:01 +0300 |
| commit | dcebf9c7f954a55350b68d0ead1935612c4e2e05 (patch) | |
| tree | 3eb3e9f6154c6760bcb89a565f8ddc8f8b66cb90 /src/osc/dispatch.c | |
| parent | bd8222e615134c3ec5e7a07b6b1fa97c9bd4a471 (diff) | |
Rename the library to wsap_vtcore
ncurses installs <term.h> 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 <wsap_vtcore/wsap_vtcore.h>. 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 <noreply@anthropic.com>
Diffstat (limited to 'src/osc/dispatch.c')
| -rw-r--r-- | src/osc/dispatch.c | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/src/osc/dispatch.c b/src/osc/dispatch.c index 400adbf..442c2e8 100644 --- a/src/osc/dispatch.c +++ b/src/osc/dispatch.c @@ -9,18 +9,18 @@ #define OSC_HEAP_INIT 4096 #define OSC_HEAP_KEEP (1u << 20) -size_t term_osc_room(const struct term *t) +size_t wsap_vtcore_osc_room(const struct wsap_vtcore *t) { size_t cap = t->osc_heap ? t->osc_heap_cap : sizeof(t->osc_buf); return cap - 1 - (size_t)t->osc_len; } -char *term_osc_tail(struct term *t) +char *wsap_vtcore_osc_tail(struct wsap_vtcore *t) { return (t->osc_heap ? t->osc_heap : t->osc_buf) + t->osc_len; } -bool term_osc_grow(struct term *t) +bool wsap_vtcore_osc_grow(struct wsap_vtcore *t) { if (!t->osc_heap) { char *p = malloc(OSC_HEAP_INIT); @@ -30,9 +30,9 @@ bool term_osc_grow(struct term *t) t->osc_heap_cap = OSC_HEAP_INIT; return true; } - if (t->osc_heap_cap >= TERM_OSC_MAX) return false; + if (t->osc_heap_cap >= WSAP_VTCORE_OSC_MAX) return false; size_t cap = t->osc_heap_cap * 2; - if (cap > TERM_OSC_MAX) cap = TERM_OSC_MAX; + if (cap > WSAP_VTCORE_OSC_MAX) cap = WSAP_VTCORE_OSC_MAX; char *p = realloc(t->osc_heap, cap); if (!p) return false; t->osc_heap = p; @@ -40,7 +40,7 @@ bool term_osc_grow(struct term *t) return true; } -void term_osc_cleanup(struct term *t) +void wsap_vtcore_osc_cleanup(struct wsap_vtcore *t) { free(t->osc_heap); t->osc_heap = NULL; @@ -48,7 +48,7 @@ void term_osc_cleanup(struct term *t) free(t->dcs_buf); t->dcs_buf = NULL; t->dcs_cap = 0; - term_osc8_cleanup(t); + wsap_vtcore_osc8_cleanup(t); free(t->cwd); t->cwd = NULL; free(t->pointer_shape); @@ -57,7 +57,7 @@ void term_osc_cleanup(struct term *t) /* Reply to a color query. An OSC 4 reply names the index it answers for; * index is negative for OSC 10, 11, and 12. */ -static void send_color_query_reply(struct term *t, int code, int index, uint32_t argb) +static void send_color_query_reply(struct wsap_vtcore *t, int code, int index, uint32_t argb) { char resp[64], prefix[16] = ""; uint8_t r = (argb >> 16) & 0xff, g = (argb >> 8) & 0xff, b = argb & 0xff; @@ -69,15 +69,15 @@ static void send_color_query_reply(struct term *t, int code, int index, uint32_t send_response(t, resp); } -static void osc_color_set_or_query(struct term *t, int code, const char *params, int slot) +static void osc_color_set_or_query(struct wsap_vtcore *t, int code, const char *params, int slot) { if (!strcmp(params, "?")) { send_color_query_reply(t, code, -1, t->palette.colors[slot]); return; } uint32_t argb; - if (term_color_parse(params, &argb)) - term_palette_set(&t->palette, slot, argb); + if (wsap_vtcore_color_parse(params, &argb)) + wsap_vtcore_palette_set(&t->palette, slot, argb); } static long osc_next_index(const char **pp) @@ -91,7 +91,7 @@ static long osc_next_index(const char **pp) return idx; } -static void osc4_handle(struct term *t, const char *params) +static void osc4_handle(struct wsap_vtcore *t, const char *params) { const char *p = params; while (*p) { @@ -113,8 +113,8 @@ static void osc4_handle(struct term *t, const char *params) memcpy(buf, spec, spec_len); buf[spec_len] = '\0'; uint32_t argb; - if (term_color_parse(buf, &argb)) - term_palette_set(&t->palette, (int)idx, argb); + if (wsap_vtcore_color_parse(buf, &argb)) + wsap_vtcore_palette_set(&t->palette, (int)idx, argb); } } p = spec_end; @@ -122,10 +122,10 @@ static void osc4_handle(struct term *t, const char *params) } } -static void osc104_handle(struct term *t, const char *params) +static void osc104_handle(struct wsap_vtcore *t, const char *params) { if (!*params) { - term_palette_reset_all(&t->palette); + wsap_vtcore_palette_reset_all(&t->palette); return; } const char *p = params; @@ -134,13 +134,13 @@ static void osc104_handle(struct term *t, const char *params) if (idx < 0) return; if (idx <= 255) - term_palette_reset(&t->palette, (int)idx); + wsap_vtcore_palette_reset(&t->palette, (int)idx); } } -void term_osc_finish(struct term *t) +void wsap_vtcore_osc_finish(struct wsap_vtcore *t) { - if (!term_str_was_truncated(t)) { + if (!wsap_vtcore_str_was_truncated(t)) { char *buf = t->osc_heap ? t->osc_heap : t->osc_buf; buf[t->osc_len] = '\0'; @@ -175,34 +175,34 @@ void term_osc_finish(struct term *t) osc4_handle(t, params); break; case 8: - term_osc8(t, params); + wsap_vtcore_osc8(t, params); break; case 10: - osc_color_set_or_query(t, 10, params, TERM_PALETTE_FG); + osc_color_set_or_query(t, 10, params, WSAP_VTCORE_PALETTE_FG); break; case 11: - osc_color_set_or_query(t, 11, params, TERM_PALETTE_BG); + osc_color_set_or_query(t, 11, params, WSAP_VTCORE_PALETTE_BG); break; case 12: - osc_color_set_or_query(t, 12, params, TERM_PALETTE_CURSOR); + osc_color_set_or_query(t, 12, params, WSAP_VTCORE_PALETTE_CURSOR); break; case 52: - term_osc52(t, params); + wsap_vtcore_osc52(t, params); break; case 104: osc104_handle(t, params); break; case 110: - term_palette_reset(&t->palette, TERM_PALETTE_FG); + wsap_vtcore_palette_reset(&t->palette, WSAP_VTCORE_PALETTE_FG); break; case 111: - term_palette_reset(&t->palette, TERM_PALETTE_BG); + wsap_vtcore_palette_reset(&t->palette, WSAP_VTCORE_PALETTE_BG); break; case 112: - term_palette_reset(&t->palette, TERM_PALETTE_CURSOR); + wsap_vtcore_palette_reset(&t->palette, WSAP_VTCORE_PALETTE_CURSOR); break; default: - term_osc_misc_dispatch(t, code, params); + wsap_vtcore_osc_misc_dispatch(t, code, params); break; } } |
