diff options
| author | Berke Güzel <wenekar1@gmail.com> | 2026-10-12 17:49:34 +0300 |
|---|---|---|
| committer | Berke Güzel <wenekar1@gmail.com> | 2026-10-12 17:49:34 +0300 |
| commit | 4384435941b8c7658856b381d071aee2e0035e89 (patch) | |
| tree | 5ece99c3dd1decb8ec3fd404c0ece2b5865a552a /src/palette.h | |
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:<name>.
- 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 <noreply@anthropic.com>
Diffstat (limited to 'src/palette.h')
| -rw-r--r-- | src/palette.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/palette.h b/src/palette.h new file mode 100644 index 0000000..5eef03e --- /dev/null +++ b/src/palette.h @@ -0,0 +1,34 @@ +#ifndef TERM_PALETTE_H +#define TERM_PALETTE_H + +#include <stdbool.h> +#include <stdint.h> + +#include "term.h" + +/* + * The colors of one terminal. base holds the colors that the theme gives; + * colors holds base plus the entries that the program changed with OSC 4, + * 10, 11, or 12. version changes whenever colors changes. + */ +struct palette { + uint32_t colors[TERM_PALETTE_SIZE]; + uint32_t base[TERM_PALETTE_SIZE]; + struct term_theme theme; + uint64_t version; +}; + +/* Set every entry from theme. An all-zero theme selects the built-in theme. */ +void term_palette_init(struct palette *p, const struct term_theme *theme); +/* Change one entry (0-255, TERM_PALETTE_FG, _BG, or _CURSOR). */ +void term_palette_set(struct palette *p, int slot, uint32_t argb); +/* Restore one entry, or all entries, to the theme color. */ +void term_palette_reset(struct palette *p, int slot); +void term_palette_reset_all(struct palette *p); + +static inline uint32_t palette_resolve(const struct palette *p, term_color c) +{ + return term_color_is_slot(c) ? p->colors[c & 0x1FFu] : c; +} + +#endif |
