added tart main tools
This commit is contained in:
@@ -1,13 +1,23 @@
|
||||
#include "../includes/tart.h"
|
||||
#include <malloc.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
struct tart_cell tart_test() {
|
||||
return (struct tart_cell){{0,0,0}, {0,0,0}, 0, 't'};
|
||||
}
|
||||
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});
|
||||
}
|
||||
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(sizeof(struct tart_cell[cell_count]));
|
||||
struct tart_buffer buf = {cell_count,0,id,size,position,0};
|
||||
struct tart_cell* cells = (struct tart_cell*)malloc((size.x * size.y) * sizeof(struct tart_cell));
|
||||
tart_cell cell = NULL_CELL;
|
||||
struct tart_buffer buf = {cell_count,0,id,size,position,cells}; // -NOTE- dose not set the layer
|
||||
return buf;
|
||||
}
|
||||
struct tart_cell tart_create_cell(char display, tart_byte style, struct tart_rgb foreground, struct tart_rgb background) {
|
||||
@@ -15,12 +25,9 @@ struct tart_cell tart_create_cell(char display, tart_byte style, struct tart_rgb
|
||||
return b;
|
||||
}
|
||||
tart_byte tart_add_buffer(struct tart_window* window, struct tart_buffer buffer) {
|
||||
if(window->buffer_count < 0xFF) {
|
||||
window->buffers[window->buffer_count] = buffer;
|
||||
window->buffer_count++;
|
||||
return window->buffer_count;
|
||||
}
|
||||
return 0;
|
||||
window->buffers[window->buffer_count] = buffer;
|
||||
window->buffer_count++;
|
||||
return window->buffer_count;
|
||||
}
|
||||
tart_byte tart_set_buffer(struct tart_window* window, struct tart_buffer buffer, tart_byte layer) {
|
||||
if(layer <= 0xFF) {
|
||||
@@ -37,10 +44,8 @@ struct tart_buffer* tart_get_buffer(struct tart_window* window, tart_byte layer)
|
||||
struct tart_cell* tart_get_cell(struct tart_buffer* buffer, int idx) {
|
||||
return &buffer->cells[idx];
|
||||
}
|
||||
struct tart_cell* tart_set_cell(struct tart_buffer* buffer, struct tart_cell* cell,int idx) {
|
||||
if(buffer->cell_count >= idx) {
|
||||
buffer->cells[idx] = *cell;
|
||||
return cell;
|
||||
}
|
||||
return 0;
|
||||
|
||||
struct tart_cell tart_set_cell(struct tart_buffer* buffer, struct tart_cell cell,int idx) {
|
||||
buffer->cells[idx] = cell;
|
||||
return NULL_CELL;
|
||||
}
|
||||
|
||||
0
source/term.cpp
Normal file
0
source/term.cpp
Normal file
8
source/term.h
Normal file
8
source/term.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#ifndef TERM_H
|
||||
#define TERM_H
|
||||
#include "tart.h"
|
||||
|
||||
int tart_draw(struct tart_window);
|
||||
int tart_draw_buffer(struct tart_buffer);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user