summaryrefslogtreecommitdiff
path: root/src/osc/link.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/osc/link.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/osc/link.c')
-rw-r--r--src/osc/link.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/src/osc/link.c b/src/osc/link.c
index f31a750..363a568 100644
--- a/src/osc/link.c
+++ b/src/osc/link.c
@@ -4,15 +4,15 @@
#include <stdlib.h>
#include <string.h>
-#define TERM_LINK_MAX 8192
-#define TERM_LINK_URI_MAX 4096
+#define WSAP_VTCORE_LINK_MAX 8192
+#define WSAP_VTCORE_LINK_URI_MAX 4096
struct link_hash_slot {
uint64_t hash;
uint16_t id;
};
-struct term_links {
+struct wsap_vtcore_links {
char **uri;
uint16_t *free_ids;
struct link_hash_slot *hash_table;
@@ -31,7 +31,7 @@ static inline uint64_t hash_uri(const char *s)
return h ? h : 1;
}
-static void links_insert_hash(struct term_links *l, uint64_t h, uint16_t id)
+static void links_insert_hash(struct wsap_vtcore_links *l, uint64_t h, uint16_t id)
{
if (!l->hash_table || !l->hash_cap)
return;
@@ -48,9 +48,9 @@ static void links_insert_hash(struct term_links *l, uint64_t h, uint16_t id)
}
}
-static bool links_grow(struct term_links *l)
+static bool links_grow(struct wsap_vtcore_links *l)
{
- uint16_t new_cap = l->capacity == 0 ? 64 : l->capacity < 4096 ? l->capacity * 2 : TERM_LINK_MAX;
+ uint16_t new_cap = l->capacity == 0 ? 64 : l->capacity < 4096 ? l->capacity * 2 : WSAP_VTCORE_LINK_MAX;
if (new_cap <= l->capacity)
return false;
char **new_uri = realloc(l->uri, sizeof(char *) * new_cap);
@@ -89,7 +89,7 @@ static bool links_grow(struct term_links *l)
static void links_mark_row(const struct cell *row, int len, uint64_t *mark, uint16_t cap)
{
- if (len > TERM_MAX_COLS) len = TERM_MAX_COLS;
+ if (len > WSAP_VTCORE_MAX_COLS) len = WSAP_VTCORE_MAX_COLS;
for (int i = 0; i < len; i++) {
uint16_t id = row[i].pad;
if (id && id <= cap)
@@ -123,19 +123,19 @@ static void links_mark_screen(const struct screen *s, struct links_mark *m)
if (row->kind == ROW_CELLS)
links_mark_row(row->cells, row->len, m->mark, m->cap);
else
- term_hist_text_mark_links(&row->text, links_mark_hist, m);
+ wsap_vtcore_hist_text_mark_links(&row->text, links_mark_hist, m);
}
}
-static void links_gc(struct term *t, struct term_links *l)
+static void links_gc(struct wsap_vtcore *t, struct wsap_vtcore_links *l)
{
- uint64_t mark[TERM_LINK_MAX / 64] = { 0 };
+ uint64_t mark[WSAP_VTCORE_LINK_MAX / 64] = { 0 };
struct links_mark m = { mark, l->capacity };
links_mark_id(t->cur_link, mark, l->capacity);
links_mark_screen(&t->scr, &m);
if (t->alternate && t->alt_allocated)
links_mark_screen(&t->alt_scr, &m);
- term_hist_mark_links(&t->hist, links_mark_hist, &m);
+ wsap_vtcore_hist_mark_links(&t->hist, links_mark_hist, &m);
l->free_count = 0;
for (int i = 0; i + 1 < l->next; i++) {
if (l->uri[i] && !(mark[i >> 6] & (1ull << (i & 63)))) {
@@ -154,7 +154,7 @@ static void links_gc(struct term *t, struct term_links *l)
}
}
-static uint16_t links_find(const struct term_links *l, const char *uri, uint64_t h)
+static uint16_t links_find(const struct wsap_vtcore_links *l, const char *uri, uint64_t h)
{
if (!l->hash_table || !l->hash_cap)
return 0;
@@ -174,7 +174,7 @@ static uint16_t links_find(const struct term_links *l, const char *uri, uint64_t
return 0;
}
-static uint16_t links_alloc(struct term *t, struct term_links *l)
+static uint16_t links_alloc(struct wsap_vtcore *t, struct wsap_vtcore_links *l)
{
if (l->free_count)
return l->free_ids[--l->free_count];
@@ -186,7 +186,7 @@ static uint16_t links_alloc(struct term *t, struct term_links *l)
return 0;
}
-void term_osc8(struct term *t, const char *params)
+void wsap_vtcore_osc8(struct wsap_vtcore *t, const char *params)
{
const char *sep = strchr(params, ';');
if (!sep)
@@ -196,11 +196,11 @@ void term_osc8(struct term *t, const char *params)
t->cur_link = 0;
return;
}
- if (strlen(uri) > TERM_LINK_URI_MAX) {
+ if (strlen(uri) > WSAP_VTCORE_LINK_URI_MAX) {
t->cur_link = 0;
return;
}
- struct term_links *l = t->links;
+ struct wsap_vtcore_links *l = t->links;
if (!l) {
l = calloc(1, sizeof(*l));
if (!l) {
@@ -218,7 +218,7 @@ void term_osc8(struct term *t, const char *params)
t->cur_link = 0;
return;
}
- l->uri[id - 1] = term_strdup(uri);
+ l->uri[id - 1] = wsap_vtcore_strdup(uri);
if (!l->uri[id - 1]) {
l->free_ids[l->free_count++] = id;
t->cur_link = 0;
@@ -229,12 +229,12 @@ void term_osc8(struct term *t, const char *params)
t->cur_link = id;
}
-const char *term_osc8_url_at(const struct term *t, int col, int row)
+const char *wsap_vtcore_osc8_url_at(const struct wsap_vtcore *t, int col, int row)
{
- const struct term_links *l = t->links;
+ const struct wsap_vtcore_links *l = t->links;
if (!l || col < 0 || col >= t->cols)
return NULL;
- const struct cell *cells = term_screen_view_row(t, row);
+ const struct cell *cells = wsap_vtcore_screen_view_row(t, row);
if (!cells)
return NULL;
uint16_t id = cells[col].pad;
@@ -244,9 +244,9 @@ const char *term_osc8_url_at(const struct term *t, int col, int row)
return l->uri[id - 1];
}
-void term_osc8_cleanup(struct term *t)
+void wsap_vtcore_osc8_cleanup(struct wsap_vtcore *t)
{
- struct term_links *l = t->links;
+ struct wsap_vtcore_links *l = t->links;
if (!l)
return;
for (uint16_t i = 0; i < l->capacity; i++)