summaryrefslogtreecommitdiff
path: root/tests/helpers/term_api.h
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 /tests/helpers/term_api.h
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 'tests/helpers/term_api.h')
-rw-r--r--tests/helpers/term_api.h106
1 files changed, 53 insertions, 53 deletions
diff --git a/tests/helpers/term_api.h b/tests/helpers/term_api.h
index f2d6a5d..17a29ae 100644
--- a/tests/helpers/term_api.h
+++ b/tests/helpers/term_api.h
@@ -7,7 +7,7 @@
* terminal shows.
*/
-#include "term/term.h"
+#include "wsap_vtcore/wsap_vtcore.h"
#include <stdbool.h>
#include <stddef.h>
@@ -17,149 +17,149 @@
/* The history size the tests assume. */
#define TEST_SCROLLBACK 4096
-static inline struct term *tt_new_opts(int cols, int rows, const struct term_callbacks *cb)
+static inline struct wsap_vtcore *tt_new_opts(int cols, int rows, const struct wsap_vtcore_callbacks *cb)
{
- struct term_options opt = {
+ struct wsap_vtcore_options opt = {
.size = { .x = cols, .y = rows },
.scrollback = TEST_SCROLLBACK,
};
if (cb)
opt.callbacks = *cb;
- return term_new(&opt);
+ return wsap_vtcore_new(&opt);
}
-static inline struct term *tt_new(int cols, int rows)
+static inline struct wsap_vtcore *tt_new(int cols, int rows)
{
return tt_new_opts(cols, rows, NULL);
}
-static inline void tt_write(struct term *t, const char *s, size_t len)
+static inline void tt_write(struct wsap_vtcore *t, const char *s, size_t len)
{
- term_feed(t, s, len, 0);
+ wsap_vtcore_feed(t, s, len, 0);
}
-static inline void tt_puts(struct term *t, const char *s)
+static inline void tt_puts(struct wsap_vtcore *t, const char *s)
{
- term_feed(t, s, strlen(s), 0);
+ wsap_vtcore_feed(t, s, strlen(s), 0);
}
-static inline int tt_cols(const struct term *t) { return term_size(t).x; }
-static inline int tt_rows(const struct term *t) { return term_size(t).y; }
-static inline int tt_cursor_x(const struct term *t) { return term_cursor(t).pos.x; }
-static inline int tt_cursor_y(const struct term *t) { return term_cursor(t).pos.y; }
-static inline int tt_history(const struct term *t) { return term_scrollback(t).total; }
-static inline int tt_view_offset(const struct term *t) { return term_scrollback(t).offset; }
+static inline int tt_cols(const struct wsap_vtcore *t) { return wsap_vtcore_size(t).x; }
+static inline int tt_rows(const struct wsap_vtcore *t) { return wsap_vtcore_size(t).y; }
+static inline int tt_cursor_x(const struct wsap_vtcore *t) { return wsap_vtcore_cursor(t).pos.x; }
+static inline int tt_cursor_y(const struct wsap_vtcore *t) { return wsap_vtcore_cursor(t).pos.y; }
+static inline int tt_history(const struct wsap_vtcore *t) { return wsap_vtcore_scrollback(t).total; }
+static inline int tt_view_offset(const struct wsap_vtcore *t) { return wsap_vtcore_scrollback(t).offset; }
/* One snapshot serves every read. It follows whichever terminal a test
* reads last. */
-static struct term_snapshot *tt_snapshot_for(struct term *t)
+static struct wsap_vtcore_snapshot *tt_snapshot_for(struct wsap_vtcore *t)
{
- static struct term_snapshot *snap;
+ static struct wsap_vtcore_snapshot *snap;
if (!snap)
- snap = term_snapshot_new();
- term_snapshot_update(snap, t);
+ snap = wsap_vtcore_snapshot_new();
+ wsap_vtcore_snapshot_update(snap, t);
return snap;
}
-static const struct term_cell tt_blank_cell = {
- .text = ' ', .fg = TERM_COLOR_FG, .bg = TERM_COLOR_BG, .width = 1,
+static const struct wsap_vtcore_cell tt_blank_cell = {
+ .text = ' ', .fg = WSAP_VTCORE_COLOR_FG, .bg = WSAP_VTCORE_COLOR_BG, .width = 1,
};
/* A cell of the viewport. Out-of-range columns read as a blank cell. */
-static inline const struct term_cell *tt_view_cell(struct term *t, int col, int row)
+static inline const struct wsap_vtcore_cell *tt_view_cell(struct wsap_vtcore *t, int col, int row)
{
- struct term_snapshot *s = tt_snapshot_for(t);
- const struct term_cell *cells = term_snapshot_row(s, row);
+ struct wsap_vtcore_snapshot *s = tt_snapshot_for(t);
+ const struct wsap_vtcore_cell *cells = wsap_vtcore_snapshot_row(s, row);
if (!cells)
return NULL;
- if (col < 0 || col >= term_snapshot_view(s)->size.x)
+ if (col < 0 || col >= wsap_vtcore_snapshot_view(s)->size.x)
return &tt_blank_cell;
return &cells[col];
}
/* A cell of the live screen, whatever the viewport shows. */
-static inline const struct term_cell *tt_cell(struct term *t, int col, int row)
+static inline const struct wsap_vtcore_cell *tt_cell(struct wsap_vtcore *t, int col, int row)
{
int offset = tt_view_offset(t);
if (offset)
- term_scroll_to(t, 0);
- const struct term_cell *cell = tt_view_cell(t, col, row);
+ wsap_vtcore_scroll_to(t, 0);
+ const struct wsap_vtcore_cell *cell = tt_view_cell(t, col, row);
if (offset)
- term_scroll_to(t, offset);
+ wsap_vtcore_scroll_to(t, offset);
return cell;
}
/* The code points of a cell's text: one, or a whole cluster. The snapshot
* that the last read used must still describe the terminal. */
-static inline int tt_cell_cps(struct term *t, const struct term_cell *cell,
+static inline int tt_cell_cps(struct wsap_vtcore *t, const struct wsap_vtcore_cell *cell,
uint32_t *cps, int cap)
{
- return term_snapshot_cluster(tt_snapshot_for(t), cell->text, cps, cap);
+ return wsap_vtcore_snapshot_cluster(tt_snapshot_for(t), cell->text, cps, cap);
}
/* The first code point of a cell's text. */
-static inline uint32_t tt_cell_cp(struct term *t, const struct term_cell *cell)
+static inline uint32_t tt_cell_cp(struct wsap_vtcore *t, const struct wsap_vtcore_cell *cell)
{
uint32_t cp = 0;
- if (!(cell->text & TERM_TEXT_CLUSTER))
+ if (!(cell->text & WSAP_VTCORE_TEXT_CLUSTER))
return cell->text;
tt_cell_cps(t, cell, &cp, 1);
return cp;
}
-static inline bool tt_is_cluster(const struct term_cell *cell)
+static inline bool tt_is_cluster(const struct wsap_vtcore_cell *cell)
{
- return (cell->text & TERM_TEXT_CLUSTER) != 0;
+ return (cell->text & WSAP_VTCORE_TEXT_CLUSTER) != 0;
}
/* The selected columns [begin, end) of a viewport row. */
-static inline struct term_span tt_row_selection(struct term *t, int row)
+static inline struct wsap_vtcore_span tt_row_selection(struct wsap_vtcore *t, int row)
{
- return term_snapshot_row_selection(tt_snapshot_for(t), row);
+ return wsap_vtcore_snapshot_row_selection(tt_snapshot_for(t), row);
}
-static inline bool tt_selected(struct term *t, int col, int row)
+static inline bool tt_selected(struct wsap_vtcore *t, int col, int row)
{
- struct term_span span = tt_row_selection(t, row);
+ struct wsap_vtcore_span span = tt_row_selection(t, row);
return col >= span.begin && col < span.end;
}
/* Select from one viewport cell to another, both inclusive. */
-static inline void tt_select(struct term *t, int x1, int y1, int x2, int y2)
+static inline void tt_select(struct wsap_vtcore *t, int x1, int y1, int x2, int y2)
{
bool forward = y1 < y2 || (y1 == y2 && x1 <= x2);
- struct term_vector2i a = { .x = x1, .y = y1 }, b = { .x = x2, .y = y2 };
- term_select_start(t, forward ? a : b, false, TERM_SELECT_CELL);
- term_select_extend(t, forward ? b : a, true);
+ struct wsap_vtcore_vector2i a = { .x = x1, .y = y1 }, b = { .x = x2, .y = y2 };
+ wsap_vtcore_select_start(t, forward ? a : b, false, WSAP_VTCORE_SELECT_CELL);
+ wsap_vtcore_select_extend(t, forward ? b : a, true);
}
/* The helpers below return new strings. The caller frees them. */
/* NULL when nothing is selected. */
-static inline char *tt_selection_text(const struct term *t)
+static inline char *tt_selection_text(const struct wsap_vtcore *t)
{
- return term_selection_text(t);
+ return wsap_vtcore_selection_text(t);
}
-static inline char *tt_history_text(struct term *t, int max_rows)
+static inline char *tt_history_text(struct wsap_vtcore *t, int max_rows)
{
- return term_history_text(t, max_rows);
+ return wsap_vtcore_history_text(t, max_rows);
}
/* NULL when there is no link. */
-static inline char *tt_link_at(struct term *t, int col, int row)
+static inline char *tt_link_at(struct wsap_vtcore *t, int col, int row)
{
- return term_link_at(t, (struct term_vector2i){ .x = col, .y = row });
+ return wsap_vtcore_link_at(t, (struct wsap_vtcore_vector2i){ .x = col, .y = row });
}
-static inline bool tt_resize(struct term *t, int cols, int rows)
+static inline bool tt_resize(struct wsap_vtcore *t, int cols, int rows)
{
- return term_resize(t, (struct term_vector2i){ .x = cols, .y = rows });
+ return wsap_vtcore_resize(t, (struct wsap_vtcore_vector2i){ .x = cols, .y = rows });
}
/* The ARGB value of a color in the terminal's current palette. */
-static inline uint32_t tt_color(struct term *t, term_color c)
+static inline uint32_t tt_color(struct wsap_vtcore *t, wsap_vtcore_color c)
{
- return term_view_color(term_snapshot_view(tt_snapshot_for(t)), c);
+ return wsap_vtcore_view_color(wsap_vtcore_snapshot_view(tt_snapshot_for(t)), c);
}
#endif