added a temperary buffer when running
This commit is contained in:
@@ -6,6 +6,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#include "../source/term.h"
|
||||
#include <stdio.h>
|
||||
// #========================================================================#
|
||||
// | 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*);
|
||||
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
#include "term.h"
|
||||
#include <stdio.h>
|
||||
|
||||
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
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user