utf8proc library added
This commit is contained in:
parent
483e6fa96b
commit
c8dfd8224e
4
.gitmodules
vendored
4
.gitmodules
vendored
@ -4,3 +4,7 @@
|
||||
[submodule "kerep"]
|
||||
path = kerep
|
||||
url = https://github.com/Timerix22/kerep.git
|
||||
[submodule "utf8proc"]
|
||||
path = utf8proc
|
||||
url = https://github.com/Timerix22/utf8proc.git
|
||||
branch = my_branch
|
||||
|
||||
13
Makefile
13
Makefile
@ -12,6 +12,15 @@ build_exec: profile
|
||||
build_exec_dbg:
|
||||
@cbuild/call_task.sh build_exec_dbg 2>&1 | tee make_raw.log
|
||||
|
||||
# recompile kerep.a in the next build task
|
||||
rebuild_kerep:
|
||||
@tasks/rebuild_lib.sh kerep
|
||||
# recompile utf8proc.a in the next build task
|
||||
rebuild_utf8proc:
|
||||
@tasks/rebuild_lib.sh utf8proc
|
||||
|
||||
rebuild_all: rebuild_kerep rebuild_utf8proc
|
||||
|
||||
######################################
|
||||
###### Launch tasks #######
|
||||
######################################
|
||||
@ -59,7 +68,3 @@ fix_log:
|
||||
| sed 's/ H //g' \
|
||||
| sed 's/\[3gH //g' \
|
||||
> make_fixed.log
|
||||
|
||||
# recompile kerep.a in the next build task
|
||||
rebuild_kerep:
|
||||
@cbuild/call_task.sh rebuild_kerep
|
||||
|
||||
@ -26,7 +26,6 @@ OUTDIR="bin"
|
||||
case "$OS" in
|
||||
WINDOWS)
|
||||
EXEC_FILE="$PROJECT.exe"
|
||||
SHARED_LIB_FILE="$PROJECT.dll"
|
||||
;;
|
||||
LINUX)
|
||||
EXEC_FILE="$PROJECT"
|
||||
@ -38,9 +37,6 @@ esac
|
||||
|
||||
# TASKS
|
||||
case "$TASK" in
|
||||
rebuild_kerep)
|
||||
TASK_SCRIPT=tasks/rebuild_kerep.sh
|
||||
;;
|
||||
# creates executable using profile info generated by build_profile
|
||||
build_exec)
|
||||
# -flto applies more optimizations across object files
|
||||
@ -51,7 +47,7 @@ case "$TASK" in
|
||||
LINKER_ARGS="$CPP_ARGS"
|
||||
PRE_TASK_SCRIPT=tasks/pre_build.sh
|
||||
TASK_SCRIPT=cbuild/default_tasks/build_exec.sh
|
||||
KEREP_BUILD_TASK=build_static_lib
|
||||
DEPS_BUILD_TASK=build_static_lib
|
||||
;;
|
||||
# creates executable with debug info and no optimizations
|
||||
build_exec_dbg)
|
||||
@ -60,7 +56,7 @@ case "$TASK" in
|
||||
LINKER_ARGS="$CPP_ARGS"
|
||||
PRE_TASK_SCRIPT=tasks/pre_build.sh
|
||||
TASK_SCRIPT=cbuild/default_tasks/build_exec.sh
|
||||
KEREP_BUILD_TASK=build_static_lib_dbg
|
||||
DEPS_BUILD_TASK=build_static_lib_dbg
|
||||
;;
|
||||
# executes $EXEC_FILE
|
||||
exec)
|
||||
|
||||
@ -21,10 +21,11 @@ Maybe FrameBuffer_create(FrameBuffer* fb){
|
||||
term_default_size.cols, term_default_size.rows);
|
||||
}
|
||||
u32 length=fb->size.cols * fb->size.rows;
|
||||
fb->data=malloc(sizeof(*fb->data) * length);
|
||||
u32 sz=sizeof(*fb->data);
|
||||
fb->data=malloc( sz* length);
|
||||
|
||||
for(u32 i=0; i<length; i++)
|
||||
fb->data[i]=UTFCHAR('#');
|
||||
fb->data[i]=TERMCHAR('#');
|
||||
|
||||
return MaybeNull;
|
||||
}
|
||||
@ -38,7 +39,7 @@ void Renderer_freeMembers(void * _self){
|
||||
// Renderer //
|
||||
//////////////////////////////////////
|
||||
|
||||
UI_Maybe __Renderer_set(Renderer* self, utfchar c, u16 x, u16 y) {
|
||||
UI_Maybe __Renderer_set(Renderer* self, termchar c, u16 x, u16 y) {
|
||||
if(x >= self->frameBuffer.size.cols)
|
||||
UI_safethrow(UIError_InvalidX,;);
|
||||
if(y >= self->frameBuffer.size.rows)
|
||||
@ -57,8 +58,8 @@ UI_Maybe __Renderer_drawFrame(Renderer* self){
|
||||
|
||||
for(u16 y=0; y<buf.size.rows; y++){
|
||||
for(u16 x=0; x<buf.size.cols; x++){
|
||||
utfchar c=buf.data[buf.size.cols*y + x];
|
||||
int rez=utfchar_print(c);
|
||||
termchar c=buf.data[buf.size.cols*y + x];
|
||||
int rez=termchar_print(c);
|
||||
if(rez<0){
|
||||
char* chex=toString_hex(&c, sizeof(c), true, true, true);
|
||||
char* errnostr=toString_i64(errno);
|
||||
@ -95,7 +96,7 @@ Renderer* Renderer_create(){
|
||||
// drawing functions //
|
||||
//////////////////////////////////////
|
||||
|
||||
UI_Maybe Renderer_fill(Renderer* renderer, utfchar c, DrawingArea area){
|
||||
UI_Maybe Renderer_fill(Renderer* renderer, termchar c, DrawingArea area){
|
||||
UI_try(DrawingArea_validate(area),_,;);
|
||||
for(u16 y=area.y; y<area.y+area.h; y++)
|
||||
for(u16 x=area.x; x<area.x+area.w; x++){
|
||||
@ -104,7 +105,7 @@ UI_Maybe Renderer_fill(Renderer* renderer, utfchar c, DrawingArea area){
|
||||
return MaybeNull;
|
||||
}
|
||||
|
||||
UI_Maybe Renderer_drawLineX(Renderer* renderer, utfchar c, u16 x, u16 y, u16 length){
|
||||
UI_Maybe Renderer_drawLineX(Renderer* renderer, termchar c, u16 x, u16 y, u16 length){
|
||||
while(length>0){
|
||||
UI_try(Renderer_set(renderer, c, x, y),_,;);
|
||||
x++; length--;
|
||||
@ -112,7 +113,7 @@ UI_Maybe Renderer_drawLineX(Renderer* renderer, utfchar c, u16 x, u16 y, u16 len
|
||||
return MaybeNull;
|
||||
}
|
||||
|
||||
UI_Maybe Renderer_drawLineY(Renderer* renderer, utfchar c, u16 x, u16 y, u16 length){
|
||||
UI_Maybe Renderer_drawLineY(Renderer* renderer, termchar c, u16 x, u16 y, u16 length){
|
||||
while(length>0){
|
||||
UI_try(Renderer_set(renderer, c, x, y),_,;);
|
||||
y++; length--;
|
||||
@ -124,10 +125,10 @@ UI_Maybe Renderer_drawBorder(Renderer* renderer, UIBorder border, DrawingArea ar
|
||||
UI_try(DrawingArea_validate(area),_0,;);
|
||||
|
||||
//lines
|
||||
utfchar topChar = UIBorder_char_h[border.top ];
|
||||
utfchar bottomChar = UIBorder_char_h[border.bottom];
|
||||
utfchar leftChar = UIBorder_char_v[border.left ];
|
||||
utfchar rightChar = UIBorder_char_v[border.right ];
|
||||
termchar topChar = UIBorder_char_h[border.top ];
|
||||
termchar bottomChar = UIBorder_char_h[border.bottom];
|
||||
termchar leftChar = UIBorder_char_v[border.left ];
|
||||
termchar rightChar = UIBorder_char_v[border.right ];
|
||||
// top
|
||||
|
||||
// TODO check neighbor borders and insert crossing chars like '╄'
|
||||
@ -141,10 +142,10 @@ UI_Maybe Renderer_drawBorder(Renderer* renderer, UIBorder border, DrawingArea ar
|
||||
UI_try(Renderer_drawLineY(renderer, rightChar, area.x+area.w-1, area.y+1, area.h-2),_4,;)
|
||||
|
||||
// corners
|
||||
utfchar ltCornerChar = UIBorder_char_lt[border.left ][border.top ];
|
||||
utfchar rtCornerChar = UIBorder_char_rt[border.right][border.top ];
|
||||
utfchar rbCornerChar = UIBorder_char_rb[border.right][border.bottom];
|
||||
utfchar lbCornerChar = UIBorder_char_lb[border.left ][border.bottom];
|
||||
termchar ltCornerChar = UIBorder_char_lt[border.left ][border.top ];
|
||||
termchar rtCornerChar = UIBorder_char_rt[border.right][border.top ];
|
||||
termchar rbCornerChar = UIBorder_char_rb[border.right][border.bottom];
|
||||
termchar lbCornerChar = UIBorder_char_lb[border.left ][border.bottom];
|
||||
// left top corner
|
||||
UI_try(Renderer_set(renderer, ltCornerChar, area.x, area.y),_5,;);
|
||||
// right top corner
|
||||
|
||||
@ -8,7 +8,7 @@ void TextBlock_freeMembers(void* _self){
|
||||
UI_Maybe TextBlock_draw(Renderer* renderer, UIElement* _self, DrawingArea area){
|
||||
TextBlock* self=(TextBlock*)_self;
|
||||
UI_try(UIElement_validate((UIElement*)self, area),_0,;);
|
||||
UI_try(Renderer_fill(renderer, UTFCHAR(' '), area),_2,;);
|
||||
UI_try(Renderer_fill(renderer, TERMCHAR(' '), area),_2,;);
|
||||
UI_try(Renderer_drawBorder(renderer, self->base.borders, area),_1,;);
|
||||
return MaybeNull;
|
||||
}
|
||||
|
||||
@ -8,7 +8,7 @@ extern "C" {
|
||||
#include "../../kerep/src/kprint/kprint_colors.h"
|
||||
#include "../../kerep/src/Array/Array.h"
|
||||
#include "../term/term.h"
|
||||
#include "unicode.h"
|
||||
#include "../encoding/encoding.h"
|
||||
#include "UIError.h"
|
||||
|
||||
|
||||
@ -62,7 +62,7 @@ STRUCT(UIBorder,
|
||||
//////////////////////////////////////
|
||||
|
||||
STRUCT(FrameBuffer,
|
||||
utfchar* data;
|
||||
termchar* data;
|
||||
TerminalSize size;
|
||||
)
|
||||
|
||||
@ -71,7 +71,7 @@ typedef struct Renderer Renderer;
|
||||
STRUCT(Renderer,
|
||||
FrameBuffer frameBuffer;
|
||||
UI_THROWING_FUNC_DECL((*drawFrame)(Renderer*));
|
||||
UI_THROWING_FUNC_DECL((*set)(Renderer*, utfchar c, u16 x, u16 y));
|
||||
UI_THROWING_FUNC_DECL((*set)(Renderer*, termchar c, u16 x, u16 y));
|
||||
)
|
||||
|
||||
#define Renderer_drawFrame(RENDERER) RENDERER->drawFrame(RENDERER)
|
||||
@ -80,9 +80,9 @@ STRUCT(Renderer,
|
||||
Renderer* Renderer_create();
|
||||
void Renderer_destroy(Renderer* self);
|
||||
|
||||
UI_THROWING_FUNC_DECL(Renderer_fill(Renderer* renderer, utfchar c, DrawingArea area));
|
||||
UI_THROWING_FUNC_DECL(Renderer_drawLineX(Renderer* renderer, utfchar c, u16 x, u16 y, u16 length));
|
||||
UI_THROWING_FUNC_DECL(Renderer_drawLineY(Renderer* renderer, utfchar c, u16 x, u16 y, u16 length));
|
||||
UI_THROWING_FUNC_DECL(Renderer_fill(Renderer* renderer, termchar c, DrawingArea area));
|
||||
UI_THROWING_FUNC_DECL(Renderer_drawLineX(Renderer* renderer, termchar c, u16 x, u16 y, u16 length));
|
||||
UI_THROWING_FUNC_DECL(Renderer_drawLineY(Renderer* renderer, termchar c, u16 x, u16 y, u16 length));
|
||||
UI_THROWING_FUNC_DECL(Renderer_drawBorder(Renderer* renderer, UIBorder border, DrawingArea area));
|
||||
|
||||
//////////////////////////////////////
|
||||
|
||||
@ -10,12 +10,12 @@ UIElement __UIElement_createDefault(ktid typeId, UIElement_draw_t drawFunc);
|
||||
UI_THROWING_FUNC_DECL(DrawingArea_validate(DrawingArea a));
|
||||
UI_THROWING_FUNC_DECL(UIElement_validate(UIElement* u, DrawingArea a));
|
||||
|
||||
extern utfchar UIBorder_char_h[4];
|
||||
extern utfchar UIBorder_char_v[4];
|
||||
extern utfchar UIBorder_char_lt[4][4];
|
||||
extern utfchar UIBorder_char_rt[4][4];
|
||||
extern utfchar UIBorder_char_rb[4][4];
|
||||
extern utfchar UIBorder_char_lb[4][4];
|
||||
extern termchar UIBorder_char_h[4];
|
||||
extern termchar UIBorder_char_v[4];
|
||||
extern termchar UIBorder_char_lt[4][4];
|
||||
extern termchar UIBorder_char_rt[4][4];
|
||||
extern termchar UIBorder_char_rb[4][4];
|
||||
extern termchar UIBorder_char_lb[4][4];
|
||||
|
||||
#if __cplusplus
|
||||
}
|
||||
|
||||
@ -1,108 +1,108 @@
|
||||
#include "tui_internal.h"
|
||||
|
||||
utfchar UIBorder_char_h[4]={
|
||||
[UIBorder_Hidden]=UTFCHAR(' '),
|
||||
[UIBorder_Thin ]=UTFCHAR('─'),
|
||||
[UIBorder_Thick ]=UTFCHAR('━'),
|
||||
[UIBorder_Double]=UTFCHAR('═')
|
||||
termchar UIBorder_char_h[4]={
|
||||
[UIBorder_Hidden]=TERMCHAR(' '),
|
||||
[UIBorder_Thin ]=TERMCHAR('─'),
|
||||
[UIBorder_Thick ]=TERMCHAR('━'),
|
||||
[UIBorder_Double]=TERMCHAR('═')
|
||||
};
|
||||
|
||||
utfchar UIBorder_char_v[4]={
|
||||
[UIBorder_Hidden]=UTFCHAR(' '),
|
||||
[UIBorder_Thin ]=UTFCHAR('│'),
|
||||
[UIBorder_Thick ]=UTFCHAR('┃'),
|
||||
[UIBorder_Double]=UTFCHAR('║')
|
||||
termchar UIBorder_char_v[4]={
|
||||
[UIBorder_Hidden]=TERMCHAR(' '),
|
||||
[UIBorder_Thin ]=TERMCHAR('│'),
|
||||
[UIBorder_Thick ]=TERMCHAR('┃'),
|
||||
[UIBorder_Double]=TERMCHAR('║')
|
||||
};
|
||||
|
||||
/// [left_border][top_border]
|
||||
utfchar UIBorder_char_lt[4][4]={
|
||||
[UIBorder_Hidden][UIBorder_Hidden]=UTFCHAR(' '),
|
||||
[UIBorder_Hidden][UIBorder_Thin ]=UTFCHAR('─'),
|
||||
[UIBorder_Hidden][UIBorder_Thick ]=UTFCHAR('━'),
|
||||
[UIBorder_Hidden][UIBorder_Double]=UTFCHAR('═'),
|
||||
termchar UIBorder_char_lt[4][4]={
|
||||
[UIBorder_Hidden][UIBorder_Hidden]=TERMCHAR(' '),
|
||||
[UIBorder_Hidden][UIBorder_Thin ]=TERMCHAR('─'),
|
||||
[UIBorder_Hidden][UIBorder_Thick ]=TERMCHAR('━'),
|
||||
[UIBorder_Hidden][UIBorder_Double]=TERMCHAR('═'),
|
||||
|
||||
[UIBorder_Thin ][UIBorder_Hidden]=UTFCHAR('│'),
|
||||
[UIBorder_Thin ][UIBorder_Thin ]=UTFCHAR('┌'),
|
||||
[UIBorder_Thin ][UIBorder_Thick ]=UTFCHAR('┍'),
|
||||
[UIBorder_Thin ][UIBorder_Double]=UTFCHAR('╒'),
|
||||
[UIBorder_Thin ][UIBorder_Hidden]=TERMCHAR('│'),
|
||||
[UIBorder_Thin ][UIBorder_Thin ]=TERMCHAR('┌'),
|
||||
[UIBorder_Thin ][UIBorder_Thick ]=TERMCHAR('┍'),
|
||||
[UIBorder_Thin ][UIBorder_Double]=TERMCHAR('╒'),
|
||||
|
||||
[UIBorder_Thick ][UIBorder_Hidden]=UTFCHAR('┃'),
|
||||
[UIBorder_Thick ][UIBorder_Thin ]=UTFCHAR('┎'),
|
||||
[UIBorder_Thick ][UIBorder_Thick ]=UTFCHAR('┏'),
|
||||
[UIBorder_Thick ][UIBorder_Double]=UTFCHAR('╒'),
|
||||
[UIBorder_Thick ][UIBorder_Hidden]=TERMCHAR('┃'),
|
||||
[UIBorder_Thick ][UIBorder_Thin ]=TERMCHAR('┎'),
|
||||
[UIBorder_Thick ][UIBorder_Thick ]=TERMCHAR('┏'),
|
||||
[UIBorder_Thick ][UIBorder_Double]=TERMCHAR('╒'),
|
||||
|
||||
[UIBorder_Double][UIBorder_Hidden]=UTFCHAR('║'),
|
||||
[UIBorder_Double][UIBorder_Thin ]=UTFCHAR('╓'),
|
||||
[UIBorder_Double][UIBorder_Thick ]=UTFCHAR('╓'),
|
||||
[UIBorder_Double][UIBorder_Double]=UTFCHAR('╔')
|
||||
[UIBorder_Double][UIBorder_Hidden]=TERMCHAR('║'),
|
||||
[UIBorder_Double][UIBorder_Thin ]=TERMCHAR('╓'),
|
||||
[UIBorder_Double][UIBorder_Thick ]=TERMCHAR('╓'),
|
||||
[UIBorder_Double][UIBorder_Double]=TERMCHAR('╔')
|
||||
};
|
||||
|
||||
|
||||
/// [right_border][top_border]
|
||||
utfchar UIBorder_char_rt[4][4]={
|
||||
[UIBorder_Hidden][UIBorder_Hidden]=UTFCHAR(' '),
|
||||
[UIBorder_Hidden][UIBorder_Thin ]=UTFCHAR('─'),
|
||||
[UIBorder_Hidden][UIBorder_Thick ]=UTFCHAR('━'),
|
||||
[UIBorder_Hidden][UIBorder_Double]=UTFCHAR('═'),
|
||||
termchar UIBorder_char_rt[4][4]={
|
||||
[UIBorder_Hidden][UIBorder_Hidden]=TERMCHAR(' '),
|
||||
[UIBorder_Hidden][UIBorder_Thin ]=TERMCHAR('─'),
|
||||
[UIBorder_Hidden][UIBorder_Thick ]=TERMCHAR('━'),
|
||||
[UIBorder_Hidden][UIBorder_Double]=TERMCHAR('═'),
|
||||
|
||||
[UIBorder_Thin ][UIBorder_Hidden]=UTFCHAR('│'),
|
||||
[UIBorder_Thin ][UIBorder_Thin ]=UTFCHAR('┐'),
|
||||
[UIBorder_Thin ][UIBorder_Thick ]=UTFCHAR('┑'),
|
||||
[UIBorder_Thin ][UIBorder_Double]=UTFCHAR('╕'),
|
||||
[UIBorder_Thin ][UIBorder_Hidden]=TERMCHAR('│'),
|
||||
[UIBorder_Thin ][UIBorder_Thin ]=TERMCHAR('┐'),
|
||||
[UIBorder_Thin ][UIBorder_Thick ]=TERMCHAR('┑'),
|
||||
[UIBorder_Thin ][UIBorder_Double]=TERMCHAR('╕'),
|
||||
|
||||
[UIBorder_Thick ][UIBorder_Hidden]=UTFCHAR('┃'),
|
||||
[UIBorder_Thick ][UIBorder_Thin ]=UTFCHAR('┒'),
|
||||
[UIBorder_Thick ][UIBorder_Thick ]=UTFCHAR('┓'),
|
||||
[UIBorder_Thick ][UIBorder_Double]=UTFCHAR('╕'),
|
||||
[UIBorder_Thick ][UIBorder_Hidden]=TERMCHAR('┃'),
|
||||
[UIBorder_Thick ][UIBorder_Thin ]=TERMCHAR('┒'),
|
||||
[UIBorder_Thick ][UIBorder_Thick ]=TERMCHAR('┓'),
|
||||
[UIBorder_Thick ][UIBorder_Double]=TERMCHAR('╕'),
|
||||
|
||||
[UIBorder_Double][UIBorder_Hidden]=UTFCHAR('║'),
|
||||
[UIBorder_Double][UIBorder_Thin ]=UTFCHAR('╖'),
|
||||
[UIBorder_Double][UIBorder_Thick ]=UTFCHAR('╖'),
|
||||
[UIBorder_Double][UIBorder_Double]=UTFCHAR('╗')
|
||||
[UIBorder_Double][UIBorder_Hidden]=TERMCHAR('║'),
|
||||
[UIBorder_Double][UIBorder_Thin ]=TERMCHAR('╖'),
|
||||
[UIBorder_Double][UIBorder_Thick ]=TERMCHAR('╖'),
|
||||
[UIBorder_Double][UIBorder_Double]=TERMCHAR('╗')
|
||||
};
|
||||
|
||||
/// [right_border][bottom_border]
|
||||
utfchar UIBorder_char_rb[4][4]={
|
||||
[UIBorder_Hidden][UIBorder_Hidden]=UTFCHAR(' '),
|
||||
[UIBorder_Hidden][UIBorder_Thin ]=UTFCHAR('─'),
|
||||
[UIBorder_Hidden][UIBorder_Thick ]=UTFCHAR('━'),
|
||||
[UIBorder_Hidden][UIBorder_Double]=UTFCHAR('═'),
|
||||
termchar UIBorder_char_rb[4][4]={
|
||||
[UIBorder_Hidden][UIBorder_Hidden]=TERMCHAR(' '),
|
||||
[UIBorder_Hidden][UIBorder_Thin ]=TERMCHAR('─'),
|
||||
[UIBorder_Hidden][UIBorder_Thick ]=TERMCHAR('━'),
|
||||
[UIBorder_Hidden][UIBorder_Double]=TERMCHAR('═'),
|
||||
|
||||
[UIBorder_Thin ][UIBorder_Hidden]=UTFCHAR('│'),
|
||||
[UIBorder_Thin ][UIBorder_Thin ]=UTFCHAR('┘'),
|
||||
[UIBorder_Thin ][UIBorder_Thick ]=UTFCHAR('┙'),
|
||||
[UIBorder_Thin ][UIBorder_Double]=UTFCHAR('╛'),
|
||||
[UIBorder_Thin ][UIBorder_Hidden]=TERMCHAR('│'),
|
||||
[UIBorder_Thin ][UIBorder_Thin ]=TERMCHAR('┘'),
|
||||
[UIBorder_Thin ][UIBorder_Thick ]=TERMCHAR('┙'),
|
||||
[UIBorder_Thin ][UIBorder_Double]=TERMCHAR('╛'),
|
||||
|
||||
[UIBorder_Thick ][UIBorder_Hidden]=UTFCHAR('┃'),
|
||||
[UIBorder_Thick ][UIBorder_Thin ]=UTFCHAR('┚'),
|
||||
[UIBorder_Thick ][UIBorder_Thick ]=UTFCHAR('┛'),
|
||||
[UIBorder_Thick ][UIBorder_Double]=UTFCHAR('╛'),
|
||||
[UIBorder_Thick ][UIBorder_Hidden]=TERMCHAR('┃'),
|
||||
[UIBorder_Thick ][UIBorder_Thin ]=TERMCHAR('┚'),
|
||||
[UIBorder_Thick ][UIBorder_Thick ]=TERMCHAR('┛'),
|
||||
[UIBorder_Thick ][UIBorder_Double]=TERMCHAR('╛'),
|
||||
|
||||
[UIBorder_Double][UIBorder_Hidden]=UTFCHAR('║'),
|
||||
[UIBorder_Double][UIBorder_Thin ]=UTFCHAR('╜'),
|
||||
[UIBorder_Double][UIBorder_Thick ]=UTFCHAR('╜'),
|
||||
[UIBorder_Double][UIBorder_Double]=UTFCHAR('╝')
|
||||
[UIBorder_Double][UIBorder_Hidden]=TERMCHAR('║'),
|
||||
[UIBorder_Double][UIBorder_Thin ]=TERMCHAR('╜'),
|
||||
[UIBorder_Double][UIBorder_Thick ]=TERMCHAR('╜'),
|
||||
[UIBorder_Double][UIBorder_Double]=TERMCHAR('╝')
|
||||
};
|
||||
|
||||
/// [left_border][bottom_border]
|
||||
utfchar UIBorder_char_lb[4][4]={
|
||||
[UIBorder_Hidden][UIBorder_Hidden]=UTFCHAR(' '),
|
||||
[UIBorder_Hidden][UIBorder_Thin ]=UTFCHAR('─'),
|
||||
[UIBorder_Hidden][UIBorder_Thick ]=UTFCHAR('━'),
|
||||
[UIBorder_Hidden][UIBorder_Double]=UTFCHAR('═'),
|
||||
termchar UIBorder_char_lb[4][4]={
|
||||
[UIBorder_Hidden][UIBorder_Hidden]=TERMCHAR(' '),
|
||||
[UIBorder_Hidden][UIBorder_Thin ]=TERMCHAR('─'),
|
||||
[UIBorder_Hidden][UIBorder_Thick ]=TERMCHAR('━'),
|
||||
[UIBorder_Hidden][UIBorder_Double]=TERMCHAR('═'),
|
||||
|
||||
[UIBorder_Thin ][UIBorder_Hidden]=UTFCHAR('│'),
|
||||
[UIBorder_Thin ][UIBorder_Thin ]=UTFCHAR('└'),
|
||||
[UIBorder_Thin ][UIBorder_Thick ]=UTFCHAR('┕'),
|
||||
[UIBorder_Thin ][UIBorder_Double]=UTFCHAR('╘'),
|
||||
[UIBorder_Thin ][UIBorder_Hidden]=TERMCHAR('│'),
|
||||
[UIBorder_Thin ][UIBorder_Thin ]=TERMCHAR('└'),
|
||||
[UIBorder_Thin ][UIBorder_Thick ]=TERMCHAR('┕'),
|
||||
[UIBorder_Thin ][UIBorder_Double]=TERMCHAR('╘'),
|
||||
|
||||
[UIBorder_Thick ][UIBorder_Hidden]=UTFCHAR('┃'),
|
||||
[UIBorder_Thick ][UIBorder_Thin ]=UTFCHAR('┖'),
|
||||
[UIBorder_Thick ][UIBorder_Thick ]=UTFCHAR('┗'),
|
||||
[UIBorder_Thick ][UIBorder_Double]=UTFCHAR('╘'),
|
||||
[UIBorder_Thick ][UIBorder_Hidden]=TERMCHAR('┃'),
|
||||
[UIBorder_Thick ][UIBorder_Thin ]=TERMCHAR('┖'),
|
||||
[UIBorder_Thick ][UIBorder_Thick ]=TERMCHAR('┗'),
|
||||
[UIBorder_Thick ][UIBorder_Double]=TERMCHAR('╘'),
|
||||
|
||||
[UIBorder_Double][UIBorder_Hidden]=UTFCHAR('║'),
|
||||
[UIBorder_Double][UIBorder_Thin ]=UTFCHAR('╙'),
|
||||
[UIBorder_Double][UIBorder_Thick ]=UTFCHAR('╙'),
|
||||
[UIBorder_Double][UIBorder_Double]=UTFCHAR('╚')
|
||||
[UIBorder_Double][UIBorder_Hidden]=TERMCHAR('║'),
|
||||
[UIBorder_Double][UIBorder_Thin ]=TERMCHAR('╙'),
|
||||
[UIBorder_Double][UIBorder_Thick ]=TERMCHAR('╙'),
|
||||
[UIBorder_Double][UIBorder_Double]=TERMCHAR('╚')
|
||||
};
|
||||
|
||||
@ -1,31 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// #include <wchar.h>
|
||||
#include <uchar.h>
|
||||
|
||||
typedef char16_t utfchar;
|
||||
#define UTFCHAR(CHAR) u##CHAR
|
||||
#define UTFSTR(STR) u##STR
|
||||
|
||||
// returns length of written bytes or error code
|
||||
static inline size_t utfchar_write(utfchar ch, FILE* file){
|
||||
char multibyteUtf8[8]={0};
|
||||
mbstate_t mbs={0};
|
||||
size_t length=c16rtomb(multibyteUtf8, ch, &mbs);
|
||||
if(length!=(size_t)-1)
|
||||
for(u8 i=0; i<length; i++){
|
||||
int rez=fputc(multibyteUtf8[i], file);
|
||||
if(rez<0)
|
||||
return rez;
|
||||
}
|
||||
return length;
|
||||
}
|
||||
#define utfchar_print(CH) utfchar_write(CH, stdout)
|
||||
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif
|
||||
25
src/encoding/encoding.h
Normal file
25
src/encoding/encoding.h
Normal file
@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "../../kerep/src/base/base.h"
|
||||
|
||||
typedef u8 utf8char;
|
||||
typedef u32 utf32char;
|
||||
|
||||
/// Writes utf32 char to file
|
||||
///@returns >0 length of utf8 multibyte character representation.
|
||||
///@returns 0 utf8proc_encode_char returns error
|
||||
///@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_print(CH) utf32char_fwrite(stdout, CH)
|
||||
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif
|
||||
15
src/encoding/utf32.c
Normal file
15
src/encoding/utf32.c
Normal file
@ -0,0 +1,15 @@
|
||||
#include "encoding.h"
|
||||
#include "../../utf8proc/utf8proc.h"
|
||||
|
||||
int utf32char_fwrite(FILE* file, utf32char ch){
|
||||
utf8char utf8buf[6];
|
||||
int length=utf8proc_encode_char(ch, utf8buf);
|
||||
|
||||
for(u8 i=0; i<length; i++){
|
||||
int rez=fputc(utf8buf[i], file);
|
||||
if(rez<0)
|
||||
return rez;
|
||||
}
|
||||
|
||||
return length;
|
||||
}
|
||||
12
src/main.c
12
src/main.c
@ -12,10 +12,16 @@ Maybe tryReadFile(char* filePath){
|
||||
try(file_close(file),_m_,;);
|
||||
return SUCCESS(UniHeapPtr(char,fileContent));
|
||||
}
|
||||
|
||||
#include <windows.h>
|
||||
i32 main(const i32 argc, const char* const* argv){
|
||||
if(setlocale(LC_CTYPE, "C.UTF-8")!=0)
|
||||
kprintf("\e[93msetlocale failed!\n");
|
||||
#if _WIN32 || _WIN64
|
||||
if(!SetConsoleOutputCP(CP_UTF8)){
|
||||
kprintf("\e[93mcan't set console codepage to utf8");
|
||||
}
|
||||
#endif
|
||||
if(setlocale(LC_ALL, "C.UTF8")==0){ // doesn't work on windows
|
||||
kprintf("\e[93msetlocale failed! (%i)\n", errno);
|
||||
}
|
||||
|
||||
kt_beginInit();
|
||||
kt_initKerepTypes();
|
||||
|
||||
@ -1,4 +1,10 @@
|
||||
#!/usr/bin/bash
|
||||
for tmpfile in $(ls .rebuild_*.tmp); do
|
||||
for tmpfile in $(ls -a | grep -e '\.rebuild.*\.tmp'); do
|
||||
try_delete_dir_or_file "$tmpfile"
|
||||
done
|
||||
|
||||
for submodule in kerep utf8proc; do
|
||||
cd "$submodule"
|
||||
make clean
|
||||
cd ..
|
||||
done
|
||||
|
||||
@ -1,17 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
# check if kerep static lib exists or kerep_rebuild task was executed
|
||||
if [ ! -f "$OBJDIR/libs/kerep.a" ] || [ -f .rebuild_kerep.tmp ]; then
|
||||
[[ -z "$KEREP_BUILD_TASK" ]] && error "KEREP_BUILD_TASK is empty"
|
||||
myprint "${BLUE}making kerep task <$KEREP_BUILD_TASK>"
|
||||
# if $lib_project.a doesn't exist or rebuild_* task was executed, builds static lib
|
||||
function handle_static_dependency {
|
||||
local lib_project="$1"
|
||||
local lib_build_task="$2"
|
||||
local lib_build_rezults="$3"
|
||||
if [ ! -f "$OBJDIR/libs/$lib_project.a" ] || [ -f .rebuild_$lib_project.tmp ]; then
|
||||
[[ -z "$lib_build_task" ]] && error "lib_build_task is empty"
|
||||
myprint "${BLUE}making $lib_project task <$lib_build_task>"
|
||||
|
||||
cd kerep
|
||||
if ! make "$KEREP_BUILD_TASK"; then
|
||||
exit 1
|
||||
cd $lib_project
|
||||
if ! make "$lib_build_task"; then
|
||||
exit 1
|
||||
fi
|
||||
cd ..
|
||||
|
||||
cp $lib_build_rezults $OBJDIR/libs/
|
||||
myprint "${GREEN}copied ${CYAN}$lib_project.a"
|
||||
rm -f .rebuild_$lib_project.tmp
|
||||
fi
|
||||
cd ..
|
||||
}
|
||||
|
||||
cp kerep/bin/kerep.a $OBJDIR/libs/
|
||||
myprint "${GREEN}copied ${CYAN}kerep.a"
|
||||
rm -f .rebuild_kerep.tmp
|
||||
fi
|
||||
handle_static_dependency kerep "$DEPS_BUILD_TASK" kerep/bin/kerep.a
|
||||
handle_static_dependency utf8proc libutf8proc.a utf8proc/libutf8proc.a
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
#!/bin/bash
|
||||
touch .rebuild_kerep.tmp
|
||||
myprint "${YELLOW}kerep.a will be rebuilt in the next build task"
|
||||
5
tasks/rebuild_lib.sh
Normal file
5
tasks/rebuild_lib.sh
Normal file
@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
source cbuild/colors.sh
|
||||
source cbuild/functions.sh
|
||||
touch ".rebuild_$1.tmp"
|
||||
myprint "${YELLOW}$1.a will be rebuilt in the next build task"
|
||||
1
utf8proc
Submodule
1
utf8proc
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 4b6219095bd0940a0561a35317c3a5e08570acd5
|
||||
Loading…
Reference in New Issue
Block a user