Compare commits
16 Commits
9f46853d5d
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| ee10de863d | |||
| 3d755bd9a7 | |||
| 0abe4974df | |||
| fcfd5131ec | |||
| 2992e41050 | |||
| 9d1468fbf7 | |||
| fb4b61420a | |||
| 737458f802 | |||
| 0a8c4eed82 | |||
| b2839b4cd1 | |||
| 8cef088b61 | |||
| b6a50cf942 | |||
| a942782e47 | |||
| a77df22ffe | |||
| 993330a3a4 | |||
| d1dadebe4a |
6
.gitmodules
vendored
6
.gitmodules
vendored
@@ -1,6 +0,0 @@
|
|||||||
[submodule "externals/Pickler"]
|
|
||||||
path = externals/Pickler
|
|
||||||
url = http://www.gitea.preacherdhm.com/PreacherDHM/Pickler.git
|
|
||||||
[submodule "testing/externals/Pickler"]
|
|
||||||
path = testing/externals/Pickler
|
|
||||||
url = http://www.gitea.preacherdhm.com/PreacherDHM/Pickler.git
|
|
||||||
@@ -24,5 +24,4 @@ enable_testing()
|
|||||||
add_subdirectory(externals)
|
add_subdirectory(externals)
|
||||||
# PROJECT
|
# PROJECT
|
||||||
add_subdirectory(source)
|
add_subdirectory(source)
|
||||||
add_subdirectory(testing)
|
|
||||||
|
|
||||||
|
|||||||
28
examples/CMakeLists.txt
Normal file
28
examples/CMakeLists.txt
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
project(TartTest)
|
||||||
|
#add_subdirectory(externals)
|
||||||
|
set( CMAKE_CXX_STANDARD 11)
|
||||||
|
set( CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
set( SOURCES
|
||||||
|
main.cpp
|
||||||
|
test_tart.cpp
|
||||||
|
test_term.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
#set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin/tests)
|
||||||
|
#
|
||||||
|
#add_executable(${PROJECT_NAME} ${SOURCES} )
|
||||||
|
#target_link_libraries(${PROJECT_NAME} TartLib PickleLib)
|
||||||
|
#
|
||||||
|
#if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||||
|
# add_test(${PROJECT_NAME} "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/testing")
|
||||||
|
#endif()
|
||||||
|
#if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||||
|
# add_test(${PROJECT_NAME} "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/testing.exe")
|
||||||
|
#endif()
|
||||||
|
#
|
||||||
|
#project(InputTartTest)
|
||||||
|
#set( CMAKE_CXX_STANDARD 11)
|
||||||
|
#set( CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
#add_executable(${PROJECT_NAME} input.cpp )
|
||||||
|
#target_link_libraries(${PROJECT_NAME} TartLib PickleLib)
|
||||||
|
add_subdirectory(render_test)
|
||||||
81
examples/render_test/main.cpp
Normal file
81
examples/render_test/main.cpp
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
#include <tart.h>
|
||||||
|
#include <memory.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
//int main (int argc, char *argv[]) {
|
||||||
|
// struct tart_window window = tart_create_window();
|
||||||
|
// struct tart_buffer mainbuff = tart_create_buffer(109, {40,20},{20,20});
|
||||||
|
// struct tart_cell* cells = (struct tart_cell*)malloc(mainbuff.cell_count * sizeof(struct tart_cell));
|
||||||
|
// for(int i = 1; i < mainbuff.cell_count; i += 2) {
|
||||||
|
// cells[i] = tart_create_cell('^', TART_STYLE_BLINKING, TART_COLOR_BLACK_FOREGROUND, TART_COLOR_WHITE_BACKGROUND);
|
||||||
|
// }
|
||||||
|
// for(int i = 0; i < + mainbuff.cell_count; i += 2) {
|
||||||
|
// cells[i] = tart_create_cell('^', TART_STYLE_BLINKING, TART_COLOR_RED_FOREGROUND, TART_COLOR_BLACK_BACKGROUND);
|
||||||
|
// }
|
||||||
|
// tart_add_cells_to_buffer(&mainbuff, cells);
|
||||||
|
//
|
||||||
|
// struct tart_vec2 positions[4] = {{0,0},{0,1},{1,0},{1,1}};
|
||||||
|
// struct tart_cell cell = tart_create_cell('0', TART_STYLE_BLINKING, TART_COLOR_RED_FOREGROUND, TART_COLOR_GREEN_BACKGROUND);
|
||||||
|
// struct tart_cell cellss[4] = {cell,cell,cell,cell};
|
||||||
|
//
|
||||||
|
// struct tart_csprite sprite = tart_csprite(cellss,positions,4);
|
||||||
|
// tart_draw_csprite_position(&mainbuff, sprite, {2,2});
|
||||||
|
// tart_draw_csprite_position(&mainbuff, sprite, {5,2});
|
||||||
|
// tart_draw_csprite_position(&mainbuff, sprite, {5,5});
|
||||||
|
// tart_draw_csprite_position(&mainbuff, sprite, {39,18});
|
||||||
|
//
|
||||||
|
// float x = 0;
|
||||||
|
// tart_byte layer = tart_add_buffer(&window, mainbuff);
|
||||||
|
// char t[1] = {'0'};
|
||||||
|
// struct tart_vec2 p = {0,0};
|
||||||
|
//
|
||||||
|
// term_disable_cursor();
|
||||||
|
// term_threaded_input_init();
|
||||||
|
// char* bbuf = term_tinputb();
|
||||||
|
// for(;;) {
|
||||||
|
// printf("\033[H");
|
||||||
|
// struct tart_buffer* buf = tart_get_buffer(&window, 0);
|
||||||
|
// tart_draw_csprite_position(buf, sprite, {3,18});
|
||||||
|
// tart_draw_csprite_position(buf, sprite, p);
|
||||||
|
// tart_draw_window(&window, t);
|
||||||
|
// tart_restore_window(&window);
|
||||||
|
// tart_restore_buffer(buf);
|
||||||
|
// if(term_tinput() == 's') {
|
||||||
|
// x += 0.01;
|
||||||
|
// }
|
||||||
|
// if(term_tinput() == 'q') {
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// // p.x = (int)x;
|
||||||
|
// }
|
||||||
|
// term_threaded_input_stop();
|
||||||
|
// term_enable_cursor();
|
||||||
|
// exit(0);
|
||||||
|
// //term_getche();
|
||||||
|
// //term_threaded_input_stop();
|
||||||
|
// return 0;
|
||||||
|
//}
|
||||||
|
char* bbuf;
|
||||||
|
|
||||||
|
int main (int argc, char *argv[]) {
|
||||||
|
int n;
|
||||||
|
int counter = 0;
|
||||||
|
term_disable_cursor();
|
||||||
|
term_threaded_input_init();
|
||||||
|
bbuf = term_tinputb();
|
||||||
|
while(bbuf[0] != 'q') {
|
||||||
|
|
||||||
|
std::cout << counter++ << '[';
|
||||||
|
for (int i = 0; i < 8; i++) {
|
||||||
|
std::cout << bbuf[i] << ',';
|
||||||
|
}
|
||||||
|
std::cout << "] \r";
|
||||||
|
}
|
||||||
|
std::cout << '\n';
|
||||||
|
term_threaded_input_stop();
|
||||||
|
term_enable_cursor();
|
||||||
|
exit(0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "../source/term.h"
|
#include "../source/term.h"
|
||||||
|
#include <stdio.h>
|
||||||
// #========================================================================#
|
// #========================================================================#
|
||||||
// | PreacherDHM:TART
|
// | PreacherDHM:TART
|
||||||
// |
|
// |
|
||||||
@@ -22,16 +23,19 @@ extern "C" {
|
|||||||
|
|
||||||
#ifdef TART_RGB_COLORS
|
#ifdef TART_RGB_COLORS
|
||||||
#define NULL_CELL (struct tart_cell){{0,0,0},{0,0,0},0,0,0}
|
#define NULL_CELL (struct tart_cell){{0,0,0},{0,0,0},0,0,0}
|
||||||
#define TART_CELL_DATA_SIZE 16 // todo add number
|
#define TART_CELL_DATA_SIZE 32 // todo add number
|
||||||
|
typedef char tart_display[2];
|
||||||
#else
|
#else
|
||||||
#define NULL_CELL (struct tart_cell){0,0,0,0}
|
#define NULL_CELL (struct tart_cell){0,0,0,' '}
|
||||||
#define TART_CELL_DATA_SIZE 20
|
#define TART_CELL_DATA_SIZE 20
|
||||||
|
typedef char tart_display;
|
||||||
#endif
|
#endif
|
||||||
#define TART_OK 0
|
#define TART_OK 0
|
||||||
|
|
||||||
|
|
||||||
#define TART_STYLE_BOLD 1
|
#define TART_STYLE_BOLD 1
|
||||||
#define TART_STYLE_DIM 2
|
#define TART_STYLE_DIM 2
|
||||||
|
#define TART_STYLE_ITALIC 3
|
||||||
#define TART_STYLE_UNDERLINE 4
|
#define TART_STYLE_UNDERLINE 4
|
||||||
#define TART_STYLE_BLINKING 5
|
#define TART_STYLE_BLINKING 5
|
||||||
#define TART_STYLE_INVERSE 7
|
#define TART_STYLE_INVERSE 7
|
||||||
@@ -101,11 +105,20 @@ struct tart_cell {
|
|||||||
char display;
|
char display;
|
||||||
};
|
};
|
||||||
#else
|
#else
|
||||||
|
#ifdef TART_UTF8
|
||||||
|
struct tart_cell {
|
||||||
|
tart_byte foreground;
|
||||||
|
tart_byte background;
|
||||||
|
tart_byte style;
|
||||||
|
char[2] display;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
struct tart_cell {
|
struct tart_cell {
|
||||||
tart_byte foreground;
|
tart_byte foreground;
|
||||||
tart_byte background;
|
tart_byte background;
|
||||||
tart_byte style;
|
tart_byte style;
|
||||||
char display;
|
char display;
|
||||||
|
struct tart_vec2 screen_pos;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -143,6 +156,7 @@ struct tart_buffer {
|
|||||||
struct tart_vec2 size;
|
struct tart_vec2 size;
|
||||||
struct tart_vec2 position;
|
struct tart_vec2 position;
|
||||||
struct tart_cell* cells;
|
struct tart_cell* cells;
|
||||||
|
unsigned int current_idx;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Tart Window
|
/* Tart Window
|
||||||
@@ -158,7 +172,9 @@ struct tart_window {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct tart_window tart_create_window();
|
struct tart_window tart_create_window();
|
||||||
|
void tart_destroy_window(struct tart_window* window);
|
||||||
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);
|
||||||
|
tart_byte tart_restore_window(struct tart_window*);
|
||||||
|
|
||||||
#ifdef TART_RGB_COLORS
|
#ifdef TART_RGB_COLORS
|
||||||
struct tart_cell tart_create_cell(char display, tart_byte style, struct tart_rgb foreground, struct tart_rgb background);
|
struct tart_cell tart_create_cell(char display, tart_byte style, struct tart_rgb foreground, struct tart_rgb background);
|
||||||
@@ -166,8 +182,22 @@ struct tart_cell tart_create_cell(char display, tart_byte style, struct tart_rgb
|
|||||||
struct tart_cell tart_create_cell(char display, tart_byte style, tart_byte foreground, tart_byte background);
|
struct tart_cell tart_create_cell(char display, tart_byte style, tart_byte foreground, tart_byte background);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* tart_add_buffer
|
||||||
|
*
|
||||||
|
* This adds a buffer to the window.
|
||||||
|
*
|
||||||
|
* tart_byte tart_add_buffer(struct tart_window*, struct struct tart_buffer*)
|
||||||
|
*/
|
||||||
tart_byte tart_add_buffer(struct tart_window*, struct tart_buffer);
|
tart_byte tart_add_buffer(struct tart_window*, struct tart_buffer);
|
||||||
|
/* tart_remove_buffer
|
||||||
|
*
|
||||||
|
* This will remove the buffer using the *tart_id*.
|
||||||
|
*/
|
||||||
tart_byte tart_remove_buffer(struct tart_window*, tart_id);
|
tart_byte tart_remove_buffer(struct tart_window*, tart_id);
|
||||||
|
/* tart_set_buffer
|
||||||
|
*
|
||||||
|
* This will replace the the buffer at the index *(tart_byte)*.
|
||||||
|
*/
|
||||||
tart_byte tart_set_buffer(struct tart_window*, struct tart_buffer, tart_byte);
|
tart_byte tart_set_buffer(struct tart_window*, struct tart_buffer, tart_byte);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -15,21 +15,39 @@ struct tart_window tart_create_window() {
|
|||||||
struct tart_window window;
|
struct tart_window window;
|
||||||
window.buffer_count = 0;
|
window.buffer_count = 0;
|
||||||
for(int i = 0; i < 0xFF; i++) {
|
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.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[g] = '\0';
|
||||||
}
|
}
|
||||||
window.data_count = (window.size.x * window.size.y * sizeof(char) * TART_CELL_DATA_SIZE)+ 100;
|
window.data_count = dataSize;
|
||||||
|
printf("\033[?1049h");
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tart_buffer tart_create_buffer(tart_id id, struct tart_vec2 size, struct tart_vec2 position) {
|
void tart_destroy_window(struct tart_window* winodw) {
|
||||||
|
printf("\033[?1049l");
|
||||||
|
}
|
||||||
|
|
||||||
|
tart_byte tart_restore_window(struct tart_window* window) {
|
||||||
|
for (int i = 0; i < window->data_count; i++) {
|
||||||
|
window->data[i] = '\0';
|
||||||
|
}
|
||||||
|
return TART_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
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++) {
|
for (int i = 0;i < cell_count;i++) {
|
||||||
cells[i] = NULL_CELL;
|
cells[i] = NULL_CELL;
|
||||||
@@ -37,6 +55,7 @@ struct tart_buffer tart_create_buffer(tart_id id, struct tart_vec2 size, struct
|
|||||||
|
|
||||||
unsigned int data_count = (size.x*size.y) * TART_CELL_DATA_SIZE;
|
unsigned int data_count = (size.x*size.y) * TART_CELL_DATA_SIZE;
|
||||||
struct tart_buffer buf = {cell_count,0,id,size,position,cells}; // -NOTE- dose not set the layer
|
struct tart_buffer buf = {cell_count,0,id,size,position,cells}; // -NOTE- dose not set the layer
|
||||||
|
buf.cell_count = cell_count;
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
#ifdef TART_RGB_COLORS
|
#ifdef TART_RGB_COLORS
|
||||||
@@ -51,7 +70,8 @@ struct tart_cell tart_create_cell(char display, tart_byte style,
|
|||||||
return (struct tart_cell){foreground,background,style,display};
|
return (struct tart_cell){foreground,background,style,display};
|
||||||
}
|
}
|
||||||
#endif
|
#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) {
|
if(window->buffer_count <= 0xFF) {
|
||||||
window->buffers[window->buffer_count] = buffer;
|
window->buffers[window->buffer_count] = buffer;
|
||||||
window->buffer_count++;
|
window->buffer_count++;
|
||||||
@@ -84,22 +104,45 @@ struct tart_cell tart_set_cell(struct tart_buffer* buffer, struct tart_cell cell
|
|||||||
tart_byte tart_draw_window(struct tart_window * window, char* rend_buffer) {
|
tart_byte tart_draw_window(struct tart_window * window, char* rend_buffer) {
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
int bufferWidth = 0;
|
||||||
for (int b = 0;b < 0xFF; b++) {
|
for (int b = 0;b < 0xFF; b++) {
|
||||||
if(window->buffers[b].cell_count == 0)
|
if(window->buffers[b].cell_count == 0)
|
||||||
continue;
|
continue;
|
||||||
for (int y = 0; y < window->buffers[b].size.y; y++) {
|
//char bufferSetPre[16];
|
||||||
for (int x = 0; x < window->buffers[b].size.x; x++) {
|
//int bufferSetSize = sprintf(bufferSetPre, "\033[%d;%dH", window->buffers[b].position.y, window->buffers[b].position.x);
|
||||||
// add data to window c buffer.
|
//for(int preIdx = 0; preIdx < bufferSetSize; preIdx++) {
|
||||||
struct tart_cell cell = window->buffers[b].cells[(y*window->buffers[b].size.x) + x];
|
// //window->data[(y*window->buffers[b].size.x) + offset] = movePre[preIdx];
|
||||||
char pre[TART_CELL_DATA_SIZE];
|
// window->data[offset] = bufferSetPre[preIdx];
|
||||||
int size = sprintf(pre, "\033[%d;%d;%dm%c\033[0;0m", (int)cell.style, cell.foreground, cell.background, cell.display);
|
// offset++;
|
||||||
for(int preIdx = 0; preIdx < size; preIdx++) {
|
//}
|
||||||
window->data[(y*window->buffers[b].size.x) + x + offset] = pre[preIdx];
|
// offset++;
|
||||||
offset++;
|
//bufferWidth = window->buffers[b].size.x;
|
||||||
|
for (int y = 0; y < window->buffers[b].current_idx; y++) {
|
||||||
|
// add data to window c buffer.
|
||||||
|
struct tart_cell cell = window->buffers[b].cells[y];
|
||||||
|
// puts cell drawing data in pre
|
||||||
|
|
||||||
}
|
|
||||||
|
char pre[TART_CELL_DATA_SIZE+20];
|
||||||
|
int size = sprintf(pre, "\033[%d;%dH\033[0m\033[%d;%d;%dm%c\033[0;0m",
|
||||||
|
cell.screen_pos.y+1,cell.screen_pos.x+1,
|
||||||
|
(int)cell.style, cell.foreground,
|
||||||
|
cell.background, cell.display) -1;
|
||||||
|
for(int preIdx = 0; preIdx < size; preIdx++) {
|
||||||
|
window->data[offset] = pre[preIdx];
|
||||||
|
offset++;
|
||||||
}
|
}
|
||||||
window->data[((y)*window->buffers[b].size.x) + offset + window->buffers[b].size.x] = '\n';
|
#ifdef TART_RGB_COLORS
|
||||||
|
char pre[TART_CELL_DATA_SIZE+4];
|
||||||
|
int size = sprintf(pre, "\033[0m\033[38;2;%d;%d;%dm\033[0m\033[48;2;%d;%d;%dm%\033[%dmc\033[0;0m",
|
||||||
|
// TODO add rgb
|
||||||
|
(int)cell.style, cell.foreground,
|
||||||
|
cell.background, cell.display) -1;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
offset++;
|
offset++;
|
||||||
|
|
||||||
|
|
||||||
@@ -123,6 +166,10 @@ tart_byte tart_add_cells_to_buffer(struct tart_buffer* buffer, struct tart_cell*
|
|||||||
struct tart_cstring tart_cstring(char *string, long size, struct tart_cell type){
|
struct tart_cstring tart_cstring(char *string, long size, struct tart_cell type){
|
||||||
struct tart_cstring str = {0,size};
|
struct tart_cstring str = {0,size};
|
||||||
str.data = malloc(size * sizeof(struct tart_cell));
|
str.data = malloc(size * sizeof(struct tart_cell));
|
||||||
|
for(int i = 0; i < size; i++) {
|
||||||
|
str.data[i] = type;
|
||||||
|
str.data[i].display = string[i];
|
||||||
|
}
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,6 +207,7 @@ struct tart_csprite tart_csprite(struct tart_cell* cells, struct tart_vec2* posi
|
|||||||
sprite.bounds.y = positions[i].y;
|
sprite.bounds.y = positions[i].y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
sprite.size = size;
|
||||||
return sprite;
|
return sprite;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -173,8 +221,10 @@ tart_byte tart_csprite_free(struct tart_csprite* sprite) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tart_byte tart_draw_cell_position(struct tart_buffer * buffer, struct tart_cell cell, struct tart_vec2 position) {
|
tart_byte tart_draw_cell_position(struct tart_buffer * buffer, struct tart_cell cell, struct tart_vec2 position) {
|
||||||
if(buffer->size.y >= position.y && buffer->size.x >= position.x) {
|
if(buffer->size.x > position.x && buffer->size.y > position.y) {
|
||||||
buffer->cells[(buffer->size.x * position.y) + position.x] = cell;
|
cell.screen_pos = position;
|
||||||
|
buffer->cells[buffer->current_idx] = cell;
|
||||||
|
buffer->current_idx++;
|
||||||
}
|
}
|
||||||
return TART_OK;
|
return TART_OK;
|
||||||
}
|
}
|
||||||
@@ -190,12 +240,16 @@ tart_byte tart_draw_cstring_position(struct tart_buffer *buffer, struct tart_cst
|
|||||||
|
|
||||||
tart_byte tart_draw_csprite_position(struct tart_buffer * buffer, struct tart_csprite sprite, struct tart_vec2 basePosition) {
|
tart_byte tart_draw_csprite_position(struct tart_buffer * buffer, struct tart_csprite sprite, struct tart_vec2 basePosition) {
|
||||||
for(int i = 0; i < sprite.size; i++) {
|
for(int i = 0; i < sprite.size; i++) {
|
||||||
struct tart_vec2 position = {sprite.position[i].x + basePosition.x, sprite.position[i].y + basePosition.y};
|
struct tart_vec2 position = {sprite.position[i].x + basePosition.x, sprite.position[i].y + basePosition.y};
|
||||||
tart_draw_cell_position(buffer, sprite.data[i], position);
|
tart_draw_cell_position(buffer, sprite.data[i], position);
|
||||||
}
|
}
|
||||||
return TART_OK;
|
return TART_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
tart_byte tart_restore_buffer(struct tart_buffer *buffer) {
|
tart_byte tart_restore_buffer(struct tart_buffer *buffer) {
|
||||||
|
for (int i = 0; i < buffer->cell_count; i++) {
|
||||||
|
buffer->cells[i] = NULL_CELL;
|
||||||
|
buffer->current_idx = 0;
|
||||||
|
}
|
||||||
return TART_OK;
|
return TART_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
#include "term.h"
|
#include "term.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
unsigned char haveread = 0;
|
||||||
|
unsigned char __state__ = 0;
|
||||||
char __term_input_buffer__[8] = {' ',' ',' ',' ',' ',' ',' ',' '};
|
char __term_input_buffer__[8] = {' ',' ',' ',' ',' ',' ',' ',' '};
|
||||||
void set_char_push_back(char t) {
|
void set_char_push_back(char t) {
|
||||||
char tmp1;
|
char tmp1;
|
||||||
char hold1;
|
char hold1;
|
||||||
char hold2;
|
char hold2;
|
||||||
|
__state__ = __state__ + 1;
|
||||||
hold1 = __term_input_buffer__[0];
|
hold1 = __term_input_buffer__[0];
|
||||||
for(int i = 0; i < 8 - 1; i++) {
|
for(int i = 0; i < 8 - 1; i++) {
|
||||||
hold2 = __term_input_buffer__[i+1];
|
hold2 = __term_input_buffer__[i+1];
|
||||||
@@ -101,16 +104,19 @@ void init_termios(int args) {
|
|||||||
current.c_lflag &= ~ICANON;
|
current.c_lflag &= ~ICANON;
|
||||||
|
|
||||||
if(args == 0x01) {
|
if(args == 0x01) {
|
||||||
current.c_lflag |= ECHO;
|
//current.c_lflag ^ ECHO;
|
||||||
} else {
|
} else {
|
||||||
current.c_lflag &= ~ECHO;
|
//current.c_lflag &= ~ECHO;
|
||||||
|
current.c_lflag ^= ECHO;
|
||||||
|
//current.c_lflag |= ECHO;
|
||||||
}
|
}
|
||||||
|
|
||||||
tcsetattr(0,TCSAFLUSH, ¤t);
|
tcsetattr(0,0, ¤t);
|
||||||
}
|
}
|
||||||
|
|
||||||
void reset_termios(void) {
|
void reset_termios(void) {
|
||||||
tcsetattr(0, TCSAFLUSH, &old);
|
|
||||||
|
tcsetattr(0, TCSANOW, &old);
|
||||||
}
|
}
|
||||||
|
|
||||||
char term_getch() {
|
char term_getch() {
|
||||||
@@ -137,12 +143,14 @@ void* input_threaded_func(void* vargp) {
|
|||||||
int myid = getpid();
|
int myid = getpid();
|
||||||
while(1) {
|
while(1) {
|
||||||
set_char_push_back(term_getch());
|
set_char_push_back(term_getch());
|
||||||
|
usleep(1000);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int term_threaded_input_stop() {
|
int term_threaded_input_stop() {
|
||||||
pthread_cancel(input_thread);
|
pthread_cancel(input_thread);
|
||||||
|
reset_termios();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,6 +160,28 @@ int term_threaded_input_init() {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned char term_key_pressed() {
|
||||||
|
if( __state__ > 0 ) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void term_handled_key() {
|
||||||
|
if( __state__ > 0 ) {
|
||||||
|
__state__ = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void term_end_of_key() {
|
||||||
|
if(__state__ > 0 && haveread > 200) {
|
||||||
|
//__state__ = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void term_start_read() {
|
||||||
|
haveread += 1;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -170,9 +200,9 @@ char term_tinput() {
|
|||||||
return __term_input_buffer__[0];
|
return __term_input_buffer__[0];
|
||||||
}
|
}
|
||||||
void term_disable_cursor() {
|
void term_disable_cursor() {
|
||||||
fputs("\033[?25l", stdout);
|
printf("\033[?25l", stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
void term_enable_cursor() {
|
void term_enable_cursor() {
|
||||||
fputs("\033[?25h", stdout);
|
printf("\033[?25h", stdout);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,9 @@
|
|||||||
// #========================================================================#
|
// #========================================================================#
|
||||||
#ifndef TERM_H
|
#ifndef TERM_H
|
||||||
#define TERM_H
|
#define TERM_H
|
||||||
|
|
||||||
|
#define NOREAD 0
|
||||||
|
|
||||||
#include "tart.h"
|
#include "tart.h"
|
||||||
|
|
||||||
struct tart_vec2 term_current_size();
|
struct tart_vec2 term_current_size();
|
||||||
@@ -23,6 +26,10 @@ int term_threaded_input_stop();
|
|||||||
char term_tinputi(int idx);
|
char term_tinputi(int idx);
|
||||||
char* term_tinputb();
|
char* term_tinputb();
|
||||||
char term_tinput();
|
char term_tinput();
|
||||||
|
unsigned char term_key_pressed();
|
||||||
|
void term_handled_key();
|
||||||
|
void term_end_of_key();
|
||||||
|
void term_start_read();
|
||||||
|
|
||||||
void term_disable_cursor();
|
void term_disable_cursor();
|
||||||
void term_enable_cursor();
|
void term_enable_cursor();
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
project(TartTest)
|
|
||||||
add_subdirectory(externals)
|
|
||||||
set( CMAKE_CXX_STANDARD 11)
|
|
||||||
set( CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
||||||
set( SOURCES
|
|
||||||
main.cpp
|
|
||||||
test_tart.cpp
|
|
||||||
test_term.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin/tests)
|
|
||||||
|
|
||||||
add_executable(${PROJECT_NAME} ${SOURCES} )
|
|
||||||
target_link_libraries(${PROJECT_NAME} TartLib PickleLib)
|
|
||||||
|
|
||||||
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
|
||||||
add_test(${PROJECT_NAME} "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/testing")
|
|
||||||
endif()
|
|
||||||
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
|
||||||
add_test(${PROJECT_NAME} "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/testing.exe")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
project(InputTartTest)
|
|
||||||
set( CMAKE_CXX_STANDARD 11)
|
|
||||||
set( CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
||||||
add_executable(${PROJECT_NAME} input.cpp )
|
|
||||||
target_link_libraries(${PROJECT_NAME} TartLib PickleLib)
|
|
||||||
add_subdirectory(render_test)
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
---
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
Start testing: Jan 28 14:11 Pacific Standard Time (Mexico)
|
|
||||||
----------------------------------------------------------
|
|
||||||
End testing: Jan 28 14:11 Pacific Standard Time (Mexico)
|
|
||||||
1
testing/externals/CMakeLists.txt
vendored
1
testing/externals/CMakeLists.txt
vendored
@@ -1 +0,0 @@
|
|||||||
add_subdirectory(Pickler)
|
|
||||||
1
testing/externals/Pickler
vendored
1
testing/externals/Pickler
vendored
Submodule testing/externals/Pickler deleted from 22a9fb9fab
@@ -1,27 +0,0 @@
|
|||||||
#include <tart.h>
|
|
||||||
#include <iostream>
|
|
||||||
#ifdef _LINUX
|
|
||||||
#endif
|
|
||||||
|
|
||||||
char* bbuf;
|
|
||||||
|
|
||||||
int main (int argc, char *argv[]) {
|
|
||||||
int n;
|
|
||||||
int counter = 0;
|
|
||||||
term_disable_cursor();
|
|
||||||
term_threaded_input_init();
|
|
||||||
bbuf = term_tinputb();
|
|
||||||
while(bbuf[0] != 'q') {
|
|
||||||
|
|
||||||
std::cout << counter++ << '[';
|
|
||||||
for (int i = 0; i < 8; i++) {
|
|
||||||
std::cout << bbuf[i] << ',';
|
|
||||||
}
|
|
||||||
std::cout << "] \r";
|
|
||||||
}
|
|
||||||
std::cout << '\n';
|
|
||||||
term_threaded_input_stop();
|
|
||||||
term_enable_cursor();
|
|
||||||
exit(0);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
#include "test_tart.h"
|
|
||||||
#include "test_term.h"
|
|
||||||
#include <Pickler.h>
|
|
||||||
int main (int argc, char *argv[]) {
|
|
||||||
INSTALLSHELF;
|
|
||||||
tart_run(&__pickle_shelf__);
|
|
||||||
term_run(&__pickle_shelf__);
|
|
||||||
return PICKLESHELF;
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
#include <tart.h>
|
|
||||||
#include <memory.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
int main (int argc, char *argv[]) {
|
|
||||||
struct tart_window window = tart_create_window();
|
|
||||||
struct tart_buffer mainbuff = tart_create_buffer(109, {100,50},{20,20});
|
|
||||||
struct tart_cell* cells = (struct tart_cell*)malloc(mainbuff.cell_count * sizeof(struct tart_cell));
|
|
||||||
for(int i = 1; i < mainbuff.cell_count; i += 2) {
|
|
||||||
cells[i] = tart_create_cell('^', TART_STYLE_BLINKING, TART_COLOR_BLACK_FOREGROUND, TART_COLOR_WHITE_BACKGROUND);
|
|
||||||
}
|
|
||||||
for(int i = 0; i < + mainbuff.cell_count; i += 2) {
|
|
||||||
cells[i] = tart_create_cell('^', TART_STYLE_BLINKING, TART_COLOR_RED_FOREGROUND, TART_COLOR_BLACK_BACKGROUND);
|
|
||||||
}
|
|
||||||
tart_add_cells_to_buffer(&mainbuff, cells);
|
|
||||||
|
|
||||||
char t[1] = {'0'};
|
|
||||||
tart_add_buffer(&window, mainbuff);
|
|
||||||
tart_draw_window(&window, t);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,166 +0,0 @@
|
|||||||
#include "test_tart.h"
|
|
||||||
#include "Pickler.h"
|
|
||||||
bool rgb_test(struct tart_rgb* lhs, struct tart_rgb* rhs) {
|
|
||||||
if(lhs->r != rhs->r) {return false;}
|
|
||||||
if(lhs->g != rhs->g) {return false;}
|
|
||||||
if(lhs->b != rhs->b) {return false;}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool vec2_test(struct tart_vec2* lhs, struct tart_vec2* rhs) {
|
|
||||||
if(lhs->x != rhs->x) {return false;}
|
|
||||||
if(lhs->y != rhs->y) {return false;}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void tart_run(struct pickle_shelf* shelf) {
|
|
||||||
pickle_shelf __pickle_shelf__ = *shelf;
|
|
||||||
CREATEJAR(tart_objects_test);
|
|
||||||
PICKLE(Test_create_buffer) {
|
|
||||||
struct tart_vec2 size = {25,25};
|
|
||||||
struct tart_vec2 position = {0,0};
|
|
||||||
|
|
||||||
int data_count = (size.x*size.y) * TART_CELL_DATA_SIZE;
|
|
||||||
|
|
||||||
unsigned int cell_count = (size.x * size.y);
|
|
||||||
struct tart_buffer buffer_correct = {cell_count,0,25,size,position,0};
|
|
||||||
struct tart_buffer buffer_test = tart_create_buffer(25,size,position);
|
|
||||||
|
|
||||||
if(DIFFERENT(buffer_correct.cell_count,buffer_test.cell_count))
|
|
||||||
ASSERT("Cell count not the same.",false);
|
|
||||||
if(DIFFERENT(buffer_correct.layer,buffer_test.layer))
|
|
||||||
ASSERT("Layers not the same.",false);
|
|
||||||
if(DIFFERENT(buffer_correct.id,buffer_test.id))
|
|
||||||
ASSERT("Ids are not the same.",false);
|
|
||||||
if(DIFFERENT(buffer_correct.size.x,buffer_test.size.x))
|
|
||||||
ASSERT("size.x is not the same",false);
|
|
||||||
if(DIFFERENT(buffer_correct.size.y,buffer_test.size.y))
|
|
||||||
ASSERT("size.y is not the same",false);
|
|
||||||
if(DIFFERENT(buffer_correct.position.x,buffer_test.position.x))
|
|
||||||
ASSERT("position.x is not the same.",false);
|
|
||||||
if(DIFFERENT(buffer_correct.position.y,buffer_test.position.y))
|
|
||||||
ASSERT("position.y is not the same.",false);
|
|
||||||
if(DIFFERENT(buffer_correct.cell_count,buffer_test.cell_count))
|
|
||||||
ASSERT("data_counts are not the same.",false);
|
|
||||||
ASSERT("GOOD",true);
|
|
||||||
}();
|
|
||||||
|
|
||||||
|
|
||||||
PICKLE(Test_create_cell) {
|
|
||||||
|
|
||||||
#ifdef TART_RGB_COLOR
|
|
||||||
struct tart_rgb b = {80,80,80};
|
|
||||||
struct tart_rgb f = {80,80,80};
|
|
||||||
struct tart_cell cell_correct = {f, b, '1', 'f'};
|
|
||||||
struct tart_cell cell_test = tart_create_cell('f', '1', f, b);
|
|
||||||
if(!rgb_test(&cell_correct.foreground, &cell_test.foreground))
|
|
||||||
ASSERT("Forground dose not match.",false);
|
|
||||||
if(!rgb_test(&cell_correct.background, &cell_test.background))
|
|
||||||
ASSERT("background dose not match.",false);
|
|
||||||
#else
|
|
||||||
tart_byte f = 20;
|
|
||||||
tart_byte b = 40;
|
|
||||||
struct tart_cell cell_correct = {f, b, '1', 'f'};
|
|
||||||
struct tart_cell cell_test = tart_create_cell('f', '1', f, b);
|
|
||||||
if(DIFFERENT(cell_correct.foreground, cell_test.foreground))
|
|
||||||
ASSERT("Forground dose not match.",false);
|
|
||||||
if(DIFFERENT(cell_correct.background, cell_test.background))
|
|
||||||
ASSERT("background dose not match.",false);
|
|
||||||
#endif
|
|
||||||
if(DIFFERENT(cell_correct.style, cell_test.style))
|
|
||||||
ASSERT("style dose not match.",false);
|
|
||||||
if(DIFFERENT(cell_correct.display, cell_test.display))
|
|
||||||
ASSERT("display dose not match.",false);
|
|
||||||
ASSERT("GOOD",true);
|
|
||||||
}();
|
|
||||||
|
|
||||||
PICKLE(Test_create_window) {
|
|
||||||
struct tart_buffer buffer = tart_create_buffer(10, {10,20}, {0,0});
|
|
||||||
struct tart_window window = tart_create_window();
|
|
||||||
for(int i = 0; i < 0xFF + 1; i++) {
|
|
||||||
if(DIFFERENT(window.buffers[i].id, 0))
|
|
||||||
ASSERT("buffer not same", false);
|
|
||||||
}
|
|
||||||
ASSERT("GOOD", true);
|
|
||||||
}();
|
|
||||||
PICKLE(Test_add_buffer) {
|
|
||||||
struct tart_buffer buffer = tart_create_buffer(10, {10,20}, {0,0});
|
|
||||||
struct tart_window window = tart_create_window();
|
|
||||||
tart_add_buffer(&window, buffer);
|
|
||||||
if(SAME(window.buffer_count, 0))
|
|
||||||
ASSERT("index has not indexed", false);
|
|
||||||
if(DIFFERENT(window.buffers[0].id, buffer.id))
|
|
||||||
ASSERT("buffer not same", false);
|
|
||||||
ASSERT("GOOD", true);
|
|
||||||
}();
|
|
||||||
|
|
||||||
PICKLE(Test_set_buffer) {
|
|
||||||
struct tart_buffer buffer = tart_create_buffer(10, {10,20}, {0,0});
|
|
||||||
struct tart_window window = tart_create_window();
|
|
||||||
tart_set_buffer(&window, buffer, 0);
|
|
||||||
if(DIFFERENT(window.buffers[0].id, buffer.id))
|
|
||||||
ASSERT("buffer not same", false);
|
|
||||||
ASSERT("GOOD", true);
|
|
||||||
}();
|
|
||||||
|
|
||||||
PICKLE(Test_get_buffer) {
|
|
||||||
struct tart_buffer buffer = tart_create_buffer(10, {10,20}, {0,0});
|
|
||||||
struct tart_window window = tart_create_window();
|
|
||||||
tart_set_buffer(&window, buffer, 0);
|
|
||||||
if(DIFFERENT(tart_get_buffer(&window, 0)->id, buffer.id))
|
|
||||||
ASSERT("buffer not same", false);
|
|
||||||
ASSERT("GOOD", true);
|
|
||||||
}();
|
|
||||||
|
|
||||||
PICKLE(Test_set_cell) {
|
|
||||||
#ifdef TART_RGB_COLORS
|
|
||||||
tart_rgb foreground = {90,90,90};
|
|
||||||
tart_rgb background = {80,80,80};
|
|
||||||
|
|
||||||
#else
|
|
||||||
tart_byte foreground = 9;
|
|
||||||
tart_byte background = 8;
|
|
||||||
#endif
|
|
||||||
struct tart_cell cell = tart_create_cell('0',10,foreground, background);
|
|
||||||
struct tart_buffer buffer = tart_create_buffer(10, {10,20}, {10,20});
|
|
||||||
struct tart_window window = tart_create_window();
|
|
||||||
|
|
||||||
tart_set_cell(&buffer, cell, 0);
|
|
||||||
if(DIFFERENT(buffer.cells[0].display, cell.display))
|
|
||||||
ASSERT("buffer not same", false);
|
|
||||||
ASSERT("GOOD", true);
|
|
||||||
}();
|
|
||||||
|
|
||||||
PICKLE(Test_get_cell) {
|
|
||||||
#ifdef TART_RGB_COLORS
|
|
||||||
tart_rgb foreground = {90,90,90};
|
|
||||||
tart_rgb background = {80,80,80};
|
|
||||||
|
|
||||||
#else
|
|
||||||
tart_byte foreground = 9;
|
|
||||||
tart_byte background = 8;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct tart_cell cell = tart_create_cell('0',10,foreground, background);
|
|
||||||
struct tart_buffer buffer = tart_create_buffer(10, {10,20}, {10,20});
|
|
||||||
struct tart_window window = tart_create_window();
|
|
||||||
|
|
||||||
tart_set_cell(&buffer, cell, 0);
|
|
||||||
if(DIFFERENT(tart_get_cell(&buffer,0)->display, cell.display))
|
|
||||||
ASSERT("buffer not same", false);
|
|
||||||
ASSERT("GOOD", true);
|
|
||||||
}();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ADDPICKLE(tart_objects_test,Test_create_buffer);
|
|
||||||
ADDPICKLE(tart_objects_test,Test_create_cell);
|
|
||||||
ADDPICKLE(tart_objects_test,Test_create_buffer);
|
|
||||||
ADDPICKLE(tart_objects_test,Test_add_buffer);
|
|
||||||
ADDPICKLE(tart_objects_test,Test_set_buffer);
|
|
||||||
ADDPICKLE(tart_objects_test,Test_get_buffer);
|
|
||||||
ADDPICKLE(tart_objects_test,Test_set_cell);
|
|
||||||
ADDPICKLE(tart_objects_test,Test_get_cell);
|
|
||||||
PUTJARONSHELF(tart_objects_test);
|
|
||||||
*shelf = __pickle_shelf__;
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
#include <tart.h>
|
|
||||||
#include <Pickler.h>
|
|
||||||
|
|
||||||
bool rgb_test(struct tart_rgb* lhs, struct tart_rgb* rhs);
|
|
||||||
bool vec2_test(struct tart_vec2* lhs, struct tart_vec2* rhs);
|
|
||||||
void tart_run(struct pickle_shelf* shelf);
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
|
|
||||||
#if defined(_WIN64) || defined(_WIN32)
|
|
||||||
#include <Windows.h>
|
|
||||||
#else
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#endif
|
|
||||||
#include <iostream>
|
|
||||||
#include "test_term.h"
|
|
||||||
void term_run(struct pickle_shelf* shelf) {
|
|
||||||
struct pickle_shelf __pickle_shelf__ = *shelf; //start
|
|
||||||
|
|
||||||
|
|
||||||
CREATEJAR(Test_Term);
|
|
||||||
|
|
||||||
PICKLE(Test_get_window_size) {
|
|
||||||
#if defined(_WIN64) || defined(_WIN32)
|
|
||||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
|
||||||
|
|
||||||
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
|
|
||||||
int columns = (unsigned int)(csbi.srWindow.Right - csbi.srWindow.Left + 1);
|
|
||||||
int rows = (unsigned int)(csbi.srWindow.Bottom - csbi.srWindow.Top + 1);
|
|
||||||
#else
|
|
||||||
struct winsize w;
|
|
||||||
|
|
||||||
|
|
||||||
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
|
|
||||||
|
|
||||||
unsigned int rows = w.ws_row;
|
|
||||||
unsigned int columns = w.ws_col;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
std::cout << "\n";
|
|
||||||
std::cout << term_current_size().x << "term_current_size()\n";
|
|
||||||
std::cout << columns << " columns\n";
|
|
||||||
|
|
||||||
if(term_current_size().x != columns)
|
|
||||||
ASSERT("current_size.x is not the same as columns", false);
|
|
||||||
if(term_current_size().y != rows)
|
|
||||||
ASSERT("current_size.y is not the same as rows", false);
|
|
||||||
ASSERT("GOOD", true);
|
|
||||||
}();
|
|
||||||
|
|
||||||
ADDPICKLE(Test_Term, Test_get_window_size);
|
|
||||||
PUTJARONSHELF(Test_Term);
|
|
||||||
*shelf = __pickle_shelf__; // end
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
#ifndef TEST_TERM_H
|
|
||||||
#define TEST_TERM_H
|
|
||||||
|
|
||||||
#include <tart.h>
|
|
||||||
#include <Pickler.h>
|
|
||||||
void term_run(struct pickle_shelf*);
|
|
||||||
#endif
|
|
||||||
Reference in New Issue
Block a user