summaryrefslogtreecommitdiff
path: root/src/fastcsi.c
diff options
context:
space:
mode:
authorBerke Güzel <wenekar1@gmail.com>2026-10-15 13:04:01 +0300
committerBerke Güzel <wenekar1@gmail.com>2026-10-15 13:04:01 +0300
commitdcebf9c7f954a55350b68d0ead1935612c4e2e05 (patch)
tree3eb3e9f6154c6760bcb89a565f8ddc8f8b66cb90 /src/fastcsi.c
parentbd8222e615134c3ec5e7a07b6b1fa97c9bd4a471 (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/fastcsi.c')
-rw-r--r--src/fastcsi.c68
1 files changed, 34 insertions, 34 deletions
diff --git a/src/fastcsi.c b/src/fastcsi.c
index 2e0f004..6f9d926 100644
--- a/src/fastcsi.c
+++ b/src/fastcsi.c
@@ -9,7 +9,7 @@
#include <stdint.h>
#include <string.h>
-TERM_ALWAYS_INLINE
+WSAP_VTCORE_ALWAYS_INLINE
static inline const char *parse_byte_delim(const char *s, const char *end, char delim, uint32_t *val)
{
if (s >= end) return NULL;
@@ -45,7 +45,7 @@ static inline const char *parse_color_sequence(const char *p, const char *end, u
if (!s) return NULL;
s = parse_byte_delim(s, end, 'm', &b);
if (!s) return NULL;
- *color = term_rgb((int)r, (int)g, (int)b);
+ *color = wsap_vtcore_rgb((int)r, (int)g, (int)b);
return s;
}
@@ -54,12 +54,12 @@ static const char *parse_256color(const char *p, const char *end, uint32_t *colo
uint32_t v;
const char *s = parse_byte_delim(p + 2, end, 'm', &v);
if (!s) return NULL;
- *color = term_color_index(v);
+ *color = wsap_vtcore_color_index(v);
return s;
}
-TERM_NOINLINE
-int term_try_fast_csi(struct term *t, const char *buf, size_t rem)
+WSAP_VTCORE_NOINLINE
+int wsap_vtcore_try_fast_csi(struct wsap_vtcore *t, const char *buf, size_t rem)
{
const char *end = buf + rem;
const char *p = buf;
@@ -94,11 +94,11 @@ int term_try_fast_csi(struct term *t, const char *buf, size_t rem)
}
if (p < end && (unsigned char)*p >= 0x20 && (unsigned char)*p < 0x7f) {
char ch = *p++;
- if (TERM_EXPECT(!flags_ok, 0)) {
- flags_pad = term_flags_pad(t);
+ if (WSAP_VTCORE_EXPECT(!flags_ok, 0)) {
+ flags_pad = wsap_vtcore_flags_pad(t);
flags_ok = true;
}
- if (TERM_EXPECT(!sc_put1_fast(t, ch, (struct text_pen){ fg, bg, flags_pad }), 0)) {
+ if (WSAP_VTCORE_EXPECT(!sc_put1_fast(t, ch, (struct text_pen){ fg, bg, flags_pad }), 0)) {
t->cur_fg = fg;
t->cur_bg = bg;
sc_print_ascii(t, &ch, 1);
@@ -116,20 +116,20 @@ int term_try_fast_csi(struct term *t, const char *buf, size_t rem)
/* Recompute instead of zeroing. The cached flags carry the link
* id, and reset_sgr leaves cur_link set, so zeroing here would
* drop the hyperlink from every cell written after the reset. */
- flags_pad = term_flags_pad(t);
+ flags_pad = wsap_vtcore_flags_pad(t);
flags_ok = true;
p += p[0] == 'm' ? 1 : 2;
} else if (p[0] == 'J' ||
(p[0] >= '0' && p[0] <= '3' && p + 1 < end && p[1] == 'J')) {
t->cur_fg = fg;
t->cur_bg = bg;
- term_screen_erase(t, p[0] == 'J' ? 0 : p[0] - '0');
+ wsap_vtcore_screen_erase(t, p[0] == 'J' ? 0 : p[0] - '0');
p += p[0] == 'J' ? 1 : 2;
} else if (p[0] == 'K' ||
(p[0] >= '0' && p[0] <= '2' && p + 1 < end && p[1] == 'K')) {
t->cur_fg = fg;
t->cur_bg = bg;
- term_screen_erase_line(t, p[0] == 'K' ? 0 : p[0] - '0');
+ wsap_vtcore_screen_erase_line(t, p[0] == 'K' ? 0 : p[0] - '0');
p += p[0] == 'K' ? 1 : 2;
} else if (!t->origin_mode && !t->lr_margin_mode &&
((*p >= '0' && *p <= '9') || *p == ';' ||
@@ -166,7 +166,7 @@ int term_try_fast_csi(struct term *t, const char *buf, size_t rem)
case 'E': ny += n; nx = 0; goto vmove;
case 'F': ny -= n; nx = 0; goto vmove;
vmove:
- if (TERM_EXPECT(t->scroll_top != 0 || t->scroll_bottom != rows - 1, 0)) {
+ if (WSAP_VTCORE_EXPECT(t->scroll_top != 0 || t->scroll_bottom != rows - 1, 0)) {
p = esc;
goto done;
}
@@ -200,16 +200,16 @@ int term_try_fast_csi(struct term *t, const char *buf, size_t rem)
case 24: t->underline = 0; break;
case 27: t->inverse = false; break;
case 29: t->strike = false; break;
- case 39: fg = TERM_COLOR_FG; break;
- case 49: bg = TERM_COLOR_BG; break;
+ case 39: fg = WSAP_VTCORE_COLOR_FG; break;
+ case 49: bg = WSAP_VTCORE_COLOR_BG; break;
case 53: t->overline = true; break;
case 55: t->overline = false; break;
case 59: t->cur_ul = 0; break;
default:
- if ((unsigned)(v - 30) < 8) fg = term_color_index(v - 30);
- else if ((unsigned)(v - 40) < 8) bg = term_color_index(v - 40);
- else if ((unsigned)(v - 90) < 8) fg = term_color_index(v - 90 + 8);
- else if ((unsigned)(v - 100) < 8) bg = term_color_index(v - 100 + 8);
+ if ((unsigned)(v - 30) < 8) fg = wsap_vtcore_color_index(v - 30);
+ else if ((unsigned)(v - 40) < 8) bg = wsap_vtcore_color_index(v - 40);
+ else if ((unsigned)(v - 90) < 8) fg = wsap_vtcore_color_index(v - 90 + 8);
+ else if ((unsigned)(v - 100) < 8) bg = wsap_vtcore_color_index(v - 100 + 8);
break;
}
flags_ok = false;
@@ -236,25 +236,25 @@ int term_try_fast_csi(struct term *t, const char *buf, size_t rem)
uint32_t *slot = v == 38 ? &fg : v == 48 ? &bg : &t->cur_ul;
if (j + 2 < nparams && pv[j + 1] == 5) {
if (pv[j + 2] >= 0 && pv[j + 2] <= 255)
- *slot = term_color_index(pv[j + 2]);
+ *slot = wsap_vtcore_color_index(pv[j + 2]);
j += 2;
} else if (j + 1 < nparams && pv[j + 1] == 2 &&
j + 4 < nparams) {
- *slot = term_rgb(pv[j + 2], pv[j + 3], pv[j + 4]);
+ *slot = wsap_vtcore_rgb(pv[j + 2], pv[j + 3], pv[j + 4]);
j += 4;
}
break;
}
- case 39: fg = TERM_COLOR_FG; break;
- case 49: bg = TERM_COLOR_BG; break;
+ case 39: fg = WSAP_VTCORE_COLOR_FG; break;
+ case 49: bg = WSAP_VTCORE_COLOR_BG; break;
case 53: t->overline = true; break;
case 55: t->overline = false; break;
case 59: t->cur_ul = 0; break;
default:
- if ((unsigned)(v - 30) < 8) fg = term_color_index(v - 30);
- else if ((unsigned)(v - 40) < 8) bg = term_color_index(v - 40);
- else if ((unsigned)(v - 90) < 8) fg = term_color_index(v - 90 + 8);
- else if ((unsigned)(v - 100) < 8) bg = term_color_index(v - 100 + 8);
+ if ((unsigned)(v - 30) < 8) fg = wsap_vtcore_color_index(v - 30);
+ else if ((unsigned)(v - 40) < 8) bg = wsap_vtcore_color_index(v - 40);
+ else if ((unsigned)(v - 90) < 8) fg = wsap_vtcore_color_index(v - 90 + 8);
+ else if ((unsigned)(v - 100) < 8) bg = wsap_vtcore_color_index(v - 100 + 8);
break;
}
}
@@ -265,13 +265,13 @@ int term_try_fast_csi(struct term *t, const char *buf, size_t rem)
case 'J':
t->cur_fg = fg;
t->cur_bg = bg;
- term_screen_erase(t, pv[0]);
+ wsap_vtcore_screen_erase(t, pv[0]);
p = q + 1;
break;
case 'K':
t->cur_fg = fg;
t->cur_bg = bg;
- term_screen_erase_line(t, pv[0]);
+ wsap_vtcore_screen_erase_line(t, pv[0]);
p = q + 1;
break;
case 'X':
@@ -284,19 +284,19 @@ int term_try_fast_csi(struct term *t, const char *buf, size_t rem)
case 'P':
t->cur_fg = fg;
t->cur_bg = bg;
- term_screen_delete_chars(t, n);
+ wsap_vtcore_screen_delete_chars(t, n);
p = q + 1;
break;
case '@':
t->cur_fg = fg;
t->cur_bg = bg;
- term_screen_insert_chars(t, n);
+ wsap_vtcore_screen_insert_chars(t, n);
p = q + 1;
break;
case 's':
t->cur_fg = fg;
t->cur_bg = bg;
- t->saved = term_cursor_save(t);
+ t->saved = wsap_vtcore_cursor_save(t);
p = q + 1;
break;
case 'u':
@@ -325,8 +325,8 @@ tail:
int avail = cols - t->cursor_x;
int limit = end - p < (ptrdiff_t)avail ? (int)(end - p) : avail;
int run = scan_ascii_run(p, limit);
- if (TERM_EXPECT(!flags_ok, 0)) {
- flags_pad = term_flags_pad(t);
+ if (WSAP_VTCORE_EXPECT(!flags_ok, 0)) {
+ flags_pad = wsap_vtcore_flags_pad(t);
flags_ok = true;
}
if (!sc_ascii_fast(t, p, run, (struct text_pen){ fg, bg, flags_pad }))
@@ -346,7 +346,7 @@ tail:
if (p < end && *p == '\n') {
t->cur_fg = fg;
t->cur_bg = bg;
- if (term_lnm(t)) sc_cr(t);
+ if (wsap_vtcore_lnm(t)) sc_cr(t);
sc_linefeed(t, 1);
p++;
goto tail;