From 025cede85045bc20f894c8862cf46f307a3d2a77 Mon Sep 17 00:00:00 2001 From: Timerix Date: Fri, 9 Jan 2026 02:35:38 +0500 Subject: [PATCH] moved tim.h to include/ --- .vscode/.gitignore | 1 + .vscode/c_cpp_properties.json | 15 +++++++++++++++ example/ask.c | 3 +-- example/hello.c | 3 +-- example/snek.c | 3 +-- tim.h => include/tim.h | 1 - makefile | 2 ++ readme.md | 15 +-------------- test/color.c | 3 +-- test/string.c | 3 +-- test/test.c | 3 +-- test/width.c | 2 +- 12 files changed, 26 insertions(+), 28 deletions(-) create mode 100755 .vscode/.gitignore create mode 100755 .vscode/c_cpp_properties.json rename tim.h => include/tim.h (99%) diff --git a/.vscode/.gitignore b/.vscode/.gitignore new file mode 100755 index 0000000..c3d3a20 --- /dev/null +++ b/.vscode/.gitignore @@ -0,0 +1 @@ +settings.json \ No newline at end of file diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100755 index 0000000..724d44f --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,15 @@ +{ + "configurations": [ + { + "name": "all", + "defines": [], + "includePath": [ + "src", + "include", + "${default}" + ], + "cStandard": "c99" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/example/ask.c b/example/ask.c index f7ba7ec..39a4977 100644 --- a/example/ask.c +++ b/example/ask.c @@ -1,7 +1,7 @@ // Display a yes/no dialog with a message. Returns with 0 when yes was clicked. // syntax: ./ask "message" -#include "../tim.h" +#include "tim.h" // colors #define CTXT 0xf // text black, white @@ -47,4 +47,3 @@ int main(int argc, char** argv) { } } } - diff --git a/example/hello.c b/example/hello.c index aaeb9f2..2edd963 100644 --- a/example/hello.c +++ b/example/hello.c @@ -1,4 +1,4 @@ -#include "../tim.h" +#include "tim.h" int main(void) { while (tim_run(0)) { // event loop @@ -13,4 +13,3 @@ int main(void) { } } //TODO: remove atexit cleanup } - diff --git a/example/snek.c b/example/snek.c index f5cba8f..ba16035 100644 --- a/example/snek.c +++ b/example/snek.c @@ -1,6 +1,6 @@ // Simple game of snake to show how to do animation and draw cells. -#include "../tim.h" +#include "tim.h" #define FG 0x10 #define BG 0xdd @@ -127,4 +127,3 @@ int main(void) { } } } - diff --git a/tim.h b/include/tim.h similarity index 99% rename from tim.h rename to include/tim.h index 744d87a..e5a38c8 100644 --- a/tim.h +++ b/include/tim.h @@ -1,6 +1,5 @@ #pragma once -// libc #include #include #include diff --git a/makefile b/makefile index dbf0304..e8b0c31 100644 --- a/makefile +++ b/makefile @@ -1,3 +1,5 @@ +CFLAGS+=-Iinclude -Isrc -g + all: bin/test bin/string bin/color bin/hello bin/ask bin/snek bin/test: test/test.c bin diff --git a/readme.md b/readme.md index 397fac7..e0b2f70 100644 --- a/readme.md +++ b/readme.md @@ -5,20 +5,7 @@ Demo video: https://asciinema.org/a/zn3p0dsVCOQOzwY1S9gDfyaxQ ## quick start -#include "tim.h" // one header, no lib -int main(void) { // - while (tim_run(0)) { // event loop - scope (A, A, 24, 8) { // centered 24x8 scope - uint64_t c = 0x0a060f; // three colors - frame(0, 0, ~0, ~0, c); // draw frame for scope - label("Greetings!", A, 2, A, A, c); // label in top center - if (button("OK", A, ~1, 8, A, c)) // button in bottom center - return 0; // exit on button click - if (is_key_press('q')) // ctrl-c is masked - return 0; // exit on 'q' press - } // - } // atexit cleanup -} // +See [example/hello.c](./example/hello.c) ## layout diff --git a/test/color.c b/test/color.c index 08d9fa1..95b7061 100644 --- a/test/color.c +++ b/test/color.c @@ -1,6 +1,6 @@ // Shows xterm-256 color palette. -#include "../tim.h" +#include "tim.h" static void foo(int x, int y, int c) { char buf[16] = {0}; @@ -27,4 +27,3 @@ int main(void) { } } } - diff --git a/test/string.c b/test/string.c index 7e2a445..fdf9e83 100644 --- a/test/string.c +++ b/test/string.c @@ -1,6 +1,6 @@ // Test string functions. -#include "../tim.h" +#include "tim.h" #define U(s) (uint8_t*)(""s), (sizeof(s) - 1) #define TEST(t) printf("\33[3%s\33[0m %s\n", (t) ? "2mpass" : "1mfail", #t) @@ -68,4 +68,3 @@ int main(void) { TEST(is_wide_perhaps(U("한")) == true); TEST(is_wide_perhaps(U("𐍈")) == true); } - diff --git a/test/test.c b/test/test.c index 9d23f1c..6ae9ff8 100644 --- a/test/test.c +++ b/test/test.c @@ -1,4 +1,4 @@ -#include "../tim.h" +#include "tim.h" static inline void test_screen(TimEvent_t* e) { static TimEvent_t me; @@ -118,4 +118,3 @@ int main(void) { } } } - diff --git a/test/width.c b/test/width.c index 5413ce3..493a09d 100644 --- a/test/width.c +++ b/test/width.c @@ -1,7 +1,7 @@ // Test character width. #include -#include "../tim.h" +#include "tim.h" static int cp_to_utf8(int32_t cp, char* s) { assert(cp > 0 && cp < 0x110000);