f***ed up and needed to rework packages
This commit is contained in:
parent
b43ab1702f
commit
f7a87d7519
78 changed files with 3713 additions and 0 deletions
51
packages/console/ncurses/buffer/view.c
Normal file
51
packages/console/ncurses/buffer/view.c
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
#include "arc/console/buffer/view.h"
|
||||
|
||||
#include "arc/console/view.h"
|
||||
#include "arc/math/point.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
struct ARC_ConsoleViewBuffer {
|
||||
ARC_Point bounds;
|
||||
char **buffer;
|
||||
};
|
||||
|
||||
void ARC_ConsoleViewBuffer_Create(ARC_ConsoleViewBuffer **buffer, ARC_ConsoleView *view){
|
||||
*buffer = (ARC_ConsoleViewBuffer *)malloc(sizeof(ARC_ConsoleViewBuffer));
|
||||
|
||||
ARC_Rect viewBounds = ARC_ConsoleView_GetBounds(view);
|
||||
(*buffer)->bounds = (ARC_Point){ viewBounds.w - viewBounds.x, viewBounds.h - viewBounds.y };
|
||||
|
||||
//create the buffer array
|
||||
(*buffer)->buffer = (char **)malloc(sizeof(char *) * (*buffer)->bounds.y);
|
||||
for(int32_t y = 0; y < (*buffer)->bounds.y ; y++){
|
||||
(*buffer)->buffer[y] = (char *)malloc(sizeof(char) * (*buffer)->bounds.x);
|
||||
}
|
||||
|
||||
ARC_ConsoleViewBuffer_Clear(*buffer);
|
||||
}
|
||||
|
||||
void ARC_ConsoleViewBuffer_Destroy(ARC_ConsoleViewBuffer *buffer){
|
||||
for(int32_t y = 0; y < buffer->bounds.y; y++){
|
||||
free(buffer->buffer[y]);
|
||||
}
|
||||
|
||||
free(buffer->buffer);
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
void ARC_ConsoleViewBuffer_Clear(ARC_ConsoleViewBuffer *buffer){
|
||||
for(int32_t y = 0; y < buffer->bounds.y ; y++){
|
||||
for(int32_t x = 0; x < buffer->bounds.x; x++){
|
||||
buffer->buffer[y][x] = ' ';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ARC_ConsoleViewBuffer_Render(ARC_ConsoleViewBuffer *buffer, ARC_ConsoleView *view){
|
||||
for(int32_t y = 0; y < buffer->bounds.y ; y++){
|
||||
for(int32_t x = 0; x < buffer->bounds.x; x++){
|
||||
ARC_ConsoleView_RenderCharAt(view, buffer->buffer[y][x], (ARC_Point){ x, y });
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue