summaryrefslogtreecommitdiff
path: root/tests/model.c
diff options
context:
space:
mode:
authorBerke Güzel <wenekar1@gmail.com>2026-10-15 11:37:31 +0300
committerBerke Güzel <wenekar1@gmail.com>2026-10-15 11:37:31 +0300
commitaf6a37b1c4509c7766933a7cb45d2ee9a3a23f98 (patch)
treee7b0294ebf0d9b124b8885a76c119d7f46d5b0fb /tests/model.c
parentacd338ea33de36d223cc6d301712eed4a9501e6c (diff)
Return owned text and share cell attribute flags with snapshots
Make text queries return allocated strings released with term_text_free, keeping each capture atomic. Align public attributes with the write core, remove snapshot conversion tables, and migrate tests and the Kitty adapter.
Diffstat (limited to 'tests/model.c')
-rw-r--r--tests/model.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/tests/model.c b/tests/model.c
index 4fd3737..8dead6c 100644
--- a/tests/model.c
+++ b/tests/model.c
@@ -727,9 +727,12 @@ static void pen_reset(struct pen *p)
static void set_underline(uint16_t *attrs, int style)
{
- if (style > 5) style = 1;
- *attrs = (uint16_t)((*attrs & ~TERM_ATTR_UNDERLINE_MASK) |
- (unsigned)style << TERM_ATTR_UNDERLINE_SHIFT);
+ static const uint16_t flags[] = {
+ 0, TERM_ATTR_UNDERLINE, TERM_ATTR_DOUBLE_UNDERLINE,
+ TERM_ATTR_CURLY_UNDERLINE, TERM_ATTR_DOTTED_UNDERLINE, TERM_ATTR_DASHED_UNDERLINE,
+ };
+ if ((unsigned)style > 5) style = 1;
+ *attrs = (uint16_t)((*attrs & ~TERM_ATTR_UNDERLINE_MASK) | flags[style]);
}
/* 38, 48, and 58. Returns the parameters it used after the first. */
@@ -814,7 +817,7 @@ static void sgr_report(const struct model *m, char *out, size_t cap)
size_t n = 0;
out[0] = 0;
#define ADD(...) do { int k = snprintf(out + n, cap - n, __VA_ARGS__); if (k > 0) n += (size_t)k; } while (0)
- int ul = (int)((p->attrs & TERM_ATTR_UNDERLINE_MASK) >> TERM_ATTR_UNDERLINE_SHIFT);
+ int ul = term_attr_underline(p->attrs);
if (!(p->attrs & (TERM_ATTR_BOLD | TERM_ATTR_FAINT | TERM_ATTR_ITALIC | TERM_ATTR_STRIKE |
TERM_ATTR_OVERLINE | TERM_ATTR_UNDERLINE_MASK)) &&
!p->inverse && p->fg == TERM_COLOR_FG && p->bg == TERM_COLOR_BG && !p->ul)