summaryrefslogtreecommitdiff
path: root/src/osc
diff options
context:
space:
mode:
authorBerke Güzel <wenekar1@gmail.com>2026-10-15 13:04:32 +0300
committerBerke Güzel <wenekar1@gmail.com>2026-10-15 13:04:32 +0300
commitbdaedce69b17b654bd0060579dd9b9ff120009b5 (patch)
tree0e9cd8597652263a96c48ba678fb0b66e1fc131b /src/osc
parentba75c8b0a1bba03ad92c53375432f122ddb4cb98 (diff)
parentdcebf9c7f954a55350b68d0ead1935612c4e2e05 (diff)
Merge branch 'wt/rename' into api-hardening
# Conflicts: # README.md
Diffstat (limited to 'src/osc')
-rw-r--r--src/osc/clipboard.c2
-rw-r--r--src/osc/dispatch.c56
-rw-r--r--src/osc/link.c44
-rw-r--r--src/osc/meson.build2
-rw-r--r--src/osc/misc.c14
-rw-r--r--src/osc/osc.h28
6 files changed, 73 insertions, 73 deletions
diff --git a/src/osc/clipboard.c b/src/osc/clipboard.c
index 4f550ba..b330ab8 100644
--- a/src/osc/clipboard.c
+++ b/src/osc/clipboard.c
@@ -65,7 +65,7 @@ static bool b64_decode(const char *s, size_t n, char *out, size_t *out_len)
return true;
}
-void term_osc52(struct term *t, const char *params)
+void wsap_vtcore_osc52(struct wsap_vtcore *t, const char *params)
{
const char *sep = strchr(params, ';');
if (!sep || sep == params)
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;
}
}
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++)
diff --git a/src/osc/meson.build b/src/osc/meson.build
index a3b9efa..efe79c2 100644
--- a/src/osc/meson.build
+++ b/src/osc/meson.build
@@ -1,4 +1,4 @@
-term_osc_src = files(
+wsap_vtcore_osc_src = files(
'clipboard.c',
'dispatch.c',
'link.c',
diff --git a/src/osc/misc.c b/src/osc/misc.c
index 74b35cf..243c2ec 100644
--- a/src/osc/misc.c
+++ b/src/osc/misc.c
@@ -3,9 +3,9 @@
#include <stdlib.h>
#include <string.h>
-static void osc7_cwd(struct term *t, const char *uri)
+static void osc7_cwd(struct wsap_vtcore *t, const char *uri)
{
- if (!term_has_prefix_ci(uri, "file://"))
+ if (!wsap_vtcore_has_prefix_ci(uri, "file://"))
return;
const char *p = uri + 7;
const char *slash = strchr(p, '/');
@@ -16,8 +16,8 @@ static void osc7_cwd(struct term *t, const char *uri)
char *d = cwd;
while (*path) {
int hi, lo;
- if (*path == '%' && (hi = term_hex_nib(path[1])) >= 0 &&
- (lo = term_hex_nib(path[2])) >= 0) {
+ if (*path == '%' && (hi = wsap_vtcore_hex_nib(path[1])) >= 0 &&
+ (lo = wsap_vtcore_hex_nib(path[2])) >= 0) {
*d++ = (char)(hi * 16 + lo);
path += 3;
} else {
@@ -29,7 +29,7 @@ static void osc7_cwd(struct term *t, const char *uri)
t->cwd = cwd;
}
-static void osc777_notify(struct term *t, const char *params)
+static void osc777_notify(struct wsap_vtcore *t, const char *params)
{
if (strncmp(params, "notify;", 7))
return;
@@ -43,7 +43,7 @@ static void osc777_notify(struct term *t, const char *params)
*wsep = ';';
}
-void term_osc_misc_dispatch(struct term *t, long code, const char *params)
+void wsap_vtcore_osc_misc_dispatch(struct wsap_vtcore *t, long code, const char *params)
{
if (!params)
return;
@@ -57,7 +57,7 @@ void term_osc_misc_dispatch(struct term *t, long code, const char *params)
break;
case 22:
free(t->pointer_shape);
- t->pointer_shape = *params ? term_strdup(params) : NULL;
+ t->pointer_shape = *params ? wsap_vtcore_strdup(params) : NULL;
break;
case 777:
if (t->cb.notify)
diff --git a/src/osc/osc.h b/src/osc/osc.h
index 1d6680e..735e483 100644
--- a/src/osc/osc.h
+++ b/src/osc/osc.h
@@ -1,27 +1,27 @@
-#ifndef TERM_OSC_H
-#define TERM_OSC_H
+#ifndef WSAP_VTCORE_OSC_H
+#define WSAP_VTCORE_OSC_H
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
-struct term;
+struct wsap_vtcore;
-#define TERM_OSC_MAX (16u << 20)
+#define WSAP_VTCORE_OSC_MAX (16u << 20)
-size_t term_osc_room(const struct term *t);
-char *term_osc_tail(struct term *t);
-bool term_osc_grow(struct term *t);
+size_t wsap_vtcore_osc_room(const struct wsap_vtcore *t);
+char *wsap_vtcore_osc_tail(struct wsap_vtcore *t);
+bool wsap_vtcore_osc_grow(struct wsap_vtcore *t);
-void term_osc_finish(struct term *t);
+void wsap_vtcore_osc_finish(struct wsap_vtcore *t);
-void term_osc_cleanup(struct term *t);
+void wsap_vtcore_osc_cleanup(struct wsap_vtcore *t);
-void term_osc8(struct term *t, const char *params);
-void term_osc52(struct term *t, const char *params);
-void term_osc_misc_dispatch(struct term *t, long code, const char *params);
+void wsap_vtcore_osc8(struct wsap_vtcore *t, const char *params);
+void wsap_vtcore_osc52(struct wsap_vtcore *t, const char *params);
+void wsap_vtcore_osc_misc_dispatch(struct wsap_vtcore *t, long code, const char *params);
-const char *term_osc8_url_at(const struct term *t, int col, int row);
-void term_osc8_cleanup(struct term *t);
+const char *wsap_vtcore_osc8_url_at(const struct wsap_vtcore *t, int col, int row);
+void wsap_vtcore_osc8_cleanup(struct wsap_vtcore *t);
#endif