2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
34#if defined(NCURSES_UI
) || defined(UAL_UI
)
35#include "ui_ncurses_compat.h"
38#include "ui_notcurses_compat.h"
42
43
44static void compile_time_checks(
void) {
46 UiConfig cfg = {.enable_mouse =
false, .enable_alt_screen =
false, .cursor_visible =
true, .tty_path = NULL};
48 UiRect rect = {.
y = 0, .
x = 0, .
lines = 10, .
cols = 20};
51 UiBorderKind bk = UI_BORDER_ROUNDED;
67 (
void)(UIKEY_NONE + UIKEY_CHAR + UIKEY_ENTER + UIKEY_ESCAPE +
68 UIKEY_UP + UIKEY_DOWN + UIKEY_LEFT + UIKEY_RIGHT +
69 UIKEY_F01 + UIKEY_F12);
70 (
void)(UI_MOUSE_NONE + UI_MOUSE_PRESS + UI_MOUSE_RELEASE +
71 UI_MOUSE_SCROLL_UP + UI_MOUSE_SCROLL_DOWN);
76
77
78static int test_lifecycle(
void) {
80 .enable_mouse =
false,
81 .enable_alt_screen =
true,
82 .cursor_visible =
false,
88 fprintf(stderr,
"FAIL: ui_init() returned NULL\n");
93 int lines = 0, cols = 0;
95 if (lines <= 0 || cols <= 0) {
96 fprintf(stderr,
"FAIL: invalid screen size %dx%d\n", lines, cols);
100 printf(
"PASS: screen size %d lines x %d cols\n", lines, cols);
104 printf(
"PASS: backend = %s\n",
111 printf(
"PASS: caps truecolor=%d palette256=%d mouse=%d unicode=%d resize=%d pairs=%d\n",
119 fprintf(stderr,
"FAIL: ui_surface_new() returned NULL\n");
123 printf(
"PASS: surface created\n");
128 ui_draw_border(s, BOX, UI_BORDER_ROUNDED, &style);
129 ui_draw_text(s, BOX, 1, 1, &style,
"UALUI conformance test");
131 printf(
"PASS: surface drawn and rendered\n");
134 UiRect fr = {.
y = 8, .
x = 4, .
lines = 6, .
cols = 30};
137 fprintf(stderr,
"FAIL: ui_framed_surface_new() failed\n");
142 ui_draw_border(fs.outer, WIN, UI_BORDER_LIGHT, &style);
145 printf(
"PASS: framed surface created and drawn\n");
151 printf(
"PASS: shutdown clean\n");
156 compile_time_checks();
157 printf(
"PASS: compile-time type checks\n");
158 return test_lifecycle();
UiRuntime * ui_init(const UiConfig *config, SIO *sio)
Initialize the UI runtime with the given configuration and SIO.
void ui_render()
Render the UI by updating panels and refreshing the display.
int ui_draw_text(UiSurface *s, ss_t w, uint y, uint x, const char *text)
on specified window, move to y, x, add string
void ui_surface_destroy(UiSurface *s)
Destroy a UiSurface, cleaning up its windows and panels.
void ui_get_screen_size(uint *lines, uint *cols)
Get the current screen size (number of lines and columns).
void ui_shutdown()
Shutdown the UI runtime, cleaning up resources and freeing memory.
UiSurface * ui_surface_new(ss_t w, UiSurface *parent, uint p, uint lines, uint cols, uint y, uint x)
Create a new UI surface with the specified parameters.
void ui_get_caps(UiCaps *caps)
Get the UI backend capabilities.
int main(int argc, char **argv)
Capture the current terminal settings for later restoration.
UiFramedSurface ui_framed_surface_new(UiSurface *parent, UiRect rect)
Creates a new framed surface with the specified parent and rectangle.
void ui_framed_surface_destroy(UiFramedSurface *fs)
Destroys a framed surface and releases its resources.
UiBackend ui_get_backend()
Get the UI backend type.