kprint massive rename
This commit is contained in:
parent
9d5dac93de
commit
ab761aa395
@ -4,14 +4,14 @@
|
|||||||
|
|
||||||
char* __toString_char(void* c, uint32 fmt) {
|
char* __toString_char(void* c, uint32 fmt) {
|
||||||
//*c=char
|
//*c=char
|
||||||
if(kprint_format_dataFormat(fmt)==kprint_fmtChar){
|
if(kp_fmt_dataFormat(fmt)==kp_c){
|
||||||
char* cc=malloc(2);
|
char* cc=malloc(2);
|
||||||
cc[0]=*(char*)c;
|
cc[0]=*(char*)c;
|
||||||
cc[1]=0;
|
cc[1]=0;
|
||||||
return cc;
|
return cc;
|
||||||
}
|
}
|
||||||
// *c=cstring
|
// *c=cstring
|
||||||
else if(kprint_format_dataFormat(fmt)==kprint_fmtString){
|
else if(kp_fmt_dataFormat(fmt)==kp_s){
|
||||||
return cptr_copy(*(char**)c);
|
return cptr_copy(*(char**)c);
|
||||||
}
|
}
|
||||||
else throw(ERR_FORMAT);
|
else throw(ERR_FORMAT);
|
||||||
@ -19,7 +19,7 @@ char* __toString_char(void* c, uint32 fmt) {
|
|||||||
|
|
||||||
char* __toString_bool(void* c, uint32 fmt) {
|
char* __toString_bool(void* c, uint32 fmt) {
|
||||||
static const char _strbool[4][6]={ "false", "true\0", "False", "True\0" };
|
static const char _strbool[4][6]={ "false", "true\0", "False", "True\0" };
|
||||||
uint8 strind=*(bool*)c==1 + kprint_format_isUppercase(fmt)*2;
|
uint8 strind=*(bool*)c==1 + kp_fmt_isUpper(fmt)*2;
|
||||||
char* rez=malloc(6);
|
char* rez=malloc(6);
|
||||||
rez[0]=_strbool[strind][0];
|
rez[0]=_strbool[strind][0];
|
||||||
rez[1]=_strbool[strind][1];
|
rez[1]=_strbool[strind][1];
|
||||||
@ -134,16 +134,16 @@ char* toString_hex(void* _bytes, uint32 size, bool withPrefix, bool uppercase){
|
|||||||
|
|
||||||
|
|
||||||
#define __toString_int_def(BITS) char* __toString_int##BITS(void* _n, uint32 f){\
|
#define __toString_int_def(BITS) char* __toString_int##BITS(void* _n, uint32 f){\
|
||||||
switch(kprint_format_dataFormat(f)){\
|
switch(kp_fmt_dataFormat(f)){\
|
||||||
case kprint_fmtInt: ;\
|
case kp_i: ;\
|
||||||
int##BITS n=*(int##BITS*)_n;\
|
int##BITS n=*(int##BITS*)_n;\
|
||||||
return toString_int(n);\
|
return toString_int(n);\
|
||||||
case kprint_fmtBin:\
|
case kp_b:\
|
||||||
return toString_bin(_n, BITS/8, kprint_format_isWithPrefix(f));\
|
return toString_bin(_n, BITS/8, kp_fmt_withPrefix(f));\
|
||||||
case kprint_fmtHex:\
|
case kp_h:\
|
||||||
return toString_hex(_n, BITS/8, kprint_format_isWithPrefix(f), kprint_format_isUppercase(f));\
|
return toString_hex(_n, BITS/8, kp_fmt_withPrefix(f), kp_fmt_isUpper(f));\
|
||||||
default:\
|
default:\
|
||||||
kprintf("\n%u\n", kprint_format_dataFormat(f));\
|
kprintf("\n%u\n", kp_fmt_dataFormat(f));\
|
||||||
throw(ERR_FORMAT);\
|
throw(ERR_FORMAT);\
|
||||||
return NULL;\
|
return NULL;\
|
||||||
}\
|
}\
|
||||||
@ -154,16 +154,16 @@ __toString_int_def(32)
|
|||||||
__toString_int_def(64)
|
__toString_int_def(64)
|
||||||
|
|
||||||
#define __toString_uint_def(BITS) char* __toString_uint##BITS(void* _n, uint32 f){\
|
#define __toString_uint_def(BITS) char* __toString_uint##BITS(void* _n, uint32 f){\
|
||||||
switch(kprint_format_dataFormat(f)){\
|
switch(kp_fmt_dataFormat(f)){\
|
||||||
case kprint_fmtUInt: ;\
|
case kp_u: ;\
|
||||||
uint##BITS n=*(uint##BITS*)_n;\
|
uint##BITS n=*(uint##BITS*)_n;\
|
||||||
return toString_uint(n, kprint_format_isWithPostfix(f), kprint_format_isUppercase(f));\
|
return toString_uint(n, kp_fmt_withPostfix(f), kp_fmt_isUpper(f));\
|
||||||
case kprint_fmtBin:\
|
case kp_b:\
|
||||||
return toString_bin(_n, BITS/8, kprint_format_isWithPrefix(f));\
|
return toString_bin(_n, BITS/8, kp_fmt_withPrefix(f));\
|
||||||
case kprint_fmtHex:\
|
case kp_h:\
|
||||||
return toString_hex(_n, BITS/8, kprint_format_isWithPrefix(f), kprint_format_isUppercase(f));\
|
return toString_hex(_n, BITS/8, kp_fmt_withPrefix(f), kp_fmt_isUpper(f));\
|
||||||
default:\
|
default:\
|
||||||
kprintf("\n%u\n", kprint_format_dataFormat(f));\
|
kprintf("\n%u\n", kp_fmt_dataFormat(f));\
|
||||||
throw(ERR_FORMAT);\
|
throw(ERR_FORMAT);\
|
||||||
return NULL;\
|
return NULL;\
|
||||||
}\
|
}\
|
||||||
@ -174,16 +174,16 @@ __toString_uint_def(32)
|
|||||||
__toString_uint_def(64)
|
__toString_uint_def(64)
|
||||||
|
|
||||||
#define __toString_float_def(BITS) char* __toString_float##BITS(void* _n, uint32 f){\
|
#define __toString_float_def(BITS) char* __toString_float##BITS(void* _n, uint32 f){\
|
||||||
switch(kprint_format_dataFormat(f)){\
|
switch(kp_fmt_dataFormat(f)){\
|
||||||
case kprint_fmtFloat: ;\
|
case kp_f: ;\
|
||||||
float##BITS n=*(float##BITS*)_n;\
|
float##BITS n=*(float##BITS*)_n;\
|
||||||
return toString_float(n, kprint_format_isWithPostfix(f), kprint_format_isUppercase(f));\
|
return toString_float(n, kp_fmt_withPostfix(f), kp_fmt_isUpper(f));\
|
||||||
case kprint_fmtBin:\
|
case kp_b:\
|
||||||
return toString_bin(_n, BITS/8, kprint_format_isWithPrefix(f));\
|
return toString_bin(_n, BITS/8, kp_fmt_withPrefix(f));\
|
||||||
case kprint_fmtHex:\
|
case kp_h:\
|
||||||
return toString_hex(_n, BITS/8, kprint_format_isWithPrefix(f), kprint_format_isUppercase(f));\
|
return toString_hex(_n, BITS/8, kp_fmt_withPrefix(f), kp_fmt_isUpper(f));\
|
||||||
default:\
|
default:\
|
||||||
kprintf("\n%u\n", kprint_format_dataFormat(f));\
|
kprintf("\n%u\n", kp_fmt_dataFormat(f));\
|
||||||
throw(ERR_FORMAT);\
|
throw(ERR_FORMAT);\
|
||||||
return NULL;\
|
return NULL;\
|
||||||
}\
|
}\
|
||||||
|
|||||||
@ -11,7 +11,7 @@ Unlike in standard printf, `%l...` and `%ll...` placeholders dont depend on size
|
|||||||
| float32 / float64 | %f |
|
| float32 / float64 | %f |
|
||||||
| char | %c |
|
| char | %c |
|
||||||
| char[] | %s |
|
| char[] | %s |
|
||||||
| void* | %p / %x |
|
| void\* | %p / %x |
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
@ -20,31 +20,31 @@ I don't really like printf function (and its variants), so i made safer and more
|
|||||||
|
|
||||||
| function | returns | arguments |
|
| function | returns | arguments |
|
||||||
|----------|---------|-----------|
|
|----------|---------|-----------|
|
||||||
| kprint | void/throw | kprint_format, void*, kprint_format, void*... |
|
| kprint | void/throw | kp_fmt, void\*, kp_fmt, void\*... |
|
||||||
| ksprint | Maybe<char*> | kprint_format, void*, kprint_format, void*... |
|
| ksprint | Maybe<char\*>| kp_fmt, void\*, kp_fmt, void\*... |
|
||||||
| kfprint | Maybe<void> | FILE*, kprint_format, void*, kprint_format, void*... |
|
| kfprint | Maybe<void> | FILE\*, kp_fmt, void\*, kp_fmt, void\*... |
|
||||||
|
|
||||||
## how to use it:
|
## how to use it:
|
||||||
+ **format construction:**
|
+ **format construction:**
|
||||||
```
|
```
|
||||||
kprint_format fmt= kprint_fgColor | kprint_bgColor | kprint_fdataFmt | flags | ktid;
|
kp_fmt fmt= kp_fgColor | kp_bgColor | kprint_fdataFmt | flags | ktid;
|
||||||
```
|
```
|
||||||
[more about `kprint_format`](kprint_format.md)
|
[more about `kp_fmt`](kp_fmt.md)
|
||||||
+ fgColor and bgColor can be set to change console output color
|
+ fgColor and bgColor can be set to change console output color
|
||||||
+ you should set dataFormat for `int`/`uint`/`float`/`char*` arguments and ktid for other types
|
+ you should set dataFormat for `int`/`uint`/`float`/`char\*` arguments and ktid for other types
|
||||||
+ flags can be set to modify TypeDescriptor.toString() behavior
|
+ flags can be set to modify TypeDescriptor.toString() behavior
|
||||||
+ don't forget to set TypeDescriptor.toString when registering type, or kprint will crash
|
+ don't forget to set TypeDescriptor.toString when registering type, or kprint will crash
|
||||||
|
|
||||||
+ **using base type arguments:**
|
+ **using base type arguments:**
|
||||||
you can just put them into a function
|
you can just put them into a function
|
||||||
```
|
```
|
||||||
kprint(kprint_fmtHex | kprint_fmtUppercase | kprint_fmtWithPrefix, 255);
|
kprint(kp_h|kp_upper|kp_prefix, 255);
|
||||||
```
|
```
|
||||||
output: 0xFF
|
output: 0xFF
|
||||||
+ **using other registered types:**
|
+ **using other registered types:**
|
||||||
should be sent as pointers
|
should be sent as pointers
|
||||||
```
|
```
|
||||||
Maybe m=MaybeNull;
|
Maybe m=MaybeNull;
|
||||||
kprint(kprint_fgBlue | kprint_fmtString, "Maybe: ", kprint_fgGreen | ktid_MaybePtr, &m);
|
kprint(kp_fgBlue|kp_s, "Maybe: ", kp_fgGreen|ktid_MaybePtr, &m);
|
||||||
```
|
```
|
||||||
output: <span style="color:blue">Maybe:</span> <span style="color:lightgreen">{value={0, ktid_Null}}</span>
|
output: <span style="color:blue">Maybe:</span> <span style="color:lightgreen">{value={0, ktid_Null}}</span>
|
||||||
|
|||||||
@ -1,29 +1,29 @@
|
|||||||
#include "../String/StringBuilder.h"
|
#include "../String/StringBuilder.h"
|
||||||
#include "kprint.h"
|
#include "kprint.h"
|
||||||
|
|
||||||
ktid __typeFromFormat(kprint_format f){
|
ktid __typeFromFormat(kp_fmt f){
|
||||||
ktid typeId=kprint_format_ktid(f);
|
ktid typeId=kp_fmt_ktid(f);
|
||||||
if(typeId)
|
if(typeId)
|
||||||
return typeId;
|
return typeId;
|
||||||
switch(kprint_format_dataFormat(f)){
|
switch(kp_fmt_dataFormat(f)){
|
||||||
case kprint_fmtInt:
|
case kp_i:
|
||||||
case kprint_fmtHex:
|
case kp_h:
|
||||||
case kprint_fmtBin:
|
case kp_b:
|
||||||
return ktid_name(int64);
|
return ktid_name(int64);
|
||||||
case kprint_fmtUInt:
|
case kp_u:
|
||||||
return ktid_name(uint64);
|
return ktid_name(uint64);
|
||||||
case kprint_fmtFloat:
|
case kp_f:
|
||||||
return ktid_name(float64);
|
return ktid_name(float64);
|
||||||
case kprint_fmtChar:
|
case kp_c:
|
||||||
return ktid_char;
|
return ktid_char;
|
||||||
case kprint_fmtString:
|
case kp_s:
|
||||||
return ktid_ptrName(char);
|
return ktid_ptrName(char);
|
||||||
default:
|
default:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Maybe __next_toString(kprint_format f, __kprint_value_union* object){
|
Maybe __next_toString(kp_fmt f, __kp_value_union* object){
|
||||||
// detecting type
|
// detecting type
|
||||||
ktid typeId=__typeFromFormat(f);
|
ktid typeId=__typeFromFormat(f);
|
||||||
if(typeId==-1)
|
if(typeId==-1)
|
||||||
@ -34,7 +34,7 @@ Maybe __next_toString(kprint_format f, __kprint_value_union* object){
|
|||||||
return SUCCESS(UniHeapPtr(char, typeDesc.toString(object, f)));
|
return SUCCESS(UniHeapPtr(char, typeDesc.toString(object, f)));
|
||||||
}
|
}
|
||||||
|
|
||||||
Maybe __ksprint(uint8 n, kprint_format* formats, __kprint_value_union* objects){
|
Maybe __ksprint(uint8 n, kp_fmt* formats, __kp_value_union* objects){
|
||||||
n/=2;
|
n/=2;
|
||||||
StringBuilder* strb=StringBuilder_create();
|
StringBuilder* strb=StringBuilder_create();
|
||||||
for(uint8 i=0; i<n; i++){
|
for(uint8 i=0; i<n; i++){
|
||||||
@ -46,7 +46,7 @@ Maybe __ksprint(uint8 n, kprint_format* formats, __kprint_value_union* objects){
|
|||||||
return SUCCESS(UniHeapPtr(char, rezult));
|
return SUCCESS(UniHeapPtr(char, rezult));
|
||||||
}
|
}
|
||||||
|
|
||||||
Maybe __kfprint(FILE* file, uint8 n, kprint_format* formats, __kprint_value_union* objects){
|
Maybe __kfprint(FILE* file, uint8 n, kp_fmt* formats, __kp_value_union* objects){
|
||||||
n/=2;
|
n/=2;
|
||||||
for(uint8 i=0; i<n; i++){
|
for(uint8 i=0; i<n; i++){
|
||||||
try(__next_toString(formats[i], &objects[i]),maybeStr,;);
|
try(__next_toString(formats[i], &objects[i]),maybeStr,;);
|
||||||
@ -58,10 +58,10 @@ Maybe __kfprint(FILE* file, uint8 n, kprint_format* formats, __kprint_value_unio
|
|||||||
return MaybeNull;
|
return MaybeNull;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __kprint(uint8 n, kprint_format* formats, __kprint_value_union* objects){
|
void __kprint(uint8 n, kp_fmt* formats, __kp_value_union* objects){
|
||||||
n/=2;
|
n/=2;
|
||||||
for(uint8 i=0; i<n; i++){
|
for(uint8 i=0; i<n; i++){
|
||||||
kprint_format fmt=formats[i];
|
kp_fmt fmt=formats[i];
|
||||||
kprint_setColor(fmt);
|
kprint_setColor(fmt);
|
||||||
tryLast(__next_toString(fmt, &objects[i]),maybeStr);
|
tryLast(__next_toString(fmt, &objects[i]),maybeStr);
|
||||||
if(fputs(maybeStr.value.VoidPtr, stdout)==EOF)\
|
if(fputs(maybeStr.value.VoidPtr, stdout)==EOF)\
|
||||||
@ -76,72 +76,72 @@ void __kprint(uint8 n, kprint_format* formats, __kprint_value_union* objects){
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#define FOREGROUND_YELLOW FOREGROUND_GREEN | FOREGROUND_RED
|
#define FOREGROUND_YELLOW FOREGROUND_GREEN | FOREGROUND_RED
|
||||||
|
|
||||||
DWORD kprint_fgColor_toWin(kprint_fgColor f){
|
DWORD kp_fgColor_toWin(kp_fgColor f){
|
||||||
//kprintf("fg: %x\n", f);
|
//kprintf("fg: %x\n", f);
|
||||||
switch(f){
|
switch(f){
|
||||||
case kprint_fgBlack: return 0;
|
case kp_fgBlack: return 0;
|
||||||
case kprint_fgDarkRed: return FOREGROUND_RED;
|
case kp_fgRedD: return FOREGROUND_RED;
|
||||||
case kprint_fgDarkGreen: return FOREGROUND_GREEN;
|
case kp_fgGreenD: return FOREGROUND_GREEN;
|
||||||
case kprint_fgDarkYellow: return FOREGROUND_GREEN | FOREGROUND_RED;
|
case kp_fgYellowD: return FOREGROUND_GREEN | FOREGROUND_RED;
|
||||||
case kprint_fgDarkBlue: return FOREGROUND_BLUE;
|
case kp_fgBlueD: return FOREGROUND_BLUE;
|
||||||
case kprint_fgDarkMagenta: return FOREGROUND_RED | FOREGROUND_BLUE;
|
case kp_fgMagentaD: return FOREGROUND_RED | FOREGROUND_BLUE;
|
||||||
case kprint_fgDarkCyan: return FOREGROUND_BLUE | FOREGROUND_GREEN;
|
case kp_fgCyanD: return FOREGROUND_BLUE | FOREGROUND_GREEN;
|
||||||
case kprint_fgGray: return FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED;
|
case kp_fgGray: return FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED;
|
||||||
case kprint_fgDarkGray: return FOREGROUND_INTENSITY;
|
case kp_fgGrayD: return FOREGROUND_INTENSITY;
|
||||||
case kprint_fgRed: return FOREGROUND_RED | FOREGROUND_INTENSITY;
|
case kp_fgRed: return FOREGROUND_RED | FOREGROUND_INTENSITY;
|
||||||
case kprint_fgGreen: return FOREGROUND_GREEN | FOREGROUND_INTENSITY;
|
case kp_fgGreen: return FOREGROUND_GREEN | FOREGROUND_INTENSITY;
|
||||||
case kprint_fgYellow: return FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY;
|
case kp_fgYellow: return FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY;
|
||||||
case kprint_fgBlue: return FOREGROUND_BLUE | FOREGROUND_INTENSITY;
|
case kp_fgBlue: return FOREGROUND_BLUE | FOREGROUND_INTENSITY;
|
||||||
case kprint_fgMagenta: return FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY;
|
case kp_fgMagenta: return FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY;
|
||||||
case kprint_fgCyan: return FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY;
|
case kp_fgCyan: return FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY;
|
||||||
case kprint_fgWhite: return FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY;
|
case kp_fgWhite: return FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY;
|
||||||
default: throw(ERR_FORMAT);
|
default: throw(ERR_FORMAT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD kprint_bgColor_toWin(kprint_bgColor f){
|
DWORD kp_bgColor_toWin(kp_bgColor f){
|
||||||
//kprintf("bg: %x\n", f);
|
//kprintf("bg: %x\n", f);
|
||||||
switch(f){
|
switch(f){
|
||||||
case kprint_bgBlack: return 0;
|
case kp_bgBlack: return 0;
|
||||||
case kprint_bgDarkRed: return BACKGROUND_RED;
|
case kp_bgRedD: return BACKGROUND_RED;
|
||||||
case kprint_bgDarkGreen: return BACKGROUND_GREEN;
|
case kp_bgGreenD: return BACKGROUND_GREEN;
|
||||||
case kprint_bgDarkYellow: return BACKGROUND_GREEN | BACKGROUND_RED;
|
case kp_bgYellowD: return BACKGROUND_GREEN | BACKGROUND_RED;
|
||||||
case kprint_bgDarkBlue: return BACKGROUND_BLUE;
|
case kp_bgBlueD: return BACKGROUND_BLUE;
|
||||||
case kprint_bgDarkMagenta: return BACKGROUND_RED | BACKGROUND_BLUE;
|
case kp_bgMagentaD: return BACKGROUND_RED | BACKGROUND_BLUE;
|
||||||
case kprint_bgDarkCyan: return BACKGROUND_BLUE | BACKGROUND_GREEN;
|
case kp_bgCyanD: return BACKGROUND_BLUE | BACKGROUND_GREEN;
|
||||||
case kprint_bgGray: return BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED;
|
case kp_bgGray: return BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED;
|
||||||
case kprint_bgDarkGray: return BACKGROUND_INTENSITY;
|
case kp_bgGrayD: return BACKGROUND_INTENSITY;
|
||||||
case kprint_bgRed: return BACKGROUND_RED | BACKGROUND_INTENSITY;
|
case kp_bgRed: return BACKGROUND_RED | BACKGROUND_INTENSITY;
|
||||||
case kprint_bgGreen: return BACKGROUND_GREEN | BACKGROUND_INTENSITY;
|
case kp_bgGreen: return BACKGROUND_GREEN | BACKGROUND_INTENSITY;
|
||||||
case kprint_bgYellow: return BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY;
|
case kp_bgYellow: return BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY;
|
||||||
case kprint_bgBlue: return BACKGROUND_BLUE | BACKGROUND_INTENSITY;
|
case kp_bgBlue: return BACKGROUND_BLUE | BACKGROUND_INTENSITY;
|
||||||
case kprint_bgMagenta: return BACKGROUND_BLUE | BACKGROUND_RED | BACKGROUND_INTENSITY;
|
case kp_bgMagenta: return BACKGROUND_BLUE | BACKGROUND_RED | BACKGROUND_INTENSITY;
|
||||||
case kprint_bgCyan: return BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_INTENSITY;
|
case kp_bgCyan: return BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_INTENSITY;
|
||||||
case kprint_bgWhite: return BACKGROUND_RED | BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_INTENSITY;
|
case kp_bgWhite: return BACKGROUND_RED | BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_INTENSITY;
|
||||||
default: throw(ERR_FORMAT);
|
default: throw(ERR_FORMAT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void kprint_setColor(kprint_format f){
|
void kprint_setColor(kp_fmt f){
|
||||||
DWORD color=0;
|
DWORD color=0;
|
||||||
if(!kprint_format_isFgColorChanged(f) & !kprint_format_isBgColorChanged(f))
|
if(!kp_fmt_fgColorSet(f) & !kp_fmt_bgColorSet(f))
|
||||||
return;
|
return;
|
||||||
if(kprint_format_isFgColorChanged(f))
|
if(kp_fmt_fgColorSet(f))
|
||||||
color+=kprint_fgColor_toWin(kprint_format_fgColor(f));
|
color+=kp_fgColor_toWin(kp_fmt_fgColor(f));
|
||||||
if(kprint_format_isBgColorChanged(f))
|
if(kp_fmt_bgColorSet(f))
|
||||||
color+=kprint_bgColor_toWin(kprint_format_bgColor(f));
|
color+=kp_bgColor_toWin(kp_fmt_bgColor(f));
|
||||||
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
|
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
SetConsoleTextAttribute(hConsole, color);
|
SetConsoleTextAttribute(hConsole, color);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
void kprint_setColor(kprint_format f){
|
void kprint_setColor(kp_fmt f){
|
||||||
if(kprint_format_isFgColorChanged(f)){
|
if(kp_fmt_fgColorSet(f)){
|
||||||
uint8 fg=(f&0x0f000000)>>24;
|
uint8 fg=(f&0x0f000000)>>24;
|
||||||
if(fg<8) fg+=30;
|
if(fg<8) fg+=30;
|
||||||
else fg+=90-8;
|
else fg+=90-8;
|
||||||
printf("\e[%um", fg);
|
printf("\e[%um", fg);
|
||||||
}
|
}
|
||||||
if(kprint_format_isBgColorChanged(f)){
|
if(kp_fmt_bgColorSet(f)){
|
||||||
uint8 bg=(f&0x00f00000)>>20;
|
uint8 bg=(f&0x00f00000)>>20;
|
||||||
if(bg<8) bg+=40;
|
if(bg<8) bg+=40;
|
||||||
else bg+=100-8;
|
else bg+=100-8;
|
||||||
@ -150,7 +150,7 @@ void kprint_setColor(kprint_format f){
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Maybe ksprint_ar(uint32 count, kprint_format format, ktid typeId, void* array){
|
/* Maybe ksprint_ar(uint32 count, kp_fmt format, ktid typeId, void* array){
|
||||||
ktDescriptor typeDesc=ktDescriptor_get(format.typeId);
|
ktDescriptor typeDesc=ktDescriptor_get(format.typeId);
|
||||||
if(!typeDesc.toString)
|
if(!typeDesc.toString)
|
||||||
safethrow("type descriptor doesnt have toString() func",;);
|
safethrow("type descriptor doesnt have toString() func",;);
|
||||||
|
|||||||
@ -8,76 +8,91 @@ extern "C" {
|
|||||||
#include "kprint_colors.h"
|
#include "kprint_colors.h"
|
||||||
#include "kprint_format.h"
|
#include "kprint_format.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
This file looks like a mess, but all cotnent here just solves the problem of putting variadic arguments to array of formats and array of objects.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
typedef union {
|
typedef union {
|
||||||
int64 i64;
|
int64 i64;
|
||||||
uint64 u64;
|
uint64 u64;
|
||||||
float64 f64;
|
float64 f64;
|
||||||
void* ptr;
|
void* ptr;
|
||||||
} __kprint_value_union;
|
} __kp_value_union;
|
||||||
#define __kprintVU(value) (__kprint_value_union){ value }
|
#define __kpVU(value) (__kp_value_union){ value }
|
||||||
|
|
||||||
#define __kprint_argsToFormats8(\
|
#define __kp_argsToFmts8(\
|
||||||
a0, a1, a2, a3, a4, a5, a6, a7,...)\
|
a0, a1, a2, a3, a4, a5, a6, a7,...)\
|
||||||
((int32[]){ a0,a2,a4,a6 })
|
((int32[]){ a0,a2,a4,a6 })
|
||||||
#define __kprint_argsToObjects8(\
|
#define __kp_argsToObjs8(\
|
||||||
a0, a1, a2, a3, a4, a5, a6, a7,...)\
|
a0, a1, a2, a3, a4, a5, a6, a7,...)\
|
||||||
((__kprint_value_union[]){ __kprintVU(a1),__kprintVU(a3),__kprintVU(a5),__kprintVU(a7) })
|
((__kp_value_union[]){ __kpVU(a1),__kpVU(a3),__kpVU(a5),__kpVU(a7) })
|
||||||
|
|
||||||
#define __kprint_argsToFormats16(\
|
#define __kp_argsToFmts16(\
|
||||||
a0, a1, a2, a3, a4, a5, a6, a7,\
|
a0, a1, a2, a3, a4, a5, a6, a7,\
|
||||||
a8, a9, a10,a11,a12,a13,a14,a15,...)\
|
a8, a9, a10,a11,a12,a13,a14,a15,...)\
|
||||||
((int32[]){ a0,a2,a4,a6,a8,a10,a12,a14 })
|
((int32[]){ a0,a2,a4,a6,a8,a10,a12,a14 })
|
||||||
#define __kprint_argsToObjects16(\
|
#define __kp_argsToObjs16(\
|
||||||
a0, a1, a2, a3, a4, a5, a6, a7,\
|
a0, a1, a2, a3, a4, a5, a6, a7,\
|
||||||
a8, a9, a10,a11,a12,a13,a14,a15,...)\
|
a8, a9, a10,a11,a12,a13,a14,a15,...)\
|
||||||
((__kprint_value_union[]){ __kprintVU(a1),__kprintVU(a3),__kprintVU(a5),__kprintVU(a7),__kprintVU(a9),__kprintVU(a11),__kprintVU(a13),__kprintVU(a15) })
|
((__kp_value_union[]){ __kpVU(a1),__kpVU(a3),__kpVU(a5),__kpVU(a7),__kpVU(a9),__kpVU(a11),__kpVU(a13),__kpVU(a15) })
|
||||||
|
|
||||||
#define __kprint_argsToFormats32(\
|
#define __kp_argsToFmts32(\
|
||||||
a0, a1, a2, a3, a4, a5, a6, a7,\
|
a0, a1, a2, a3, a4, a5, a6, a7,\
|
||||||
a8, a9, a10,a11,a12,a13,a14,a15,\
|
a8, a9, a10,a11,a12,a13,a14,a15,\
|
||||||
a16,a17,a18,a19,a20,a21,a22,a23,\
|
a16,a17,a18,a19,a20,a21,a22,a23,\
|
||||||
a24,a25,a26,a27,a28,a29,a30,a31,...)\
|
a24,a25,a26,a27,a28,a29,a30,a31,...)\
|
||||||
((int32[]){ a0,a2,a4,a6,a8,a10,a12,a14,a16,a18,a20,a22,a24,a26,a28,a30 })
|
((int32[]){ a0,a2,a4,a6,a8,a10,a12,a14,a16,a18,a20,a22,a24,a26,a28,a30 })
|
||||||
#define __kprint_argsToObjects32(\
|
#define __kp_argsToObjs32(\
|
||||||
a0, a1, a2, a3, a4, a5, a6, a7,\
|
a0, a1, a2, a3, a4, a5, a6, a7,\
|
||||||
a8, a9, a10,a11,a12,a13,a14,a15,\
|
a8, a9, a10,a11,a12,a13,a14,a15,\
|
||||||
a16,a17,a18,a19,a20,a21,a22,a23,\
|
a16,a17,a18,a19,a20,a21,a22,a23,\
|
||||||
a24,a25,a26,a27,a28,a29,a30,a31,...)\
|
a24,a25,a26,a27,a28,a29,a30,a31,...)\
|
||||||
((__kprint_value_union[]){ __kprintVU(a1),__kprintVU(a3),__kprintVU(a5),__kprintVU(a7),__kprintVU(a9),__kprintVU(a11),__kprintVU(a13),__kprintVU(a15),__kprintVU(a17),__kprintVU(a19),__kprintVU(a21),__kprintVU(a23),__kprintVU(a25),__kprintVU(a27),__kprintVU(a29),__kprintVU(a31) })
|
((__kp_value_union[]){ __kpVU(a1),__kpVU(a3),__kpVU(a5),__kpVU(a7),__kpVU(a9),__kpVU(a11),__kpVU(a13),__kpVU(a15),__kpVU(a17),__kpVU(a19),__kpVU(a21),__kpVU(a23),__kpVU(a25),__kpVU(a27),__kpVU(a29),__kpVU(a31) })
|
||||||
|
|
||||||
#define __32zeroes 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
#define __32zeroes 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||||
|
|
||||||
#define __kprint_argsToArrs(COUNT,ARGS...)\
|
#define __kp_argsToArrs(COUNT,ARGS...)\
|
||||||
(kprint_format*)(COUNT<=8 ? __kprint_argsToFormats8(ARGS) :\
|
(kp_fmt*)(\
|
||||||
COUNT<=16 ? __kprint_argsToFormats16(ARGS) :\
|
COUNT<=8 ? __kp_argsToFmts8(ARGS) :\
|
||||||
__kprint_argsToFormats32(ARGS)),\
|
COUNT<=16 ? __kp_argsToFmts16(ARGS) :\
|
||||||
(__kprint_value_union*)(COUNT<=8 ? __kprint_argsToObjects8(ARGS) :\
|
__kp_argsToFmts32(ARGS)),\
|
||||||
COUNT<=16 ? __kprint_argsToObjects16(ARGS) :\
|
(__kp_value_union*)(\
|
||||||
__kprint_argsToObjects32(ARGS))
|
COUNT<=8 ? __kp_argsToObjs8(ARGS) :\
|
||||||
|
COUNT<=16 ? __kp_argsToObjs16(ARGS) :\
|
||||||
|
__kp_argsToObjs32(ARGS))
|
||||||
|
|
||||||
|
|
||||||
Maybe __ksprint(uint8 n, kprint_format* formats, __kprint_value_union* objects);
|
Maybe __ksprint(uint8 n, kp_fmt* formats, __kp_value_union* objects);
|
||||||
|
|
||||||
|
/// @param ARGS kp_fmt, value, kp_fmt, value...
|
||||||
|
///@returns Maybe<char*>
|
||||||
#define ksprint(ARGS...) WARNING_DISABLE( W_INT_CONVERSION,\
|
#define ksprint(ARGS...) WARNING_DISABLE( W_INT_CONVERSION,\
|
||||||
__ksprint(count_args(ARGS), __kprint_argsToArrs(count_args(ARGS),ARGS, __32zeroes))\
|
__ksprint(count_args(ARGS), __kp_argsToArrs(count_args(ARGS),ARGS, __32zeroes))\
|
||||||
)
|
)
|
||||||
|
/*-Wint-conversion warning was produced during value to __kp_value_union conversion*/
|
||||||
|
|
||||||
Maybe __kfprint(FILE* fd, uint8 n, kprint_format* formats, __kprint_value_union* objects);
|
Maybe __kfprint(FILE* fd, uint8 n, kp_fmt* formats, __kp_value_union* objects);
|
||||||
|
|
||||||
|
/// @param FD FILE*
|
||||||
|
/// @param ARGS kp_fmt, value, kp_fmt, value...
|
||||||
|
///@returns Maybe<void>
|
||||||
#define kfprint(FD, ARGS...) WARNING_DISABLE( W_INT_CONVERSION,\
|
#define kfprint(FD, ARGS...) WARNING_DISABLE( W_INT_CONVERSION,\
|
||||||
__kfprint(FD, count_args(ARGS), __kprint_argsToArrs(count_args(ARGS),ARGS, __32zeroes))\
|
__kfprint(FD, count_args(ARGS), __kp_argsToArrs(count_args(ARGS),ARGS, __32zeroes))\
|
||||||
)
|
)
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
void __kprint(uint8 n, kp_fmt* formats, __kp_value_union* objects);
|
||||||
#pragma GCC diagnostic ignored "-Wint-conversion"
|
|
||||||
void __kprint(uint8 n, kprint_format* formats, __kprint_value_union* objects);
|
///can use non-catchable throw !!!
|
||||||
|
///@param ARGS kp_fmt, value, kp_fmt, value...
|
||||||
|
///@returns void
|
||||||
#define kprint(ARGS...) WARNING_DISABLE( W_INT_CONVERSION,\
|
#define kprint(ARGS...) WARNING_DISABLE( W_INT_CONVERSION,\
|
||||||
__kprint(count_args(ARGS), __kprint_argsToArrs(count_args(ARGS),ARGS, __32zeroes))\
|
__kprint(count_args(ARGS), __kp_argsToArrs(count_args(ARGS),ARGS, __32zeroes))\
|
||||||
)
|
)
|
||||||
|
|
||||||
|
///@param f bgColor | fgColor
|
||||||
#pragma GCC diagnostic pop
|
void kprint_setColor(kp_fmt f);
|
||||||
|
|
||||||
// can take (bgColor | fgColor)
|
|
||||||
void kprint_setColor(kprint_format f);
|
|
||||||
|
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,51 +4,82 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef enum kprint_fgColor{
|
// 10000000 00000000 00000000 00000000
|
||||||
// 10000000 00000000 00000000 00000000
|
// ^ ^^^^
|
||||||
// ^ ^^^^
|
// | color num
|
||||||
// | color num
|
// fgColorSet flag
|
||||||
// fgColorChanged flag
|
typedef enum kp_fgColor{
|
||||||
|
/// black foreground
|
||||||
|
kp_fgBlack = 0x80000000,
|
||||||
|
/// dark red foreground
|
||||||
|
kp_fgRedD = 0x81000000,
|
||||||
|
/// dark green foreground
|
||||||
|
kp_fgGreenD = 0x82000000,
|
||||||
|
/// dark yellow foreground
|
||||||
|
kp_fgYellowD = 0x83000000,
|
||||||
|
/// dark blue foreground
|
||||||
|
kp_fgBlueD = 0x84000000,
|
||||||
|
/// dark magenta foreground
|
||||||
|
kp_fgMagentaD= 0x85000000,
|
||||||
|
/// dark cyan foreground
|
||||||
|
kp_fgCyanD = 0x86000000,
|
||||||
|
/// gray foreground
|
||||||
|
kp_fgGray = 0x87000000,
|
||||||
|
/// dark gray foreground
|
||||||
|
kp_fgGrayD = 0x88000000,
|
||||||
|
/// red foreground
|
||||||
|
kp_fgRed = 0x89000000,
|
||||||
|
/// green foreground
|
||||||
|
kp_fgGreen = 0x8a000000,
|
||||||
|
/// yellow foreground
|
||||||
|
kp_fgYellow = 0x8b000000,
|
||||||
|
/// blue foreground
|
||||||
|
kp_fgBlue = 0x8c000000,
|
||||||
|
/// magenta foreground
|
||||||
|
kp_fgMagenta = 0x8d000000,
|
||||||
|
/// cyan foreground
|
||||||
|
kp_fgCyan = 0x8e000000,
|
||||||
|
/// white foreground
|
||||||
|
kp_fgWhite = 0x8f000000
|
||||||
|
} kp_fgColor;
|
||||||
|
|
||||||
kprint_fgBlack = 0x80000000,
|
// 01000000 00000000 00000000 00000000
|
||||||
kprint_fgDarkRed = 0x81000000,
|
// ^ ^^^^
|
||||||
kprint_fgDarkGreen = 0x82000000,
|
// bgColorSet flag color num
|
||||||
kprint_fgDarkYellow = 0x83000000,
|
typedef enum kp_bgColor{
|
||||||
kprint_fgDarkBlue = 0x84000000,
|
/// black background
|
||||||
kprint_fgDarkMagenta= 0x85000000,
|
kp_bgBlack = 0x40000000,
|
||||||
kprint_fgDarkCyan = 0x86000000,
|
/// dark red background
|
||||||
kprint_fgGray = 0x87000000,
|
kp_bgRedD = 0x40100000,
|
||||||
kprint_fgDarkGray = 0x88000000,
|
/// dark green background
|
||||||
kprint_fgRed = 0x89000000,
|
kp_bgGreenD = 0x40200000,
|
||||||
kprint_fgGreen = 0x8a000000,
|
/// dark yellow background
|
||||||
kprint_fgYellow = 0x8b000000,
|
kp_bgYellowD = 0x40300000,
|
||||||
kprint_fgBlue = 0x8c000000,
|
/// dark blue background
|
||||||
kprint_fgMagenta = 0x8d000000,
|
kp_bgBlueD = 0x40400000,
|
||||||
kprint_fgCyan = 0x8e000000,
|
/// dark magenta background
|
||||||
kprint_fgWhite = 0x8f000000
|
kp_bgMagentaD= 0x40500000,
|
||||||
} kprint_fgColor;
|
/// dark cyan background
|
||||||
|
kp_bgCyanD = 0x40600000,
|
||||||
typedef enum kprint_bgColor{
|
/// gray background
|
||||||
// 01000000 00000000 00000000 00000000
|
kp_bgGray = 0x40700000,
|
||||||
// ^ ^^^^
|
/// dark gray background
|
||||||
// bgColorChanged flag color num
|
kp_bgGrayD = 0x40800000,
|
||||||
kprint_bgBlack = 0x40000000,
|
/// red background
|
||||||
kprint_bgDarkRed = 0x40100000,
|
kp_bgRed = 0x40900000,
|
||||||
kprint_bgDarkGreen = 0x40200000,
|
/// green background
|
||||||
kprint_bgDarkYellow = 0x40300000,
|
kp_bgGreen = 0x40a00000,
|
||||||
kprint_bgDarkBlue = 0x40400000,
|
/// yellow background
|
||||||
kprint_bgDarkMagenta= 0x40500000,
|
kp_bgYellow = 0x40b00000,
|
||||||
kprint_bgDarkCyan = 0x40600000,
|
/// blue background
|
||||||
kprint_bgGray = 0x40700000,
|
kp_bgBlue = 0x40c00000,
|
||||||
kprint_bgDarkGray = 0x40800000,
|
/// magenta background
|
||||||
kprint_bgRed = 0x40900000,
|
kp_bgMagenta = 0x40d00000,
|
||||||
kprint_bgGreen = 0x40a00000,
|
/// cyan background
|
||||||
kprint_bgYellow = 0x40b00000,
|
kp_bgCyan = 0x40e00000,
|
||||||
kprint_bgBlue = 0x40c00000,
|
/// white background
|
||||||
kprint_bgMagenta = 0x40d00000,
|
kp_bgWhite = 0x40f00000
|
||||||
kprint_bgCyan = 0x40e00000,
|
} kp_bgColor;
|
||||||
kprint_bgWhite = 0x40f00000
|
|
||||||
} kprint_bgColor;
|
|
||||||
|
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,41 +7,42 @@ extern "C" {
|
|||||||
#include "../base/std.h"
|
#include "../base/std.h"
|
||||||
#include "../base/type_system/ktid.h"
|
#include "../base/type_system/ktid.h"
|
||||||
|
|
||||||
typedef enum kprint_dataFormat{
|
/// kprint_format
|
||||||
// 00000000 00000000 00000000 00000000
|
typedef uint32 kp_fmt;
|
||||||
// ^^^^
|
|
||||||
// type
|
|
||||||
kprint_fmtInt = 0x00000000,
|
|
||||||
kprint_fmtUInt = 0x00010000,
|
|
||||||
kprint_fmtHex = 0x00020000,
|
|
||||||
kprint_fmtBin = 0x00030000,
|
|
||||||
kprint_fmtFloat = 0x00040000,
|
|
||||||
kprint_fmtChar = 0x00050000,
|
|
||||||
kprint_fmtString = 0x00060000,
|
|
||||||
|
|
||||||
// 00100000 00000000 00000000 00000000
|
typedef enum kp_dataFmt{
|
||||||
// ^
|
// 00000000 00000000 00000000 00000000
|
||||||
// prefix/postfix flag
|
// ^^^^
|
||||||
kprint_fmtWithPrefix=0x20000000,
|
// type
|
||||||
kprint_fmtWithPostfix=kprint_fmtWithPrefix,
|
kp_i = 0x00000000,
|
||||||
|
kp_u = 0x00010000,
|
||||||
|
kp_h = 0x00020000,
|
||||||
|
kp_b = 0x00030000,
|
||||||
|
kp_f = 0x00040000,
|
||||||
|
kp_c = 0x00050000,
|
||||||
|
kp_s = 0x00060000,
|
||||||
|
|
||||||
// 00010000 00000000 00000000 00000000
|
// 00100000 00000000 00000000 00000000
|
||||||
// ^
|
// ^
|
||||||
// uppercase flag
|
// prefix/postfix flag
|
||||||
kprint_fmtUppercase=0x10000000
|
kp_pre=0x20000000,
|
||||||
} kprint_dataFormat;
|
kp_post=kp_pre,
|
||||||
|
|
||||||
typedef uint32 kprint_format;
|
// 00010000 00000000 00000000 00000000
|
||||||
|
// ^
|
||||||
|
// uppercase flag
|
||||||
|
kp_upper=0x10000000
|
||||||
|
} kp_dataFmt;
|
||||||
|
|
||||||
#define kprint_format_isFgColorChanged(FMT) (bool)((FMT&0x80000000)!=0)
|
#define kp_fmt_fgColorSet(FMT) (bool)((FMT&0x80000000)!=0)
|
||||||
#define kprint_format_isBgColorChanged(FMT) (bool)((FMT&0x40000000)!=0)
|
#define kp_fmt_bgColorSet(FMT) (bool)((FMT&0x40000000)!=0)
|
||||||
#define kprint_format_isWithPrefix(FMT) (bool)((FMT&kprint_fmtWithPrefix)!=0)
|
#define kp_fmt_withPrefix(FMT) (bool)((FMT&kp_pre)!=0)
|
||||||
#define kprint_format_isWithPostfix(FMT) (bool)((FMT&kprint_fmtWithPostfix)!=0)
|
#define kp_fmt_withPostfix(FMT) (bool)((FMT&kp_post)!=0)
|
||||||
#define kprint_format_isUppercase(FMT) (bool)((FMT&kprint_fmtUppercase)!=0)
|
#define kp_fmt_isUpper(FMT) (bool)((FMT&kp_upper)!=0)
|
||||||
#define kprint_format_fgColor(FMT) (kprint_fgColor)(FMT&0x8f000000)
|
#define kp_fmt_fgColor(FMT) (kp_fgColor)(FMT&0x8f000000)
|
||||||
#define kprint_format_bgColor(FMT) (kprint_bgColor)(FMT&0x40f00000)
|
#define kp_fmt_bgColor(FMT) (kp_bgColor)(FMT&0x40f00000)
|
||||||
#define kprint_format_dataFormat(FMT) (kprint_dataFormat)(FMT&0x000f0000)
|
#define kp_fmt_dataFormat(FMT) (kp_dataFmt)(FMT&0x000f0000)
|
||||||
#define kprint_format_ktid(FMT) (kprint_dataFormat)(FMT&0x0000ffff)
|
#define kp_fmt_ktid(FMT) (ktid)(FMT&0x0000ffff)
|
||||||
|
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
# kerep_format
|
# kerep_format
|
||||||
|
|
||||||
```
|
```
|
||||||
00000000 00000000 00000000 00000000
|
00000000 00000000 00000000 00000000
|
||||||
fgColorSet┘│││└┼┴┘ └┼┴┘└┴┴┤ ktid
|
fgColorSet┘│││└┼┴┘ └┼┴┘└┴┴┤ ktid
|
||||||
bgColorSet─┘││ │ bgColor └data format
|
bgColorSet─┘││ │ bgColor └data format
|
||||||
prefix┬────┘│ └fgColor
|
prefix┬────┘│ └fgColor
|
||||||
postfix └uppercase
|
postfix └uppercase
|
||||||
@ -12,61 +12,61 @@ bgColorSet─┘││ │ bgColor └data format
|
|||||||
## Console colors
|
## Console colors
|
||||||
### *Foreground*
|
### *Foreground*
|
||||||
|
|
||||||
| kprint_fg | hex | bin |
|
| kp_fg | hex | bin |
|
||||||
|-----------|-----|-----|
|
|-------|-----|-----|
|
||||||
| Black | 0x80000000 | 10000000 00000000... |
|
| Black | 0x80000000 | 10000000 00000000... |
|
||||||
| DarkRed | 0x81000000 | 10000001 00000000... |
|
| RedD | 0x81000000 | 10000001 00000000... |
|
||||||
| DarkGreen | 0x82000000 | 10000010 00000000... |
|
| GreenD | 0x82000000 | 10000010 00000000... |
|
||||||
| DarkYellow | 0x83000000 | 10000011 00000000... |
|
| YellowD | 0x83000000 | 10000011 00000000... |
|
||||||
| DarkBlue | 0x84000000 | 10000100 00000000... |
|
| BlueD | 0x84000000 | 10000100 00000000... |
|
||||||
| DarkMagenta | 0x85000000 | 10000101 00000000... |
|
| MagentaD | 0x85000000 | 10000101 00000000... |
|
||||||
| DarkCyan | 0x86000000 | 10000110 00000000... |
|
| CyanD | 0x86000000 | 10000110 00000000... |
|
||||||
| Gray | 0x87000000 | 10000111 00000000... |
|
| Gray | 0x87000000 | 10000111 00000000... |
|
||||||
| DarkGray | 0x88000000 | 10001000 00000000... |
|
| GrayD | 0x88000000 | 10001000 00000000... |
|
||||||
| Red | 0x89000000 | 10001001 00000000... |
|
| Red | 0x89000000 | 10001001 00000000... |
|
||||||
| Green | 0x8a000000 | 10001010 00000000... |
|
| Green | 0x8a000000 | 10001010 00000000... |
|
||||||
| Yellow | 0x8b000000 | 10001011 00000000... |
|
| Yellow | 0x8b000000 | 10001011 00000000... |
|
||||||
| Blue | 0x8c000000 | 10001100 00000000... |
|
| Blue | 0x8c000000 | 10001100 00000000... |
|
||||||
| Magenta | 0x8d000000 | 10001101 00000000... |
|
| Magenta | 0x8d000000 | 10001101 00000000... |
|
||||||
| Cyan | 0x8e000000 | 10001110 00000000... |
|
| Cyan | 0x8e000000 | 10001110 00000000... |
|
||||||
| White | 0x8f000000 | 10001111 00000000... |
|
| White | 0x8f000000 | 10001111 00000000... |
|
||||||
|
|
||||||
### *Background*
|
### *Background*
|
||||||
| kprint_bg | hex | bin |
|
| kp_bg | hex | bin |
|
||||||
|-----------|-----|-----|
|
|-------|-----|-----|
|
||||||
| Black | 0x40000000 | 01000000 00000000... |
|
| Black | 0x40000000 | 01000000 00000000... |
|
||||||
| DarkRed | 0x40100000 | 01000000 00010000... |
|
| RedD | 0x40100000 | 01000000 00010000... |
|
||||||
| DarkGreen | 0x40200000 | 01000000 00100000... |
|
| GreenD | 0x40200000 | 01000000 00100000... |
|
||||||
| DarkYellow | 0x40300000 | 01000000 00110000... |
|
| YellowD | 0x40300000 | 01000000 00110000... |
|
||||||
| DarkBlue | 0x40400000 | 01000000 01000000... |
|
| BlueD | 0x40400000 | 01000000 01000000... |
|
||||||
| DarkMagenta | 0x40500000 | 01000000 01010000... |
|
| MagentaD | 0x40500000 | 01000000 01010000... |
|
||||||
| DarkCyan | 0x40600000 | 01000000 01100000... |
|
| CyanD | 0x40600000 | 01000000 01100000... |
|
||||||
| Gray | 0x40700000 | 01000000 01110000... |
|
| Gray | 0x40700000 | 01000000 01110000... |
|
||||||
| DarkGray | 0x40800000 | 01000000 10000000... |
|
| GrayD | 0x40800000 | 01000000 10000000... |
|
||||||
| Red | 0x40900000 | 01000000 10010000... |
|
| Red | 0x40900000 | 01000000 10010000... |
|
||||||
| Green | 0x40a00000 | 01000000 10100000... |
|
| Green | 0x40a00000 | 01000000 10100000... |
|
||||||
| Yellow | 0x40b00000 | 01000000 10110000... |
|
| Yellow | 0x40b00000 | 01000000 10110000... |
|
||||||
| Blue | 0x40c00000 | 01000000 11000000... |
|
| Blue | 0x40c00000 | 01000000 11000000... |
|
||||||
| Magenta | 0x40d00000 | 01000000 11010000... |
|
| Magenta | 0x40d00000 | 01000000 11010000... |
|
||||||
| Cyan | 0x40e00000 | 01000000 11100000... |
|
| Cyan | 0x40e00000 | 01000000 11100000... |
|
||||||
| White | 0x40f00000 | 01000000 11110000... |
|
| White | 0x40f00000 | 01000000 11110000... |
|
||||||
|
|
||||||
|
|
||||||
## Data format
|
## Data format
|
||||||
|
|
||||||
| kprint_fmt | possible flags | data types | hex value | bin value |
|
| format | possible flags | data types | hex value | bin value |
|
||||||
|------------|----------------|------------|-----------|-----------|
|
|-----------|----------------|------------|-----------|-----------|
|
||||||
| Int | | int8... int64 | 0x00000000 | 00000000 00000000... |
|
| kp_i | | int8... int64 | 0x00000000 | 00000000 00000000... |
|
||||||
| UInt | WithPostfix, Uppercase | uint8... uint64 | 0x00010000 | 00000000 00000001... |
|
| kp_u | Postfix, Upper | uint8... uint64 | 0x00010000 | 00000000 00000001... |
|
||||||
| Hex | WithPrefix, Uppercase | any | 0x00020000 | 00000000 00000010... |
|
| kp_h | Prefix, Upper | any | 0x00020000 | 00000000 00000010... |
|
||||||
| Bin | WithPrefix, | any | 0x00030000 | 00000000 00000011... |
|
| kp_b | Prefix | any | 0x00030000 | 00000000 00000011... |
|
||||||
| Float | WithPostfix, Uppercase | float32, float64 | 0x00040000 | 00000000 00000100... |
|
| kp_f | Postfix, Upper | float32, float64 | 0x00040000 | 00000000 00000100... |
|
||||||
| Char | | char | 0x00050000 | 00000000 00000101... |
|
| kp_c | | char | 0x00050000 | 00000000 00000101... |
|
||||||
| String | | char* | 0x00060000 | 00000000 00000110... |
|
| kp_sing | | char* | 0x00060000 | 00000000 00000110... |
|
||||||
|
|
||||||
### *Flags*
|
### *Flags*
|
||||||
| kprint_fmt | hex value | bin value |
|
| flag | hex value | bin value |
|
||||||
|-------------|------------|-----------|
|
|------|------------|-----------|
|
||||||
| withPrefix | 0x20000000 | 00100000 00000000... |
|
| kp_pre | 0x20000000 | 00100000 00000000... |
|
||||||
| withPostfix | 0x20000000 | 00100000 00000000... |
|
| kp_post | 0x20000000 | 00100000 00000000... |
|
||||||
| upperase | 0x10000000 | 00010000 00000000... |
|
| kp_upper | 0x10000000 | 00010000 00000000... |
|
||||||
|
|||||||
@ -5,11 +5,11 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define testColor(COLOR) \
|
#define testColor(COLOR) \
|
||||||
kprint_setColor(kprint_bgBlack | kprint_fg##COLOR);\
|
kprint_setColor(kp_bgBlack | kp_fg##COLOR);\
|
||||||
kprintf(#COLOR " ");\
|
kprintf(#COLOR " ");\
|
||||||
kprint_setColor(kprint_bg##COLOR | kprint_fgGray);\
|
kprint_setColor(kp_bg##COLOR | kp_fgGray);\
|
||||||
kprintf(#COLOR);\
|
kprintf(#COLOR);\
|
||||||
kprint_setColor(kprint_bgBlack | kprint_fgBlack);\
|
kprint_setColor(kp_bgBlack | kp_fgBlack);\
|
||||||
kprintf("\n");
|
kprintf("\n");
|
||||||
|
|
||||||
void test_kprint_colors(){
|
void test_kprint_colors(){
|
||||||
@ -29,14 +29,14 @@ void test_kprint_colors(){
|
|||||||
kprintf("\n"); */
|
kprintf("\n"); */
|
||||||
|
|
||||||
testColor(Black);
|
testColor(Black);
|
||||||
testColor(DarkRed);
|
testColor(RedD);
|
||||||
testColor(DarkGreen);
|
testColor(GreenD);
|
||||||
testColor(DarkYellow);
|
testColor(YellowD);
|
||||||
testColor(DarkBlue);
|
testColor(BlueD);
|
||||||
testColor(DarkMagenta);
|
testColor(MagentaD);
|
||||||
testColor(DarkCyan);
|
testColor(CyanD);
|
||||||
testColor(Gray);
|
testColor(Gray);
|
||||||
testColor(DarkGray);
|
testColor(GrayD);
|
||||||
testColor(Red);
|
testColor(Red);
|
||||||
testColor(Green);
|
testColor(Green);
|
||||||
testColor(Yellow);
|
testColor(Yellow);
|
||||||
@ -44,7 +44,7 @@ void test_kprint_colors(){
|
|||||||
testColor(Magenta);
|
testColor(Magenta);
|
||||||
testColor(Cyan);
|
testColor(Cyan);
|
||||||
testColor(White);
|
testColor(White);
|
||||||
kprint_setColor(kprint_bgBlack | kprint_fgGray);
|
kprint_setColor(kp_bgBlack | kp_fgGray);
|
||||||
|
|
||||||
kprint(kprint_fmtInt | kprint_fgCyan, 8888, kprint_fmtString | kprint_fgYellow, " ooo ", kprint_fmtFloat | kprint_bgDarkGreen | kprint_fgRed, 4.01, kprint_fmtString | kprint_fgWhite, "\ngg\n");
|
kprint(kprint_fmtInt | kp_fgCyan, 8888, kprint_fmtString | kp_fgYellow, " ooo ", kprint_fmtFloat | kp_bgGreenD | kp_fgRed, 4.01, kprint_fmtString | kp_fgWhite, "\ngg\n");
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user