|
|
|
|
@@ -15,14 +15,19 @@ 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, (struct tart_vec2){0,0},(struct tart_vec2){0,0});
|
|
|
|
|
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++) {
|
|
|
|
|
|
|
|
|
|
int dataSize = (window.size.x * window.size.y * sizeof(char) *
|
|
|
|
|
TART_CELL_DATA_SIZE) + 100;
|
|
|
|
|
|
|
|
|
|
window.data = malloc(dataSize);
|
|
|
|
|
for(int g = 0; g < dataSize; g++) {
|
|
|
|
|
window.data[g] = '\0';
|
|
|
|
|
}
|
|
|
|
|
window.data_count = (window.size.x * window.size.y * sizeof(char) * TART_CELL_DATA_SIZE)+ 100;
|
|
|
|
|
window.data_count = dataSize;
|
|
|
|
|
return window;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -33,10 +38,11 @@ tart_byte tart_restore_window(struct tart_window* window) {
|
|
|
|
|
return TART_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct tart_buffer tart_create_buffer(tart_id id, struct tart_vec2 size, struct tart_vec2 position) {
|
|
|
|
|
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));
|
|
|
|
|
struct tart_cell* cells = (struct tart_cell*)malloc(cell_count * sizeof(struct tart_cell));
|
|
|
|
|
|
|
|
|
|
for (int i = 0;i < cell_count;i++) {
|
|
|
|
|
cells[i] = NULL_CELL;
|
|
|
|
|
@@ -59,7 +65,8 @@ struct tart_cell tart_create_cell(char display, tart_byte style,
|
|
|
|
|
return (struct tart_cell){foreground,background,style,display};
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
tart_byte tart_add_buffer(struct tart_window* window, struct tart_buffer buffer) {
|
|
|
|
|
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++;
|
|
|
|
|
@@ -102,11 +109,13 @@ tart_byte tart_draw_window(struct tart_window * window, char* rend_buffer) {
|
|
|
|
|
// add data to window c buffer.
|
|
|
|
|
struct tart_cell cell = window->buffers[b].cells[(y*window->buffers[b].size.x) + x];
|
|
|
|
|
char pre[TART_CELL_DATA_SIZE];
|
|
|
|
|
int size = sprintf(pre, "\033[%d;%d;%dm%c\033[0;0m", (int)cell.style, cell.foreground, cell.background, cell.display) - 1;
|
|
|
|
|
// puts cell drawing data in pre
|
|
|
|
|
int size = sprintf(pre, "\033[%d;%d;%dm%c\033[0;0m",
|
|
|
|
|
(int)cell.style, cell.foreground,
|
|
|
|
|
cell.background, cell.display) -1;
|
|
|
|
|
for(int preIdx = 0; preIdx < size; preIdx++) {
|
|
|
|
|
window->data[(y * bufferWidth) + x + offset] = pre[preIdx];
|
|
|
|
|
window->data[(y*window->buffers[b].size.x) + x + offset] = pre[preIdx];
|
|
|
|
|
offset++;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//window->data[((y)*window->buffers[b].size.x) + offset + window->buffers[b].size.x] = '\n';
|
|
|
|
|
|