diff --git a/includes/tart.h b/includes/tart.h index 9cc57bc..839d3d2 100644 --- a/includes/tart.h +++ b/includes/tart.h @@ -6,6 +6,7 @@ extern "C" { #endif #include "../source/term.h" +#include // #========================================================================# // | PreacherDHM:TART // | @@ -169,6 +170,7 @@ struct tart_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); tart_byte tart_restore_window(struct tart_window*); diff --git a/source/tart.c b/source/tart.c index aa48ea7..c6fb887 100644 --- a/source/tart.c +++ b/source/tart.c @@ -28,9 +28,14 @@ struct tart_window tart_create_window() { window.data[g] = '\0'; } window.data_count = dataSize; + printf("\033[?1049h"); return window; } +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'; diff --git a/source/term.c b/source/term.c index 5c763cb..f7cead9 100644 --- a/source/term.c +++ b/source/term.c @@ -1,11 +1,14 @@ #include "term.h" #include +unsigned char haveread = 0; +unsigned char __state__ = 0; char __term_input_buffer__[8] = {' ',' ',' ',' ',' ',' ',' ',' '}; void set_char_push_back(char t) { char tmp1; char hold1; char hold2; + __state__ = __state__ + 1; hold1 = __term_input_buffer__[0]; for(int i = 0; i < 8 - 1; i++) { hold2 = __term_input_buffer__[i+1]; @@ -140,6 +143,7 @@ void* input_threaded_func(void* vargp) { int myid = getpid(); while(1) { set_char_push_back(term_getch()); + usleep(1000); } return NULL; } @@ -156,6 +160,28 @@ int term_threaded_input_init() { 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 diff --git a/source/term.h b/source/term.h index 1cd777e..b0345ad 100644 --- a/source/term.h +++ b/source/term.h @@ -9,6 +9,9 @@ // #========================================================================# #ifndef TERM_H #define TERM_H + +#define NOREAD 0 + #include "tart.h" struct tart_vec2 term_current_size(); @@ -23,6 +26,10 @@ int term_threaded_input_stop(); char term_tinputi(int idx); char* term_tinputb(); 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_enable_cursor();