From 4384435941b8c7658856b381d071aee2e0035e89 Mon Sep 17 00:00:00 2001 From: Berke Güzel Date: Mon, 12 Oct 2026 17:49:34 +0300 Subject: term: move the term core to subprojects/term The core now builds, tests, and benchmarks alone, as a Meson subproject with no dependency on the main tree. - include/term/ holds term.h and the header-only unicode/. src/ holds the core and its private headers. The main tree gets only include/term through term_dep, so it cannot reach a private header. - The term tests, the term benchmarks, the Kitty parser suite, and tools/amalgamate.py and tools/generate_unicode.py move with it. The tests run as term:. - The main build passes its -march (arch_flag) and b_ndebug to the subproject. A directory configured before this commit needs meson configure -Dterm:arch_flag=-march=... once. - The term tests compile with -UNDEBUG. They do work inside assert. - The subproject exports term_test_dep with term_api.h, for the main tree's render, thumbnail, color, and selection tests. - The Kitty bridge used struct vector2i and has not compiled since the public API redesign. It builds again. 2 of its 14 tests fail: REP after a tab, and a cursor report after a resize. - dirgraph.py drops the term and unicode layers. Its self-test uses pty. - The symbols test ignores the __odr_asan symbols that ASan adds. Co-Authored-By: Claude Opus 5.5 --- tests/model.h | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 tests/model.h (limited to 'tests/model.h') diff --git a/tests/model.h b/tests/model.h new file mode 100644 index 0000000..9a4316f --- /dev/null +++ b/tests/model.h @@ -0,0 +1,50 @@ +#ifndef WSAP_TERM_MODEL_H +#define WSAP_TERM_MODEL_H + +/* + * A slow reference model of the terminal. It defines correct behavior for + * the input that tests/term/fuzz_gen.h makes. model.c names its sources: + * xterm and ECMA-48 for controls, Unicode for UTF-8, and this terminal's + * own design where xterm has no rule (reflow, history, clusters). + * + * The model reads nothing from the terminal. Tests compare the two through + * the public API only. + */ + +#include "term/term.h" +#include "term/unicode/grapheme.h" + +#include +#include +#include + +struct model_cell { + uint32_t cp[GRAPHEME_MAX_LEN]; + uint8_t n; /* code points; 0 for the right half of a wide cell */ + uint8_t width; /* 1, 2 for a wide cell, 0 for its right half */ + uint16_t attrs; /* TERM_ATTR_* */ + term_color fg, bg; +}; + +struct model; + +/* history is the history limit, as in term_options.scrollback. */ +struct model *model_new(struct term_vector2i size, int history); +void model_free(struct model *m); +void model_feed(struct model *m, const char *s, size_t len, unsigned flags); +bool model_resize(struct model *m, struct term_vector2i size); + +struct term_vector2i model_size(const struct model *m); +/* History rows. The alternate screen shows no history, so it reports 0. */ +int model_history(const struct model *m); +/* Row 0 is the oldest history row. Row model_history() is the top screen + * row. Return NULL for an invalid row. Different rows can be read together. + * A feed or resize ends the lifetime of returned row data. */ +const struct model_cell *model_row(const struct model *m, int row); +struct term_cursor model_cursor(const struct model *m); +struct term_modes model_modes(const struct model *m); +/* Replies since the last model_take_replies(). */ +const char *model_replies(const struct model *m, size_t *len); +void model_take_replies(struct model *m); + +#endif -- cgit v1.2.3