skip to content
==> tests/render.c <==
1/* The diff: unchanged cells are not written, contiguous cells don't move the cursor, colours and
2 * modifiers change only when they do, a wide character's covered cell is skipped. */
3#include "mesh/check.h"
4#include "tui/render.h"
5
6#include <string.h>
7
8int main(void) {
9    tui_buffer a, b;
10    tui_buffer_init(&a, (tui_rect){0, 0, 6, 2});
11    tui_buffer_init(&b, (tui_rect){0, 0, 6, 2});
12    tui_out o = {0};
13    tui_render_diff(&a, &b, &o);
14    CHECK_S(o.data, "\x1b[39m\x1b[49m\x1b[0m");
15    tui_out_free(&o);
16    tui_buffer_set_string(&b, 1, 0, "ab", tui_fg(TUI_RGB(1, 2, 3)));
17    tui_buffer_set_string(&b, 0, 1, "\xE6\x97\xA5x", tui_style_add(tui_style_new(), TUI_BOLD));
18    tui_render_diff(&a, &b, &o);
19    CHECK_S(o.data, "\x1b[1;2H\x1b[38;2;1;2;3m\x1b[49ma" "b"
20                    "\x1b[2;1H\x1b[1m\x1b[39m\x1b[49m\xE6\x97\xA5"
21                    "\x1b[2;3Hx"
22                    "\x1b[39m\x1b[49m\x1b[0m");
23    tui_out_free(&o);
24    tui_buffer_free(&a);
25    tui_buffer_free(&b);
26    return mesh_check_done();
27}