fixed kprint flag macros
This commit is contained in:
parent
c1218014db
commit
9d5dac93de
@ -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_uppercase(fmt)*2;
|
uint8 strind=*(bool*)c==1 + kprint_format_isUppercase(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];
|
||||||
@ -139,9 +139,9 @@ char* toString_hex(void* _bytes, uint32 size, bool withPrefix, bool uppercase){
|
|||||||
int##BITS n=*(int##BITS*)_n;\
|
int##BITS n=*(int##BITS*)_n;\
|
||||||
return toString_int(n);\
|
return toString_int(n);\
|
||||||
case kprint_fmtBin:\
|
case kprint_fmtBin:\
|
||||||
return toString_bin(_n, BITS/8, kprint_format_withPrefix(f));\
|
return toString_bin(_n, BITS/8, kprint_format_isWithPrefix(f));\
|
||||||
case kprint_fmtHex:\
|
case kprint_fmtHex:\
|
||||||
return toString_hex(_n, BITS/8, kprint_format_withPrefix(f), kprint_format_uppercase(f));\
|
return toString_hex(_n, BITS/8, kprint_format_isWithPrefix(f), kprint_format_isUppercase(f));\
|
||||||
default:\
|
default:\
|
||||||
kprintf("\n%u\n", kprint_format_dataFormat(f));\
|
kprintf("\n%u\n", kprint_format_dataFormat(f));\
|
||||||
throw(ERR_FORMAT);\
|
throw(ERR_FORMAT);\
|
||||||
@ -157,11 +157,11 @@ __toString_int_def(64)
|
|||||||
switch(kprint_format_dataFormat(f)){\
|
switch(kprint_format_dataFormat(f)){\
|
||||||
case kprint_fmtUInt: ;\
|
case kprint_fmtUInt: ;\
|
||||||
uint##BITS n=*(uint##BITS*)_n;\
|
uint##BITS n=*(uint##BITS*)_n;\
|
||||||
return toString_uint(n, kprint_format_withPostfix(f), kprint_format_uppercase(f));\
|
return toString_uint(n, kprint_format_isWithPostfix(f), kprint_format_isUppercase(f));\
|
||||||
case kprint_fmtBin:\
|
case kprint_fmtBin:\
|
||||||
return toString_bin(_n, BITS/8, kprint_format_withPrefix(f));\
|
return toString_bin(_n, BITS/8, kprint_format_isWithPrefix(f));\
|
||||||
case kprint_fmtHex:\
|
case kprint_fmtHex:\
|
||||||
return toString_hex(_n, BITS/8, kprint_format_withPrefix(f), kprint_format_uppercase(f));\
|
return toString_hex(_n, BITS/8, kprint_format_isWithPrefix(f), kprint_format_isUppercase(f));\
|
||||||
default:\
|
default:\
|
||||||
kprintf("\n%u\n", kprint_format_dataFormat(f));\
|
kprintf("\n%u\n", kprint_format_dataFormat(f));\
|
||||||
throw(ERR_FORMAT);\
|
throw(ERR_FORMAT);\
|
||||||
@ -177,11 +177,11 @@ __toString_uint_def(64)
|
|||||||
switch(kprint_format_dataFormat(f)){\
|
switch(kprint_format_dataFormat(f)){\
|
||||||
case kprint_fmtFloat: ;\
|
case kprint_fmtFloat: ;\
|
||||||
float##BITS n=*(float##BITS*)_n;\
|
float##BITS n=*(float##BITS*)_n;\
|
||||||
return toString_float(n, kprint_format_withPostfix(f), kprint_format_uppercase(f));\
|
return toString_float(n, kprint_format_isWithPostfix(f), kprint_format_isUppercase(f));\
|
||||||
case kprint_fmtBin:\
|
case kprint_fmtBin:\
|
||||||
return toString_bin(_n, BITS/8, kprint_format_withPrefix(f));\
|
return toString_bin(_n, BITS/8, kprint_format_isWithPrefix(f));\
|
||||||
case kprint_fmtHex:\
|
case kprint_fmtHex:\
|
||||||
return toString_hex(_n, BITS/8, kprint_format_withPrefix(f), kprint_format_uppercase(f));\
|
return toString_hex(_n, BITS/8, kprint_format_isWithPrefix(f), kprint_format_isUppercase(f));\
|
||||||
default:\
|
default:\
|
||||||
kprintf("\n%u\n", kprint_format_dataFormat(f));\
|
kprintf("\n%u\n", kprint_format_dataFormat(f));\
|
||||||
throw(ERR_FORMAT);\
|
throw(ERR_FORMAT);\
|
||||||
|
|||||||
@ -124,24 +124,24 @@ DWORD kprint_bgColor_toWin(kprint_bgColor f){
|
|||||||
|
|
||||||
void kprint_setColor(kprint_format f){
|
void kprint_setColor(kprint_format f){
|
||||||
DWORD color=0;
|
DWORD color=0;
|
||||||
if(!kprint_format_fgColorChanged(f) & !kprint_format_bgColorChanged(f))
|
if(!kprint_format_isFgColorChanged(f) & !kprint_format_isBgColorChanged(f))
|
||||||
return;
|
return;
|
||||||
if(kprint_format_fgColorChanged(f))
|
if(kprint_format_isFgColorChanged(f))
|
||||||
color+=kprint_fgColor_toWin(kprint_format_fgColor(f));
|
color+=kprint_fgColor_toWin(kprint_format_fgColor(f));
|
||||||
if(kprint_format_bgColorChanged(f))
|
if(kprint_format_isBgColorChanged(f))
|
||||||
color+=kprint_bgColor_toWin(kprint_format_bgColor(f));
|
color+=kprint_bgColor_toWin(kprint_format_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(kprint_format f){
|
||||||
if(kprint_format_fgColorChanged(f)){
|
if(kprint_format_isFgColorChanged(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_bgColorChanged(f)){
|
if(kprint_format_isBgColorChanged(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;
|
||||||
|
|||||||
@ -33,11 +33,11 @@ typedef enum kprint_dataFormat{
|
|||||||
|
|
||||||
typedef uint32 kprint_format;
|
typedef uint32 kprint_format;
|
||||||
|
|
||||||
#define kprint_format_fgColorChanged(FMT) (FMT&0x80000000)
|
#define kprint_format_isFgColorChanged(FMT) (bool)((FMT&0x80000000)!=0)
|
||||||
#define kprint_format_bgColorChanged(FMT) (FMT&0x40000000)
|
#define kprint_format_isBgColorChanged(FMT) (bool)((FMT&0x40000000)!=0)
|
||||||
#define kprint_format_withPrefix(FMT) (FMT&kprint_fmtWithPrefix)
|
#define kprint_format_isWithPrefix(FMT) (bool)((FMT&kprint_fmtWithPrefix)!=0)
|
||||||
#define kprint_format_withPostfix(FMT) (FMT&kprint_fmtWithPostfix)
|
#define kprint_format_isWithPostfix(FMT) (bool)((FMT&kprint_fmtWithPostfix)!=0)
|
||||||
#define kprint_format_uppercase(FMT) (FMT&kprint_fmtUppercase)
|
#define kprint_format_isUppercase(FMT) (bool)((FMT&kprint_fmtUppercase)!=0)
|
||||||
#define kprint_format_fgColor(FMT) (kprint_fgColor)(FMT&0x8f000000)
|
#define kprint_format_fgColor(FMT) (kprint_fgColor)(FMT&0x8f000000)
|
||||||
#define kprint_format_bgColor(FMT) (kprint_bgColor)(FMT&0x40f00000)
|
#define kprint_format_bgColor(FMT) (kprint_bgColor)(FMT&0x40f00000)
|
||||||
#define kprint_format_dataFormat(FMT) (kprint_dataFormat)(FMT&0x000f0000)
|
#define kprint_format_dataFormat(FMT) (kprint_dataFormat)(FMT&0x000f0000)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user