reworded tart and now it works with utf8 and is enabled by defalt

This commit is contained in:
2026-01-29 10:47:16 -08:00
parent ee10de863d
commit 704f624f25
8 changed files with 493 additions and 622 deletions

30
test/CMakeLists.txt Normal file
View File

@@ -0,0 +1,30 @@
cmake_minimum_required(VERSION 3.20.0)
project(testing)
# CPP
set( CMAKE_CXX_STANDARD 11)
set( CMAKE_CXX_STANDARD_REQUIRED ON)
# C
set( CMAKE_C_STANDARD 11)
set( CMAKE_C_STANDARD_REQUIRED ON)
#set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/libs)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
set( CMAKE_COLOR_MAKEFILE ON)
set( CMAKE_COLOR_DIAGNOSTICS ON)
set( CMAKE_EXPORT_COMPILE_COMMANDS ON)
set( SOURCES
main.c
)
add_executable(
Testing
${SOURCES}
)
target_link_libraries(
Testing
TartLib
)

121
test/main.c Normal file
View File

@@ -0,0 +1,121 @@
#define TART_UTF8
#include "../includes/tart.h"
#include <unistd.h>
#include <signal.h>
#include <stdio.h>
#include <locale.h>
#define jump tart_move_cursor
int e = 1;
void aOnExit() {
//printf("shutting Down");
e = 0;
}
void draw_button(tart_window *w,const t_char* label, tart_vec2 position) {
jump(w, (tart_vec2){position.x,position.y + 0});
tart_printf(w, 1, T"┏━━━");
int size = t_strlen(label);
for(int i = 0; i < size; i++ ) {
tart_printf(w, 1, T"");
}
tart_printf(w, 1, T"━━━┓");
jump(w, (tart_vec2){position.x,position.y + 1});
tart_printf(w, 1, T"┃ %ls ┃", label);
jump(w, (tart_vec2){position.x,position.y + 2});
tart_printf(w, 1, T"┗━━━");
for(int i = 0; i < size; i++ ) {
tart_printf(w, 1, T"");
}
tart_printf(w, 1, T"━━━┛");
}
int main(int argc, char *argv[])
{
signal(SIGINT, aOnExit);
setlocale(LC_CTYPE, "en_US.UTF-8");
tart_window w;
int color0 = 0;
int color1 = 0;
int color2 = 0;
tart_create_window(&w, (tart_vec2){80,40}, "testing");
tart_init(&w);
tart_disable_cusor();
w.pallet[0].background.r = 0;
w.pallet[0].background.g = 0;
w.pallet[0].background.b = 0;
w.pallet[0].forground.r = 0;
w.pallet[0].forground.g = 0;
w.pallet[0].forground.b = 0;
w.pallet[1].forground.r = 0xff;
w.pallet[1].forground.g = 0x00;
w.pallet[1].forground.b = 0xcc;
w.pallet[2].forground.r = 0x3b;
w.pallet[2].forground.g = 0x3b;
w.pallet[2].forground.b = 0x3b;
jump(&w, (tart_vec2){1,1});
jump(&w, (tart_vec2){1,2});
int x = 0;
while(e != 0) {
tart_draw(&w);
draw_button(&w, T"This is really cool!", (tart_vec2){5,5});
tart_jump(&w, (tart_vec2){3,10});
tart_printf(&w,1, T"this is\na new line test\nyay");
tart_jump(&w, (tart_vec2){3+ 20,10});
tart_printf(&w,1, T"this is\na new line test\nyay");
tart_jump(&w, (tart_vec2){3,14});
tart_printf(&w,2, T"this is\na new line test\nyay");
if(w.pallet[1].forground.r == 254) {
color0 = 0;
}
if(w.pallet[1].forground.r == 0) {
color0 = 1;
}
if(w.pallet[1].forground.g == 254) {
color1 = 0;
}
if(w.pallet[1].forground.g == 0) {
color1 = 1;
}
if(w.pallet[1].forground.b == 254) {
color2 = 0;
}
if(w.pallet[1].forground.b == 0) {
color2 = 1;
}
if(color0 == 1) {
w.pallet[1].forground.r++;
}else {
w.pallet[1].forground.r--;
}
if(color1 == 1) {
w.pallet[1].forground.g++;
}else {
w.pallet[1].forground.g--;
}
if(color2 == 1) {
w.pallet[1].forground.b++;
}else {
w.pallet[1].forground.b--;
}
}
tart_close(&w);
tart_enable_cusor();
//printf("\e[?1049l");
printf("done\n");
return 0;
}