testing on linux

This commit is contained in:
2025-01-29 10:51:20 -08:00
parent 569ea396c0
commit 58d3ec9e71
8 changed files with 50 additions and 12 deletions

View File

@@ -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/")

View File

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

View File

View File

@@ -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