kt_register for all types
This commit is contained in:
parent
768c55af4a
commit
9febbe1de0
@ -1,10 +1,5 @@
|
||||
#include "tui_internal.h"
|
||||
|
||||
int TCI_fwrite(FILE* file, TermCharInfo tci){
|
||||
kprint_setColor(tci.color);
|
||||
return termchar_fwrite(file, tci.ch);
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
// FrameBuffer //
|
||||
//////////////////////////////////////
|
||||
|
||||
@ -4,8 +4,14 @@ kt_define(DrawingArea, NULL, NULL);
|
||||
kt_define(UIBorder, NULL, NULL);
|
||||
|
||||
void kt_initScolteTypes(){
|
||||
// term
|
||||
kt_register(TerminalSize);
|
||||
kt_register(TermCharInfo);
|
||||
// tui
|
||||
kt_register(DrawingArea);
|
||||
kt_register(UIBorder);
|
||||
kt_register(FrameBuffer);
|
||||
kt_register(Renderer);
|
||||
kt_register(UIElement);
|
||||
kt_register(Grid);
|
||||
kt_register(TextBlock);
|
||||
|
||||
@ -5,7 +5,6 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#include "../../kerep/src/String/string.h"
|
||||
#include "../../kerep/src/kprint/kprint_format.h"
|
||||
#include "../../kerep/src/Array/Array.h"
|
||||
#include "../term/term.h"
|
||||
#include "../encoding/encoding.h"
|
||||
@ -43,17 +42,9 @@ STRUCT(UIBorder,
|
||||
UIBorderThickness left;
|
||||
UIBorderThickness top;
|
||||
UIBorderThickness bottom;
|
||||
kp_fmt color;
|
||||
termcolor color;
|
||||
)
|
||||
|
||||
STRUCT(TermCharInfo,
|
||||
termchar ch;
|
||||
kp_fmt color; /* background + foreground */
|
||||
)
|
||||
|
||||
#define TCI(CH,COLOR)(TermCharInfo){.ch=CH, .color=COLOR}
|
||||
int TCI_fwrite(FILE* file, TermCharInfo tci);
|
||||
#define TCI_print(tci) TCI_fwrite(stdout, tci);
|
||||
|
||||
//////////////////////////////////////
|
||||
// Renderer //
|
||||
@ -99,7 +90,7 @@ STRUCT(UIElement,
|
||||
u16 min_height;
|
||||
u16 width_scaling;
|
||||
u16 height_scaling;
|
||||
kp_fmt color;
|
||||
termcolor color;
|
||||
UIBorder border;
|
||||
UIElement_draw_t draw;
|
||||
)
|
||||
|
||||
@ -15,11 +15,6 @@ typedef u32 utf32char;
|
||||
///@returns <0 error code of fputc
|
||||
int utf32char_fwrite(FILE* file, utf32char ch);
|
||||
|
||||
typedef utf32char termchar;
|
||||
#define TERMCHAR(CHAR) U##CHAR
|
||||
#define TERMSTR(STR) U##STR
|
||||
#define termchar_fwrite utf32char_fwrite
|
||||
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
8
src/term/TermCharInfo.c
Normal file
8
src/term/TermCharInfo.c
Normal file
@ -0,0 +1,8 @@
|
||||
#include "term.h"
|
||||
|
||||
kt_define(TermCharInfo, NULL, NULL);
|
||||
|
||||
int TCI_fwrite(FILE* file, TermCharInfo tci){
|
||||
kprint_setColor(tci.color);
|
||||
return termchar_fwrite(file, tci.ch);
|
||||
}
|
||||
@ -3,14 +3,17 @@
|
||||
#include <unistd.h>
|
||||
#include IFWIN("windows.h", "sys/ioctl.h")
|
||||
|
||||
void term_moveCursor(u16 row, u16 column){
|
||||
printf("\e[%u;%uf",row,column);
|
||||
|
||||
char* TerminalSize_toString(TerminalSize t){
|
||||
char buf[64];
|
||||
sprintf_s(buf, sizeof(buf), "(%ux%u)", t.cols, t.rows);
|
||||
return cptr_copy(buf);
|
||||
}
|
||||
|
||||
void term_clear() {
|
||||
printf("\e[2j");
|
||||
}
|
||||
char* __TerminalSize_toString(void* _t, u32 fmt){ return TerminalSize_toString(*(TerminalSize*)_t); }
|
||||
|
||||
kt_define(TerminalSize, NULL, __TerminalSize_toString);
|
||||
|
||||
TerminalSize term_default_size={.cols=80, .rows=16};
|
||||
|
||||
bool term_getSize(TerminalSize* out) {
|
||||
#if defined(_WIN64) || defined(_WIN32)
|
||||
@ -35,4 +38,11 @@ bool term_getSize(TerminalSize* out) {
|
||||
return true;
|
||||
}
|
||||
|
||||
TerminalSize term_default_size={.cols=80, .rows=16};
|
||||
|
||||
void term_moveCursor(u16 row, u16 column){
|
||||
printf("\e[%u;%uf",row,column);
|
||||
}
|
||||
|
||||
void term_clear() {
|
||||
printf("\e[2j");
|
||||
}
|
||||
|
||||
@ -5,13 +5,15 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#include "../../kerep/src/base/base.h"
|
||||
#include "../../kerep/src/kprint/kprint_format.h"
|
||||
#include "../encoding/encoding.h"
|
||||
|
||||
void term_moveCursor(u16 row, u16 column);
|
||||
void term_clear();
|
||||
|
||||
STRUCT(TerminalSize,
|
||||
u16 rows;
|
||||
u16 cols;
|
||||
u16 rows;
|
||||
)
|
||||
|
||||
///@return TRUE if have got terminal size, otherwise FALSE
|
||||
@ -20,6 +22,21 @@ bool term_getSize(TerminalSize* out) WARN_UNUSED_REZULT;
|
||||
/// can be used if term_getSize() fails
|
||||
extern TerminalSize term_default_size;
|
||||
|
||||
typedef kp_fmt termcolor;
|
||||
typedef utf32char termchar;
|
||||
#define TERMCHAR(CHAR) U##CHAR
|
||||
#define TERMSTR(STR) U##STR
|
||||
#define termchar_fwrite utf32char_fwrite
|
||||
|
||||
STRUCT(TermCharInfo,
|
||||
termchar ch;
|
||||
termcolor color; /* background + foreground */
|
||||
)
|
||||
|
||||
#define TCI(CH,COLOR)(TermCharInfo){.ch=CH, .color=COLOR}
|
||||
int TCI_fwrite(FILE* file, TermCharInfo tci);
|
||||
#define TCI_print(tci) TCI_fwrite(stdout, tci);
|
||||
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Loading…
Reference in New Issue
Block a user