Compare commits

17 Commits

24 changed files with 611 additions and 837 deletions

6
.gitmodules vendored
View File

@@ -1,6 +0,0 @@
[submodule "externals/Pickler"]
path = externals/Pickler
url = http://www.gitea.preacherdhm.com/PreacherDHM/Pickler.git
[submodule "testing/externals/Pickler"]
path = testing/externals/Pickler
url = http://www.gitea.preacherdhm.com/PreacherDHM/Pickler.git

View File

@@ -24,5 +24,6 @@ enable_testing()
add_subdirectory(externals) add_subdirectory(externals)
# PROJECT # PROJECT
add_subdirectory(source) add_subdirectory(source)
add_subdirectory(testing) #
add_subdirectory(test)

28
examples/CMakeLists.txt Normal file
View File

@@ -0,0 +1,28 @@
project(TartTest)
#add_subdirectory(externals)
set( CMAKE_CXX_STANDARD 11)
set( CMAKE_CXX_STANDARD_REQUIRED ON)
set( SOURCES
main.cpp
test_tart.cpp
test_term.cpp
)
#set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin/tests)
#
#add_executable(${PROJECT_NAME} ${SOURCES} )
#target_link_libraries(${PROJECT_NAME} TartLib PickleLib)
#
#if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
# add_test(${PROJECT_NAME} "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/testing")
#endif()
#if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
# add_test(${PROJECT_NAME} "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/testing.exe")
#endif()
#
#project(InputTartTest)
#set( CMAKE_CXX_STANDARD 11)
#set( CMAKE_CXX_STANDARD_REQUIRED ON)
#add_executable(${PROJECT_NAME} input.cpp )
#target_link_libraries(${PROJECT_NAME} TartLib PickleLib)
add_subdirectory(render_test)

View File

@@ -0,0 +1,81 @@
#include <tart.h>
#include <memory.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
//int main (int argc, char *argv[]) {
// struct tart_window window = tart_create_window();
// struct tart_buffer mainbuff = tart_create_buffer(109, {40,20},{20,20});
// struct tart_cell* cells = (struct tart_cell*)malloc(mainbuff.cell_count * sizeof(struct tart_cell));
// for(int i = 1; i < mainbuff.cell_count; i += 2) {
// cells[i] = tart_create_cell('^', TART_STYLE_BLINKING, TART_COLOR_BLACK_FOREGROUND, TART_COLOR_WHITE_BACKGROUND);
// }
// for(int i = 0; i < + mainbuff.cell_count; i += 2) {
// cells[i] = tart_create_cell('^', TART_STYLE_BLINKING, TART_COLOR_RED_FOREGROUND, TART_COLOR_BLACK_BACKGROUND);
// }
// tart_add_cells_to_buffer(&mainbuff, cells);
//
// struct tart_vec2 positions[4] = {{0,0},{0,1},{1,0},{1,1}};
// struct tart_cell cell = tart_create_cell('0', TART_STYLE_BLINKING, TART_COLOR_RED_FOREGROUND, TART_COLOR_GREEN_BACKGROUND);
// struct tart_cell cellss[4] = {cell,cell,cell,cell};
//
// struct tart_csprite sprite = tart_csprite(cellss,positions,4);
// tart_draw_csprite_position(&mainbuff, sprite, {2,2});
// tart_draw_csprite_position(&mainbuff, sprite, {5,2});
// tart_draw_csprite_position(&mainbuff, sprite, {5,5});
// tart_draw_csprite_position(&mainbuff, sprite, {39,18});
//
// float x = 0;
// tart_byte layer = tart_add_buffer(&window, mainbuff);
// char t[1] = {'0'};
// struct tart_vec2 p = {0,0};
//
// term_disable_cursor();
// term_threaded_input_init();
// char* bbuf = term_tinputb();
// for(;;) {
// printf("\033[H");
// struct tart_buffer* buf = tart_get_buffer(&window, 0);
// tart_draw_csprite_position(buf, sprite, {3,18});
// tart_draw_csprite_position(buf, sprite, p);
// tart_draw_window(&window, t);
// tart_restore_window(&window);
// tart_restore_buffer(buf);
// if(term_tinput() == 's') {
// x += 0.01;
// }
// if(term_tinput() == 'q') {
// break;
// }
// // p.x = (int)x;
// }
// term_threaded_input_stop();
// term_enable_cursor();
// exit(0);
// //term_getche();
// //term_threaded_input_stop();
// return 0;
//}
char* bbuf;
int main (int argc, char *argv[]) {
int n;
int counter = 0;
term_disable_cursor();
term_threaded_input_init();
bbuf = term_tinputb();
while(bbuf[0] != 'q') {
std::cout << counter++ << '[';
for (int i = 0; i < 8; i++) {
std::cout << bbuf[i] << ',';
}
std::cout << "] \r";
}
std::cout << '\n';
term_threaded_input_stop();
term_enable_cursor();
exit(0);
return 0;
}

View File

@@ -1,42 +1,105 @@
#ifndef TART_H #ifndef TART_H
#define TART_H #define TART_H
#include <string.h>
#define TART_UTF8
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#include "../source/term.h" typedef char tart_display;
// #========================================================================#
// | PreacherDHM:TART
// |
// | Tarts stands for Terminal Art. Tart is a terminal renderer that uses a |
// | render buffer like system that takes csprites or character sprites and |
// | displays them in the terminal. The render buffer consists of cells and |
// | each cell consists of
// | - Color
// | - Rendered Character
// | - Reset
// | In toaltol around 19 to 24 bytes. This alows for complete controle |
// | over each cell.
// #========================================================================#
#ifdef TART_RGB_COLORS
#define NULL_CELL (struct tart_cell){{0,0,0},{0,0,0},0,0,0}
#define TART_CELL_DATA_SIZE 16 // todo add number typedef unsigned int TART_FLAGS;
typedef unsigned char tart_byte;
typedef unsigned short tart_id;
#ifdef TART_UTF8
#include <wchar.h>
#undef t_char
typedef wchar_t t_char;
#else #else
#define NULL_CELL (struct tart_cell){0,0,0,0} typedef char t_char;
#define TART_CELL_DATA_SIZE 20
#endif #endif
typedef struct {
tart_byte r;
tart_byte g;
tart_byte b;
} tart_color;
#ifndef TART_PALET_SIZE
#define TART_PALET_SIZE 32
#endif
typedef struct {
tart_color forground;
tart_color background;
} tart_pallet;
typedef struct {
int x;
int y;
} tart_vec2;
#ifdef TART_UTF8
#define TART_CELL_SIZE 36 * 2
#else
#define TART_CELL_SIZE 26 + 19
#endif
typedef unsigned int tart_uint;
typedef unsigned int tart_style;
typedef char tart_cell[TART_CELL_SIZE];
typedef struct {
tart_cell** buffer;
tart_vec2 curser;
tart_vec2 jump;
tart_uint bufferSize;
int fd;
}tart_buffer;
/* Tart Window
*
* The tart window will have the window size and all of the buffers.
**/
typedef struct {
tart_pallet pallet[TART_PALET_SIZE];
tart_vec2 homePosition;
tart_vec2 windowSize;
tart_vec2 terminalSize;
tart_buffer buffer;
const char* name;
}tart_window ;
#define TART_OK 0 #define TART_OK 0
#define TART_NG -1
#define TART_SET_FLAG(f,x) f |= (x)
#define TART_STYLE_BOLD 1 #define TART_STYLE_NONE 0
#define TART_STYLE_DIM 2 #define TART_STYLE_BOLD 1 << 0
#define TART_STYLE_UNDERLINE 4 #define TART_STYLE_DIM 1 << 1
#define TART_STYLE_BLINKING 5 #define TART_STYLE_ITALIC 1 << 2
#define TART_STYLE_INVERSE 7 #define TART_STYLE_UNDERLINE 1 << 3
#define TART_STYLE_HIDDEN 8 #define TART_STYLE_BLINKING 1 << 4
#define TART_STYLE_STRIKETHROUGH 9 #define TART_STYLE_INVERSE 1 << 5
#define TART_STYLE_HIDDEN 1 << 6
#define TART_STYLE_STRIKETHROUGH 1 << 7
#define TART_STYLE_DRAW_BOLD 1
#define TART_STYLE_DRAW_DIM 2
#define TART_STYLE_DRAW_ITALIC 3
#define TART_STYLE_DRAW_UNDERLINE 4
#define TART_STYLE_DRAW_BLINKING 5
#define TART_STYLE_DRAW_INVERSE 7
#define TART_STYLE_DRAW_HIDDEN 8
#define TART_STYLE_DRAW_STRIKETHROUGH 9
#define TART_COLOR_BLACK_FOREGROUND 30 #define TART_COLOR_BLACK_FOREGROUND 30
#define TART_COLOR_RED_FOREGROUND 31 #define TART_COLOR_RED_FOREGROUND 31
@@ -76,126 +139,58 @@ extern "C" {
#define TART_COLOR_BRIGHT_CYAN_BACKGROUND 106 #define TART_COLOR_BRIGHT_CYAN_BACKGROUND 106
#define TART_COLOR_BRIGHT_WHITE_BACKGROUND 107 #define TART_COLOR_BRIGHT_WHITE_BACKGROUND 107
typedef unsigned char tart_byte; #define T ""
typedef unsigned short tart_id; #define TC(x) x
struct tart_vec2 { #define t_strlen strlen
unsigned short x,y; #define t_strcmp strcmp
}; #define t_strcpy strcpy
#define t_strncpy strncpy
struct tart_rgb { #define t_snprintf snprintf
tart_byte r,g,b; #define t_sprintf sprintf
}; #define t_vsprintf vsprintf
#define t_vsnprintf vsnprintf
/* Tart Cell #ifdef TART_UTF8
* #undef T
* This holds a rgb for the foreground and the background. #define T L""
* Includeing the display character. #undef TC
* #define TC(x) L##x
*/ #undef t_strlen
#ifdef TART_RGB_COLORS #define t_strlen wcslen
struct tart_cell { #undef t_strcmp
struct tart_rgb foreground; #define t_strcmp wcscmp
struct tart_rgb background; #undef t_snprintf
tart_byte style; #define t_snprintf swprintf
char display; #undef t_sprintf
}; #define t_sprintf wprintf
#else #undef t_vsprintf
struct tart_cell { #define t_vsprintf vswprintf
tart_byte foreground; #undef t_vsnprintf
tart_byte background; #define t_vsnprintf vswprintf
tart_byte style; #undef t_strcpy
char display; #define t_strcpy wcscpy
}; #undef t_strncpy
#define t_strncpy wcncpy
#endif #endif
struct tart_cstring { int tart_create_window(tart_window* w, tart_vec2 ws, const char* title);
struct tart_cell* data; int tart_init(tart_window* w);
long size; int tart_close(tart_window* w);
}; void tart_disable_cusor();
void tart_enable_cusor();
int tart_draw(tart_window* w);
struct tart_csprite { int tart_jump(tart_window* w, tart_vec2 pos);
struct tart_cell* data; int tart_move_cursor(tart_window* w, tart_vec2 pos);
struct tart_vec2* position; int tart_insert_cell(tart_window* w, tart_byte p, t_char c);
struct tart_vec2 bounds; int tart_printf(tart_window* w,tart_byte p, const t_char* c, ...);
long size; int tart_box(tart_window* w, tart_byte bp, tart_byte fp, const t_char* c,
}; tart_vec2 fpos,
tart_vec2 spos);
/* Tart Buffer int tart_line(tart_window* w, tart_byte p, const t_char* c, tart_vec2 fpos,
* tart_vec2 spos);
* The Buffer is a contner that holds all of the cells for that buffer.
* Allso containes the size of the buffer.
*
* ........................width...............
* ..........<-------------------------------->.
* ........^ @################################@.
* ........| #................................#.
* ........| #................................#.
* height--| #.............Buffer.............#.
* ........| #................................#.
* ........| #................................#.
* ........V @################################@.
*/
struct tart_buffer {
unsigned int cell_count;
tart_byte layer;
tart_id id;
struct tart_vec2 size;
struct tart_vec2 position;
struct tart_cell* cells;
};
/* Tart Window
*
* The tart window will have the window size and all of the buffers.
**/
struct tart_window {
struct tart_buffer buffers[0xFF+1];
tart_byte buffer_count;
struct tart_vec2 size;
char* data;
int data_count;
};
struct tart_window tart_create_window();
struct tart_buffer tart_create_buffer(tart_id id, struct tart_vec2 size, struct tart_vec2 position);
#ifdef TART_RGB_COLORS
struct tart_cell tart_create_cell(char display, tart_byte style, struct tart_rgb foreground, struct tart_rgb background);
#else
struct tart_cell tart_create_cell(char display, tart_byte style, tart_byte foreground, tart_byte background);
#endif
tart_byte tart_add_buffer(struct tart_window*, struct tart_buffer);
tart_byte tart_remove_buffer(struct tart_window*, tart_id);
tart_byte tart_set_buffer(struct tart_window*, struct tart_buffer, tart_byte);
struct tart_buffer* tart_get_buffer(struct tart_window*, tart_byte);
struct tart_cell* tart_get_cell(struct tart_buffer*, int);
struct tart_cell tart_set_cell(struct tart_buffer*, struct tart_cell,int);
tart_byte tart_draw_window(struct tart_window*, char*);
tart_byte tart_add_cells_to_buffer(struct tart_buffer*, struct tart_cell*);
// rendering
// Resering positionial cells.
struct tart_cstring tart_cstring(char* string, long, struct tart_cell type);
tart_byte tart_cstring_free(struct tart_cstring*);
struct tart_cstring tart_cstring_append(struct tart_cstring*, struct tart_cstring*);
struct tart_csprite tart_csprite(struct tart_cell*, struct tart_vec2*, long);
tart_byte tart_csprite_free(struct tart_csprite*);
tart_byte tart_draw_cell_position(struct tart_buffer*, struct tart_cell, struct tart_vec2);
tart_byte tart_draw_cstring_position(struct tart_buffer*, struct tart_cstring, struct tart_vec2);
tart_byte tart_draw_csprite_position(struct tart_buffer*, struct tart_csprite, struct tart_vec2);
/*
* tart_restore_buffer sets the buffer to NULL_CELL.
* */
tart_byte tart_restore_buffer(struct tart_buffer*);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -5,8 +5,6 @@ set( CMAKE_C_STANDARD_REQUIRED ON)
set(LIB_SOURCES set(LIB_SOURCES
term.c
term.h
tart.c tart.c
) )

View File

@@ -1,201 +1,255 @@
#include "../includes/tart.h" #include "../includes/tart.h"
#include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <memory.h> #include <string.h>
#include "term.h" #include <strings.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <wchar.h>
struct tart_cell tart_test() {
#ifdef TART_RGB_COLORS #define BUFFER_AT_POS(W) (W->windowSize.x * W->buffer.curser.y) + W->buffer.curser.x
return (struct tart_cell){{0,0,0}, {0,0,0}, 0, '&',0}; #define BUFFER_LINE_SIZE (w->windowSize.x) * TART_CELL_SIZE + sizeof(tart_cell)
#define BUFFER_SIZE (w->windowSize.x * w->windowSize.y)
#define BUFFER_BUFFER_SIZE BUFFER_LINE_SIZE * w->windowSize.y
tart_vec2 GetTerminalSize(tart_window* w) {
struct winsize win;
ioctl(STDOUT_FILENO, TIOCGWINSZ, &win);
return (tart_vec2){win.ws_col,win.ws_row};
};
int tart_create_buffer(tart_window* w) {
w->buffer.buffer = (tart_cell**)malloc(w->windowSize.y * sizeof(tart_cell*));
if(w->buffer.buffer == NULL) {
return TART_NG;
}
for(int i = 0; i < w->windowSize.y; i++) {
int x = BUFFER_LINE_SIZE;
w->buffer.buffer[i] = (tart_cell*)malloc(x);
bzero(w->buffer.buffer[i], (BUFFER_LINE_SIZE));
}
tart_cell ce;
bzero(ce, TART_CELL_SIZE);
snprintf(ce,TART_CELL_SIZE,
#ifdef TART_UTF8
"\e[38;2;%03hhu;%03hhu;%03hhum%lc\e[0m",
#else #else
return (struct tart_cell){196,105,0,'&'}; "\e[38;2;%03hhu;%03hhu;%03hhum%c\e[0m",
#endif #endif
} w->pallet[0].forground.r,
struct tart_window tart_create_window() { w->pallet[0].forground.g,
struct tart_window window; w->pallet[0].forground.b,
window.buffer_count = 0; #ifdef TART_UTF8
for(int i = 0; i < 0xFF; i++) { L' '
window.buffers[i] = tart_create_buffer(0, (struct tart_vec2){0,0},(struct tart_vec2){0,0});
}
window.size = term_current_size();
window.data = malloc((window.size.x * window.size.y * sizeof(char) * TART_CELL_DATA_SIZE)+ 100 );
for(int g = 0; g < (window.size.x * window.size.y * sizeof(char) * TART_CELL_DATA_SIZE)+ 100; g++) {
window.data[g] = '\0';
}
window.data_count = (window.size.x * window.size.y * sizeof(char) * TART_CELL_DATA_SIZE)+ 100;
return window;
}
struct tart_buffer tart_create_buffer(tart_id id, struct tart_vec2 size, struct tart_vec2 position) {
unsigned int cell_count = size.x * size.y;
struct tart_cell* cells = (struct tart_cell*)malloc((size.x * size.y) * sizeof(struct tart_cell));
for (int i = 0;i < cell_count;i++) {
cells[i] = NULL_CELL;
}
unsigned int data_count = (size.x*size.y) * TART_CELL_DATA_SIZE;
struct tart_buffer buf = {cell_count,0,id,size,position,cells}; // -NOTE- dose not set the layer
return buf;
}
#ifdef TART_RGB_COLORS
struct tart_cell tart_create_cell(char display, tart_byte style, struct tart_rgb foreground, struct tart_rgb background) {
struct tart_cell b = {foreground, background, style, display,0};
return b;
}
#else #else
' '
struct tart_cell tart_create_cell(char display, tart_byte style,
tart_byte foreground, tart_byte background) {
return (struct tart_cell){foreground,background,style,display};
}
#endif #endif
tart_byte tart_add_buffer(struct tart_window* window, struct tart_buffer buffer) { );
if(window->buffer_count <= 0xFF) { for(int i = 0; i < w->windowSize.y; i++ ) {
window->buffers[window->buffer_count] = buffer; for(int j = 0; j < w->windowSize.x + 1; j++) {
window->buffer_count++; memcpy(w->buffer.buffer[i][j], ce, sizeof(tart_cell));
return window->buffer_count; }
} //t_snprintf(w->buffer.buffer[i][w->windowSize.x],
return 0; // TART_CELL_SIZE,
// TC("\e[1B\e[%dC"),
// w->windowSize.x);
}
w->buffer.curser = (tart_vec2){0,0};
//bzero(w->buffer.buffer[w->windowSize.y], (BUFFER_LINE_SIZE));
//t_snprintf(w->buffer.buffer[w->windowSize.y][w->windowSize.x],
// TART_CELL_SIZE,
// TC("\e[n")
// );
return TART_OK;
} }
tart_byte tart_set_buffer(struct tart_window* window, struct tart_buffer buffer, tart_byte layer) {
if(layer <= 0xFF) { void tart_free_buffer(tart_window* w) {
window->buffers[layer] = buffer; free(w->buffer.buffer);
return layer; }
int tart_create_window(tart_window* w, tart_vec2 ws, const char* title) {
w->windowSize.x = GetTerminalSize(w).x - 1;
w->windowSize.y = GetTerminalSize(w).y;
w->terminalSize = GetTerminalSize(w);
w->homePosition = (tart_vec2){
(w->terminalSize.x / 2) - (w->windowSize.x / 2),
(w->terminalSize.x / 2) - (w->windowSize.x / 2)
};
tart_create_buffer(w);
return TART_OK;
}
int flush_buffer(tart_window* w) {
tart_cell ce;
bzero(ce, TART_CELL_SIZE);
snprintf(ce,TART_CELL_SIZE,
#ifdef TART_UTF8
"\e[48;2;%03hhu;%03hhu;%03hhum\e[38;2;%03hhu;%03hhu;%03hhum%lc\e[0m",
#else
"\e[38;2;%03hhu;%03hhu;%03hhum%c\e[0m",
#endif
w->pallet[0].background.r,
w->pallet[0].background.g,
w->pallet[0].background.b,
w->pallet[0].forground.r,
w->pallet[0].forground.g,
w->pallet[0].forground.b,
#ifdef TART_UTF8
L' '
#else
' '
#endif
);
for(int i = 0; i < w->windowSize.y; i++) {
for(int j = 0; j < w->windowSize.x ; j++) {
bzero(w->buffer.buffer[i][j], sizeof(tart_cell));
memcpy(w->buffer.buffer[i][j], ce, sizeof(tart_cell));
}
} }
return 0; return 0;
} }
struct tart_buffer* tart_get_buffer(struct tart_window* window, tart_byte layer) { void flush_palets(tart_window* w) {
return &window->buffers[layer]; for(int i = 0; i < TART_PALET_SIZE; i++) {
w->pallet[i].background.r = 0;
w->pallet[i].background.g = 0;
w->pallet[i].background.b = 0;
w->pallet[i].forground.r = 254;
w->pallet[i].forground.g = 254;
w->pallet[i].forground.b = 254;
}
} }
struct tart_cell* tart_get_cell(struct tart_buffer* buffer, int idx) { int tart_init(tart_window* w) {
return &buffer->cells[idx]; int y = 0;
int x = 0;
w->buffer.jump = (tart_vec2){0,0};
flush_buffer(w);
flush_palets(w);
//t_snprintf(ce,TART_CELL_SIZE, TC("\e[%d;%dh"),
// (w->terminalSize.x/2)-(w->windowSize.x/2),
// (w->terminalSize.y/2)-(w->windowSize.y/2));
//write(STDOUT_FILENO, ce, TART_CELL_SIZE);
write(STDOUT_FILENO, "\e[?1049h", 8);
write(STDOUT_FILENO, "\e[H", 3);
write(STDOUT_FILENO, "\e[s", 3);
return TART_OK;
} }
struct tart_cell tart_set_cell(struct tart_buffer* buffer, struct tart_cell cell,int idx) { void tart_disable_cusor() {
struct tart_cell c = buffer->cells[idx]; write(STDOUT_FILENO, "\e[?25l", 8);
buffer->cells[idx] = cell; }
return c; void tart_enable_cusor() {
write(STDOUT_FILENO, "\e[?25h", 8);
} }
tart_byte tart_draw_window(struct tart_window * window, char* rend_buffer) { int tart_close(tart_window* w) {
int offset = 0; write(STDOUT_FILENO, "\e[?1049l", 8);
int i = 0; //for(int i = 0; i < w->windowSize.y; i++) {
for (int b = 0;b < 0xFF; b++) { // free(w->buffer.buffer[i]);
if(window->buffers[b].cell_count == 0) //}
continue; //free(w->buffer.buffer);
for (int y = 0; y < window->buffers[b].size.y; y++) { return TART_OK;
for (int x = 0; x < window->buffers[b].size.x; x++) { }
// add data to window c buffer. int tart_draw(tart_window* w) {
struct tart_cell cell = window->buffers[b].cells[(y*window->buffers[b].size.x) + x]; for(int i = 0; i < w->windowSize.y; i++) {
char pre[TART_CELL_DATA_SIZE]; for(int j = 0; j < w->windowSize.x + 1; j++) {
int size = sprintf(pre, "\033[%d;%d;%dm%c\033[0;0m", (int)cell.style, cell.foreground, cell.background, cell.display); write(STDOUT_FILENO,
for(int preIdx = 0; preIdx < size; preIdx++) { w->buffer.buffer[i][j],
window->data[(y*window->buffers[b].size.x) + x + offset] = pre[preIdx]; TART_CELL_SIZE
offset++; );
}
}
window->data[((y)*window->buffers[b].size.x) + offset + window->buffers[b].size.x] = '\n';
offset++;
// add cursor move command.
i++;
} }
} }
fwrite(window->data, sizeof(char), window->data_count, stdout); flush_buffer(w);
write(STDOUT_FILENO, "\e[u", strlen("\e[u"));
return TART_OK; return TART_OK;
}; }
tart_byte tart_add_cells_to_buffer(struct tart_buffer* buffer, struct tart_cell* cells) { int tart_jump(tart_window* w, tart_vec2 pos) {
for(int i = 0; i < buffer->cell_count; i++) { w->buffer.jump = pos;
buffer->cells[i] = cells[i]; w->buffer.curser = pos;
}
return TART_OK; return TART_OK;
} }
int tart_move_cursor(tart_window* w, tart_vec2 pos) {
struct tart_cstring tart_cstring(char *string, long size, struct tart_cell type){ if(pos.x >= w->windowSize.x) {
struct tart_cstring str = {0,size}; for(int i = pos.x; i >= w->windowSize.x; i /= w->windowSize.x) {
str.data = malloc(size * sizeof(struct tart_cell)); w->buffer.curser.x = i;
return str; w->buffer.curser.y++;
}
tart_byte tart_cstring_free(struct tart_cstring* string) {
free(string->data);
string->size = 0;
return TART_OK;
}
struct tart_cstring tart_cstring_append(struct tart_cstring* lhs, struct tart_cstring* rhs) {
struct tart_cstring ret = {0,0};
ret.size = lhs->size + rhs->size;
ret.data = malloc(ret.size * sizeof(struct tart_cell));
for(int i = 0; i < lhs->size; i++) {
ret.data[i] = lhs->data[i];
}
for(int i = 0; i < rhs->size; i++) {
ret.data[lhs->size + i] = rhs->data[i];
}
return ret;
}
struct tart_csprite tart_csprite(struct tart_cell* cells, struct tart_vec2* positions, long size) {
struct tart_csprite sprite = {0,0,0,size};
sprite.data = cells;
sprite.position = positions;
for(int i = 0; i < size; i++) {
if(positions[i].x > sprite.bounds.x) {
sprite.bounds.x = positions[i].x;
} }
} else {
if(positions[i].y > sprite.bounds.y) { w->buffer.curser.x = pos.x;
sprite.bounds.y = positions[i].y; }
if(pos.y >= w->windowSize.y - 1) {
for(int i = pos.y; i >= w->windowSize.y - 1; i /= w->windowSize.y) {
w->buffer.curser.y = i;
} }
}else {
w->buffer.curser.y = pos.y;
} }
return sprite;
};
tart_byte tart_csprite_free(struct tart_csprite* sprite) {
sprite->bounds.x = 0;
sprite->bounds.y = 0;
sprite->size = 0;
free(sprite->data);
free(sprite->position);
return TART_OK; return TART_OK;
} }
int tart_insert_cell(tart_window* w, tart_byte p, t_char c) {
tart_byte tart_draw_cell_position(struct tart_buffer * buffer, struct tart_cell cell, struct tart_vec2 position) { if(c == TC('\n')) {
if(buffer->size.y >= position.y && buffer->size.x >= position.x) { tart_move_cursor(w, (tart_vec2){w->buffer.jump.x, w->buffer.curser.y + 1});
buffer->cells[(buffer->size.x * position.y) + position.x] = cell; return TART_OK;
} }
bzero(w->buffer.buffer[w->buffer.curser.y][w->buffer.curser.x], TART_CELL_SIZE);
tart_cell ce;
bzero(ce, TART_CELL_SIZE);
snprintf(ce,TART_CELL_SIZE,
#ifdef TART_UTF8
"\e[48;2;%03hhu;%03hhu;%03hhum\e[38;2;%03hhu;%03hhu;%03hhum%lc\e[0m",
#else
"\e[48;2;%03hhu;%03hhu;%03hhum\e[38;2;%03hhu;%03hhu;%03hhum%c\e[0m",
#endif
w->pallet[p].background.r,
w->pallet[p].background.g,
w->pallet[p].background.b,
w->pallet[p].forground.r,
w->pallet[p].forground.g,
w->pallet[p].forground.b,
c
);
memcpy(w->buffer.buffer[w->buffer.curser.y][w->buffer.curser.x], ce, TART_CELL_SIZE);
tart_move_cursor(w, (tart_vec2){w->buffer.curser.x + 1, w->buffer.curser.y});
return TART_OK; return TART_OK;
} }
int tart_printf(tart_window* w,tart_byte p, const t_char* c, ...) {
tart_byte tart_draw_cstring_position(struct tart_buffer *buffer, struct tart_cstring string, struct tart_vec2 position) { va_list args;
struct tart_vec2 pos = position; va_start(args, c);
for(int i = 0; i < string.size; i++) { t_char tmp[1024];
tart_draw_cell_position(buffer, string.data[i], pos); t_vsnprintf(tmp,1024, c, args);
pos.x++; for(int i = 0; i < t_strlen(tmp); i++) {
tart_insert_cell(w, p, tmp[i]);
} }
va_end(args);
return TART_OK; return TART_OK;
} }
int tart_box(tart_window* w, tart_byte bp, tart_byte fp, const t_char* c,
tart_byte tart_draw_csprite_position(struct tart_buffer * buffer, struct tart_csprite sprite, struct tart_vec2 basePosition) { tart_vec2 fpos,
for(int i = 0; i < sprite.size; i++) { tart_vec2 spos) {
struct tart_vec2 position = {sprite.position[i].x + basePosition.x, sprite.position[i].y + basePosition.y};
tart_draw_cell_position(buffer, sprite.data[i], position);
}
return TART_OK; return TART_OK;
} }
int tart_line(tart_window* w, tart_byte p, const t_char* c, tart_vec2 fpos,
tart_byte tart_restore_buffer(struct tart_buffer *buffer) { tart_vec2 spos) {
return TART_OK; return TART_OK;
} }

View File

@@ -1,178 +0,0 @@
#include "term.h"
#include <stdio.h>
char __term_input_buffer__[8] = {' ',' ',' ',' ',' ',' ',' ',' '};
void set_char_push_back(char t) {
char tmp1;
char hold1;
char hold2;
hold1 = __term_input_buffer__[0];
for(int i = 0; i < 8 - 1; i++) {
hold2 = __term_input_buffer__[i+1];
__term_input_buffer__[i+1] = hold1;
hold1 = hold2;
}
__term_input_buffer__[0] = t;
}
// if windows is defined.
#if defined(_WIN64) || defined(_WIN32)
#include <Windows.h>
#include <conio.h>
struct tart_vec2 term_current_size() {
struct tart_vec2 ret;
CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
unsigned int rows = (csbi.srWindow.Right - csbi.srWindow.Left + 1);
unsigned int cols = (csbi.srWindow.Bottom - csbi.srWindow.Top + 1);
unsigned short max_short = 0XFFFF;
if(rows < max_short && cols < max_short) {
ret = (struct tart_vec2){(unsigned short) rows ,(unsigned short) cols};
}
return ret;
}
HANDLE __term_input_thread;
int __term_input_thread_stop;
DWORD WINAPI input_threaded_func(void* data) {
while(__term_input_thread_stop == 1) {
if(_kbhit())
set_char_push_back(_getch());
}
return 0;
}
int term_threaded_input_init() {
__term_input_thread_stop = 1;
__term_input_thread = CreateThread(NULL,0,input_threaded_func,NULL, 0, NULL);
return 0;
}
int term_threaded_input_stop() {
__term_input_thread_stop = 0;
WaitForSingleObject(__term_input_thread, INFINITE);
return 0;
}
#else
#include <sys/ioctl.h>
#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
#include <threads.h>
#include <termios.h>
struct tart_vec2 term_current_size() {
struct tart_vec2 ret;
struct winsize w;
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
unsigned int rows = w.ws_col;
unsigned int cols = w.ws_row;
unsigned short max_short = 0XFFFF;
if(rows < max_short && cols < max_short) {
ret = (struct tart_vec2){(unsigned short) rows ,(unsigned short) cols};
}
return ret;
}
struct termios old, current;
void init_termios(int args) {
tcgetattr(0, &old);
current = old;
current.c_lflag &= ~ICANON;
if(args == 0x01) {
current.c_lflag |= ECHO;
} else {
current.c_lflag &= ~ECHO;
}
tcsetattr(0,TCSAFLUSH, &current);
}
void reset_termios(void) {
tcsetattr(0, TCSAFLUSH, &old);
}
char term_getch() {
char tmp;
init_termios(0x00);
tmp = getchar();
reset_termios();
return tmp;
}
char term_getche() {
char tmp;
init_termios(0x01);
tmp = getchar();
reset_termios();
return tmp;
}
pthread_t input_thread;
void* input_threaded_func(void* vargp) {
int myid = getpid();
while(1) {
set_char_push_back(term_getch());
}
return NULL;
}
int term_threaded_input_stop() {
pthread_cancel(input_thread);
return 1;
}
int term_threaded_input_init() {
pthread_create(&input_thread, NULL, input_threaded_func, NULL);
return 1;
}
#endif
char term_tinputi(int idx){
if(idx < 8) {
return __term_input_buffer__[idx];
}
return 0x0;
}
char* term_tinputb() {
return __term_input_buffer__;
}
char term_tinput() {
return __term_input_buffer__[0];
}
void term_disable_cursor() {
fputs("\033[?25l", stdout);
}
void term_enable_cursor() {
fputs("\033[?25h", stdout);
}

View File

@@ -1,30 +0,0 @@
// #========================================================================#
// | PREACHERDHM:TERM |
// | |
// | term renders all of the data from TART. Term takes a tart_window and |
// | renders all of the buffers and cells inside the that window object. |
// | There is a draw function and a draw buffer function. |
// | |
// | Term is just a way to output the data from tart. |
// #========================================================================#
#ifndef TERM_H
#define TERM_H
#include "tart.h"
struct tart_vec2 term_current_size();
char term_getch();
char term_getche();
// tinput is threaded input
int term_threaded_input_init();
int term_threaded_input_stop();
char term_tinputi(int idx);
char* term_tinputb();
char term_tinput();
void term_disable_cursor();
void term_enable_cursor();
#endif

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;
}

View File

@@ -1,28 +0,0 @@
project(TartTest)
add_subdirectory(externals)
set( CMAKE_CXX_STANDARD 11)
set( CMAKE_CXX_STANDARD_REQUIRED ON)
set( SOURCES
main.cpp
test_tart.cpp
test_term.cpp
)
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin/tests)
add_executable(${PROJECT_NAME} ${SOURCES} )
target_link_libraries(${PROJECT_NAME} TartLib PickleLib)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
add_test(${PROJECT_NAME} "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/testing")
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
add_test(${PROJECT_NAME} "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/testing.exe")
endif()
project(InputTartTest)
set( CMAKE_CXX_STANDARD 11)
set( CMAKE_CXX_STANDARD_REQUIRED ON)
add_executable(${PROJECT_NAME} input.cpp )
target_link_libraries(${PROJECT_NAME} TartLib PickleLib)
add_subdirectory(render_test)

View File

@@ -1 +0,0 @@
---

View File

@@ -1,3 +0,0 @@
Start testing: Jan 28 14:11 Pacific Standard Time (Mexico)
----------------------------------------------------------
End testing: Jan 28 14:11 Pacific Standard Time (Mexico)

View File

@@ -1 +0,0 @@
add_subdirectory(Pickler)

View File

@@ -1,27 +0,0 @@
#include <tart.h>
#include <iostream>
#ifdef _LINUX
#endif
char* bbuf;
int main (int argc, char *argv[]) {
int n;
int counter = 0;
term_disable_cursor();
term_threaded_input_init();
bbuf = term_tinputb();
while(bbuf[0] != 'q') {
std::cout << counter++ << '[';
for (int i = 0; i < 8; i++) {
std::cout << bbuf[i] << ',';
}
std::cout << "] \r";
}
std::cout << '\n';
term_threaded_input_stop();
term_enable_cursor();
exit(0);
return 0;
}

View File

@@ -1,9 +0,0 @@
#include "test_tart.h"
#include "test_term.h"
#include <Pickler.h>
int main (int argc, char *argv[]) {
INSTALLSHELF;
tart_run(&__pickle_shelf__);
term_run(&__pickle_shelf__);
return PICKLESHELF;
}

View File

@@ -1,23 +0,0 @@
#include <tart.h>
#include <memory.h>
#include <stdio.h>
#include <stdlib.h>
int main (int argc, char *argv[]) {
struct tart_window window = tart_create_window();
struct tart_buffer mainbuff = tart_create_buffer(109, {100,50},{20,20});
struct tart_cell* cells = (struct tart_cell*)malloc(mainbuff.cell_count * sizeof(struct tart_cell));
for(int i = 1; i < mainbuff.cell_count; i += 2) {
cells[i] = tart_create_cell('^', TART_STYLE_BLINKING, TART_COLOR_BLACK_FOREGROUND, TART_COLOR_WHITE_BACKGROUND);
}
for(int i = 0; i < + mainbuff.cell_count; i += 2) {
cells[i] = tart_create_cell('^', TART_STYLE_BLINKING, TART_COLOR_RED_FOREGROUND, TART_COLOR_BLACK_BACKGROUND);
}
tart_add_cells_to_buffer(&mainbuff, cells);
char t[1] = {'0'};
tart_add_buffer(&window, mainbuff);
tart_draw_window(&window, t);
return 0;
}

View File

@@ -1,166 +0,0 @@
#include "test_tart.h"
#include "Pickler.h"
bool rgb_test(struct tart_rgb* lhs, struct tart_rgb* rhs) {
if(lhs->r != rhs->r) {return false;}
if(lhs->g != rhs->g) {return false;}
if(lhs->b != rhs->b) {return false;}
return true;
}
bool vec2_test(struct tart_vec2* lhs, struct tart_vec2* rhs) {
if(lhs->x != rhs->x) {return false;}
if(lhs->y != rhs->y) {return false;}
return true;
}
void tart_run(struct pickle_shelf* shelf) {
pickle_shelf __pickle_shelf__ = *shelf;
CREATEJAR(tart_objects_test);
PICKLE(Test_create_buffer) {
struct tart_vec2 size = {25,25};
struct tart_vec2 position = {0,0};
int data_count = (size.x*size.y) * TART_CELL_DATA_SIZE;
unsigned int cell_count = (size.x * size.y);
struct tart_buffer buffer_correct = {cell_count,0,25,size,position,0};
struct tart_buffer buffer_test = tart_create_buffer(25,size,position);
if(DIFFERENT(buffer_correct.cell_count,buffer_test.cell_count))
ASSERT("Cell count not the same.",false);
if(DIFFERENT(buffer_correct.layer,buffer_test.layer))
ASSERT("Layers not the same.",false);
if(DIFFERENT(buffer_correct.id,buffer_test.id))
ASSERT("Ids are not the same.",false);
if(DIFFERENT(buffer_correct.size.x,buffer_test.size.x))
ASSERT("size.x is not the same",false);
if(DIFFERENT(buffer_correct.size.y,buffer_test.size.y))
ASSERT("size.y is not the same",false);
if(DIFFERENT(buffer_correct.position.x,buffer_test.position.x))
ASSERT("position.x is not the same.",false);
if(DIFFERENT(buffer_correct.position.y,buffer_test.position.y))
ASSERT("position.y is not the same.",false);
if(DIFFERENT(buffer_correct.cell_count,buffer_test.cell_count))
ASSERT("data_counts are not the same.",false);
ASSERT("GOOD",true);
}();
PICKLE(Test_create_cell) {
#ifdef TART_RGB_COLOR
struct tart_rgb b = {80,80,80};
struct tart_rgb f = {80,80,80};
struct tart_cell cell_correct = {f, b, '1', 'f'};
struct tart_cell cell_test = tart_create_cell('f', '1', f, b);
if(!rgb_test(&cell_correct.foreground, &cell_test.foreground))
ASSERT("Forground dose not match.",false);
if(!rgb_test(&cell_correct.background, &cell_test.background))
ASSERT("background dose not match.",false);
#else
tart_byte f = 20;
tart_byte b = 40;
struct tart_cell cell_correct = {f, b, '1', 'f'};
struct tart_cell cell_test = tart_create_cell('f', '1', f, b);
if(DIFFERENT(cell_correct.foreground, cell_test.foreground))
ASSERT("Forground dose not match.",false);
if(DIFFERENT(cell_correct.background, cell_test.background))
ASSERT("background dose not match.",false);
#endif
if(DIFFERENT(cell_correct.style, cell_test.style))
ASSERT("style dose not match.",false);
if(DIFFERENT(cell_correct.display, cell_test.display))
ASSERT("display dose not match.",false);
ASSERT("GOOD",true);
}();
PICKLE(Test_create_window) {
struct tart_buffer buffer = tart_create_buffer(10, {10,20}, {0,0});
struct tart_window window = tart_create_window();
for(int i = 0; i < 0xFF + 1; i++) {
if(DIFFERENT(window.buffers[i].id, 0))
ASSERT("buffer not same", false);
}
ASSERT("GOOD", true);
}();
PICKLE(Test_add_buffer) {
struct tart_buffer buffer = tart_create_buffer(10, {10,20}, {0,0});
struct tart_window window = tart_create_window();
tart_add_buffer(&window, buffer);
if(SAME(window.buffer_count, 0))
ASSERT("index has not indexed", false);
if(DIFFERENT(window.buffers[0].id, buffer.id))
ASSERT("buffer not same", false);
ASSERT("GOOD", true);
}();
PICKLE(Test_set_buffer) {
struct tart_buffer buffer = tart_create_buffer(10, {10,20}, {0,0});
struct tart_window window = tart_create_window();
tart_set_buffer(&window, buffer, 0);
if(DIFFERENT(window.buffers[0].id, buffer.id))
ASSERT("buffer not same", false);
ASSERT("GOOD", true);
}();
PICKLE(Test_get_buffer) {
struct tart_buffer buffer = tart_create_buffer(10, {10,20}, {0,0});
struct tart_window window = tart_create_window();
tart_set_buffer(&window, buffer, 0);
if(DIFFERENT(tart_get_buffer(&window, 0)->id, buffer.id))
ASSERT("buffer not same", false);
ASSERT("GOOD", true);
}();
PICKLE(Test_set_cell) {
#ifdef TART_RGB_COLORS
tart_rgb foreground = {90,90,90};
tart_rgb background = {80,80,80};
#else
tart_byte foreground = 9;
tart_byte background = 8;
#endif
struct tart_cell cell = tart_create_cell('0',10,foreground, background);
struct tart_buffer buffer = tart_create_buffer(10, {10,20}, {10,20});
struct tart_window window = tart_create_window();
tart_set_cell(&buffer, cell, 0);
if(DIFFERENT(buffer.cells[0].display, cell.display))
ASSERT("buffer not same", false);
ASSERT("GOOD", true);
}();
PICKLE(Test_get_cell) {
#ifdef TART_RGB_COLORS
tart_rgb foreground = {90,90,90};
tart_rgb background = {80,80,80};
#else
tart_byte foreground = 9;
tart_byte background = 8;
#endif
struct tart_cell cell = tart_create_cell('0',10,foreground, background);
struct tart_buffer buffer = tart_create_buffer(10, {10,20}, {10,20});
struct tart_window window = tart_create_window();
tart_set_cell(&buffer, cell, 0);
if(DIFFERENT(tart_get_cell(&buffer,0)->display, cell.display))
ASSERT("buffer not same", false);
ASSERT("GOOD", true);
}();
ADDPICKLE(tart_objects_test,Test_create_buffer);
ADDPICKLE(tart_objects_test,Test_create_cell);
ADDPICKLE(tart_objects_test,Test_create_buffer);
ADDPICKLE(tart_objects_test,Test_add_buffer);
ADDPICKLE(tart_objects_test,Test_set_buffer);
ADDPICKLE(tart_objects_test,Test_get_buffer);
ADDPICKLE(tart_objects_test,Test_set_cell);
ADDPICKLE(tart_objects_test,Test_get_cell);
PUTJARONSHELF(tart_objects_test);
*shelf = __pickle_shelf__;
}

View File

@@ -1,6 +0,0 @@
#include <tart.h>
#include <Pickler.h>
bool rgb_test(struct tart_rgb* lhs, struct tart_rgb* rhs);
bool vec2_test(struct tart_vec2* lhs, struct tart_vec2* rhs);
void tart_run(struct pickle_shelf* shelf);

View File

@@ -1,48 +0,0 @@
#if defined(_WIN64) || defined(_WIN32)
#include <Windows.h>
#else
#include <sys/ioctl.h>
#include <stdio.h>
#include <unistd.h>
#endif
#include <iostream>
#include "test_term.h"
void term_run(struct pickle_shelf* shelf) {
struct pickle_shelf __pickle_shelf__ = *shelf; //start
CREATEJAR(Test_Term);
PICKLE(Test_get_window_size) {
#if defined(_WIN64) || defined(_WIN32)
CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
int columns = (unsigned int)(csbi.srWindow.Right - csbi.srWindow.Left + 1);
int rows = (unsigned int)(csbi.srWindow.Bottom - csbi.srWindow.Top + 1);
#else
struct winsize w;
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
unsigned int rows = w.ws_row;
unsigned int columns = w.ws_col;
#endif
std::cout << "\n";
std::cout << term_current_size().x << "term_current_size()\n";
std::cout << columns << " columns\n";
if(term_current_size().x != columns)
ASSERT("current_size.x is not the same as columns", false);
if(term_current_size().y != rows)
ASSERT("current_size.y is not the same as rows", false);
ASSERT("GOOD", true);
}();
ADDPICKLE(Test_Term, Test_get_window_size);
PUTJARONSHELF(Test_Term);
*shelf = __pickle_shelf__; // end
}

View File

@@ -1,7 +0,0 @@
#ifndef TEST_TERM_H
#define TEST_TERM_H
#include <tart.h>
#include <Pickler.h>
void term_run(struct pickle_shelf*);
#endif