testing on linux
This commit is contained in:
@@ -14,13 +14,13 @@
|
||||
// | over each cell.
|
||||
// #========================================================================#
|
||||
|
||||
#define NULL_CELL (struct tart_cell){{0,0,0},{0,0,0},0,0}
|
||||
#define NULL_CELL 0
|
||||
|
||||
typedef unsigned char tart_byte;
|
||||
typedef unsigned short tart_id;
|
||||
|
||||
struct tart_vec2 {
|
||||
short x,y;
|
||||
unsigned short x,y;
|
||||
};
|
||||
|
||||
struct tart_rgb {
|
||||
@@ -72,6 +72,7 @@ struct tart_buffer {
|
||||
struct tart_window {
|
||||
struct tart_buffer buffers[0xFF+1];
|
||||
tart_byte buffer_count;
|
||||
struct tart_vec2 size;
|
||||
};
|
||||
|
||||
struct tart_window tart_create_window();
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
project(TartLib VERSION 0.1)
|
||||
set( CMAKE_STATIC_LIBRARY_PREFIX "")
|
||||
set( CMAKE_CXX_STANDARD 11)
|
||||
set( CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
set(Lib_SOURCES
|
||||
tart.cpp
|
||||
set(LIB_SOURCES
|
||||
term.c
|
||||
term.h
|
||||
tart.c
|
||||
)
|
||||
|
||||
add_library(${PROJECT_NAME} STATIC tart.cpp)
|
||||
add_library(${PROJECT_NAME} STATIC ${LIB_SOURCES})
|
||||
target_include_directories(${PROJECT_NAME} BEFORE PUBLIC "../includes/")
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "../includes/tart.h"
|
||||
#include <stdlib.h>
|
||||
#include "term.h"
|
||||
|
||||
struct tart_cell tart_test() {
|
||||
return (struct tart_cell){{0,0,0}, {0,0,0}, 0, 't'};
|
||||
@@ -8,15 +9,16 @@ struct tart_window tart_create_window() {
|
||||
struct tart_window window;
|
||||
window.buffer_count = 0;
|
||||
for(int i = 0; i < 0xFF; i++) {
|
||||
window.buffers[i] = tart_create_buffer(0, {0,0}, {0,0});
|
||||
window.buffers[i] = tart_create_buffer(0, (struct tart_vec2){0,0},(struct tart_vec2){0,0});
|
||||
}
|
||||
window.size = term_current_size();
|
||||
return window;
|
||||
}
|
||||
|
||||
struct tart_buffer tart_create_buffer(tart_id id, struct tart_vec2 size, struct tart_vec2 position) {
|
||||
unsigned int cell_count = position.x * position.y;
|
||||
struct tart_cell* cells = (struct tart_cell*)malloc((size.x * size.y) * sizeof(struct tart_cell));
|
||||
tart_cell cell = NULL_CELL;
|
||||
struct tart_cell cell = {.foreground = {0,0,0}, .background = {10,0,0}, .style = 0x0, .display = 0x0};
|
||||
struct tart_buffer buf = {cell_count,0,id,size,position,cells}; // -NOTE- dose not set the layer
|
||||
return buf;
|
||||
}
|
||||
@@ -46,6 +48,7 @@ struct tart_cell* tart_get_cell(struct tart_buffer* buffer, int idx) {
|
||||
}
|
||||
|
||||
struct tart_cell tart_set_cell(struct tart_buffer* buffer, struct tart_cell cell,int idx) {
|
||||
struct tart_cell c = buffer->cells[idx];
|
||||
buffer->cells[idx] = cell;
|
||||
return NULL_CELL;
|
||||
return c;
|
||||
}
|
||||
21
source/term.c
Normal file
21
source/term.c
Normal file
@@ -0,0 +1,21 @@
|
||||
#include "term.h"
|
||||
#include "../includes/tart.h"
|
||||
|
||||
|
||||
// windows only
|
||||
#include <Windows.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;
|
||||
}
|
||||
@@ -1,8 +1,16 @@
|
||||
// #========================================================================#
|
||||
// | 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"
|
||||
|
||||
int tart_draw(struct tart_window);
|
||||
int tart_draw_buffer(struct tart_buffer);
|
||||
struct tart_vec2 term_current_size();
|
||||
|
||||
#endif
|
||||
|
||||
@@ -5,7 +5,8 @@ set( SOURCES
|
||||
main.cpp
|
||||
test_tart.cpp
|
||||
)
|
||||
|
||||
add_executable(${PROJECT_NAME} ${SOURCES} )
|
||||
target_link_libraries(${PROJECT_NAME} PickleLib TartLib)
|
||||
target_link_libraries(${PROJECT_NAME} TartLib PickleLib)
|
||||
|
||||
add_test(${PROJECT_NAME} "${CMAKE_SOURCE_DIR}/bin/testing.exe")
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include <tart.h>
|
||||
#include "../includes/tart.h"
|
||||
#include <Pickler.h>
|
||||
|
||||
bool rgb_test(struct tart_rgb* lhs, struct tart_rgb* rhs);
|
||||
|
||||
Reference in New Issue
Block a user