moved code from header to source files
This commit is contained in:
52
test/test.c
52
test/test.c
@@ -1,9 +1,9 @@
|
||||
#include "tim.h"
|
||||
|
||||
static inline void test_screen(TimEvent_t* e) {
|
||||
static TimEvent_t me;
|
||||
static TimEvent_t ke;
|
||||
static int render_us;
|
||||
static inline void test_screen(TimEvent* e) {
|
||||
static TimEvent me;
|
||||
static TimEvent ke;
|
||||
static i32 render_us;
|
||||
char buf[64];
|
||||
|
||||
ke = (e->type == KEY_EVENT) ? *e : ke;
|
||||
@@ -46,8 +46,8 @@ static inline void test_screen(TimEvent_t* e) {
|
||||
label("multi\nliñe\nlabël", 24, 1, A, A, 0xf);
|
||||
|
||||
// colors
|
||||
scope (1, 5, 16, 5) {
|
||||
frame(0, 0, ~0, ~0, 0xf);
|
||||
tim_scope(1, 5, 16, 5) {
|
||||
tim_frame(0, 0, ~0, ~0, 0xf);
|
||||
label(" Red ", 1, 1, 7, A, 0x0900);
|
||||
label(" ", 8, 1, 7, A, 0xc400);
|
||||
label(" Green ", 1, 2, 7, A, 0x0a00);
|
||||
@@ -57,16 +57,16 @@ static inline void test_screen(TimEvent_t* e) {
|
||||
}
|
||||
|
||||
// button
|
||||
static uint64_t bc = 0x100;
|
||||
static u64 bc = 0x100;
|
||||
if (button("Click Me", 17, 5, 16, 5, bc)) {
|
||||
bc = (bc + 0x100) & 0xff00;
|
||||
}
|
||||
|
||||
// edit
|
||||
static TimEdit_t ed1;
|
||||
static TimEdit_t ed2;
|
||||
edit_init(&ed1, 32, "Edit 1");
|
||||
edit_init(&ed2, 32, "");
|
||||
static TimEditState ed1;
|
||||
static TimEditState ed2;
|
||||
TimEditState_init(&ed1, 32, "Edit 1");
|
||||
TimEditState_init(&ed2, 32, "");
|
||||
edit(&ed1, 1, 10, 32, 0xff00ff);
|
||||
sprintf(buf, "cursor: %d length: %d", ed1.cursor, ed1.length);
|
||||
label(buf, 2, 13, A, A, 0xf);
|
||||
@@ -74,46 +74,46 @@ static inline void test_screen(TimEvent_t* e) {
|
||||
label(ed2.s, 2, 17, A, A, 0xf);
|
||||
|
||||
// checkbox
|
||||
static int chk[2] = {-1, 1};
|
||||
static i32 chk[2] = {-1, 1};
|
||||
check("Check 1", &chk[0], 1, 18, A, 0xa000f);
|
||||
check("Check 2", &chk[1], 14, 18, A, 0xa000f);
|
||||
|
||||
// radiobox
|
||||
static int rad = 0;
|
||||
static i32 rad = 0;
|
||||
radio("Radio 1", &rad, 1, 1, 19, A, 0xa000f);
|
||||
radio("Radio 2", &rad, 2, 14, 19, A, 0xa000f);
|
||||
radio("Radio 3", &rad, 3, 1, 20, A, 0xa000f);
|
||||
radio("Radio 4", &rad, 4, 14, 20, A, 0xa000f);
|
||||
|
||||
// scope nesting
|
||||
scope(~1, 1, 20, 10) {
|
||||
scope(0, 0, 10, 5) {
|
||||
frame(0, 0, ~0, ~0, 0x9);
|
||||
tim_scope(~1, 1, 20, 10) {
|
||||
tim_scope(0, 0, 10, 5) {
|
||||
tim_frame(0, 0, ~0, ~0, 0x9);
|
||||
}
|
||||
scope(~0, 0, 10, 5) {
|
||||
frame(0, 0, ~0, ~0, 0xa);
|
||||
tim_scope(~0, 0, 10, 5) {
|
||||
tim_frame(0, 0, ~0, ~0, 0xa);
|
||||
}
|
||||
scope(~0, ~0, 10, 5) {
|
||||
frame(0, 0, ~0, ~0, 0xb);
|
||||
tim_scope(~0, ~0, 10, 5) {
|
||||
tim_frame(0, 0, ~0, ~0, 0xb);
|
||||
}
|
||||
scope(0, ~0, 10, 5) {
|
||||
frame(0, 0, ~0, ~0, 0xc);
|
||||
tim_scope(0, ~0, 10, 5) {
|
||||
tim_frame(0, 0, ~0, ~0, 0xc);
|
||||
}
|
||||
}
|
||||
|
||||
// funny characters
|
||||
scope (~1, ~3, 11, 5) {
|
||||
frame(0, 0, ~0, ~0, 0xf);
|
||||
tim_scope(~1, ~3, 11, 5) {
|
||||
tim_frame(0, 0, ~0, ~0, 0xf);
|
||||
label("123456789", 1, 1, 9, A, 0x0f05);
|
||||
label("$£ह€𐍈6789", 1, 2, A, A, 0x0f05);
|
||||
label("圍棋56789", 1, 3, A, A, 0x0f05);
|
||||
}
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
i32 main(void) {
|
||||
while (tim_run(1.5)) {
|
||||
test_screen(&tim.event);
|
||||
if (is_key_press('q') || is_key_press(TimKey_Escape)) {
|
||||
if (tim_is_key_press('q') || tim_is_key_press(TimKey_Escape)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user