Fix printing in kernel
This commit is contained in:
parent
770e040383
commit
8774b20356
|
@ -76,8 +76,8 @@ int Main(void) {
|
||||||
InternalBuffer = (char*) kmalloc(4096);
|
InternalBuffer = (char*) kmalloc(4096);
|
||||||
SerialPrintf("[ Mem] Allocated a text buffer at 0x%p\r\n", (size_t) InternalBuffer);
|
SerialPrintf("[ Mem] Allocated a text buffer at 0x%p\r\n", (size_t) InternalBuffer);
|
||||||
|
|
||||||
WriteString("\\${FF0000}C\\${<green>}h\\${<blue>}r\\${FFFF00}o\\${FF00FF}m\\${FFFF}a ");
|
Printf("\\${FF0000}C\\${<green>}h\\${<blue>}r\\${FFFF00}o\\${FF00FF}m\\${FFFF}a ");
|
||||||
WriteString("\\${FFFFFF}T\\${AAAA}i\\${BBBBBB}m\\${<forgeb>}e\\${<forgey>}!\n");
|
Printf("\\${FFFFFF}T\\${AAAA}i\\${BBBBBB}m\\${<forgeb>}e\\${<forgey>}!\n");
|
||||||
|
|
||||||
SetForegroundColor(0x00FFFFFF);
|
SetForegroundColor(0x00FFFFFF);
|
||||||
|
|
||||||
|
|
|
@ -22,8 +22,8 @@ size_t strlen(const char* String) {
|
||||||
bool strcmp(char* a, const char* b) {
|
bool strcmp(char* a, const char* b) {
|
||||||
size_t aI = 0, bI = 0;
|
size_t aI = 0, bI = 0;
|
||||||
while(true) {
|
while(true) {
|
||||||
|
if(b[bI] == '\0') return true;
|
||||||
if(a[aI] != b[bI]) return false;
|
if(a[aI] != b[bI]) return false;
|
||||||
if(a[aI] == '\0') return true;
|
|
||||||
aI++;
|
aI++;
|
||||||
bI++;
|
bI++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -202,23 +202,24 @@ int Printf(const char* Format, ...) {
|
||||||
switch(*Format) {
|
switch(*Format) {
|
||||||
case '$': {
|
case '$': {
|
||||||
// COLOR
|
// COLOR
|
||||||
Format ++; // Skip $ and {
|
Format ++; // Skip $
|
||||||
size_t Color = 0;
|
size_t Color = 0;
|
||||||
bool bgFlag = false;
|
bool bgFlag = false;
|
||||||
|
|
||||||
switch(*Format) {
|
switch(*Format) {
|
||||||
case '[':
|
case '[':
|
||||||
|
// bg
|
||||||
bgFlag = true;
|
bgFlag = true;
|
||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
// bg
|
|
||||||
case '{':
|
case '{':
|
||||||
// fg
|
// fg
|
||||||
Format++;
|
Format++; // [ or {
|
||||||
|
|
||||||
if(*Format == '<') {
|
if(*Format == '<') {
|
||||||
Color = ParseEnglishColor((char*) ++Format);
|
|
||||||
Format++;
|
Format++;
|
||||||
|
Color = ParseEnglishColor((char*) Format);
|
||||||
} else {
|
} else {
|
||||||
Color = ParseHexColor(++Format, bgFlag);
|
Color = ParseHexColor(Format, bgFlag);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(bgFlag)
|
if(bgFlag)
|
||||||
|
@ -226,20 +227,18 @@ int Printf(const char* Format, ...) {
|
||||||
else
|
else
|
||||||
SetForegroundColor(Color);
|
SetForegroundColor(Color);
|
||||||
|
|
||||||
|
while(*Format != '}')
|
||||||
Format++;
|
Format++;
|
||||||
|
Format++; // }
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Format++;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'f':
|
case 'f':
|
||||||
// FORMAT
|
// FORMAT
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Format++;
|
|
||||||
} else {
|
} else {
|
||||||
WriteChar(*Format);
|
WriteChar(*Format);
|
||||||
Format++;
|
Format++;
|
||||||
|
@ -277,11 +276,10 @@ size_t ParseHexColor(const char* Stream, bool bgFlag) {
|
||||||
size_t val = 0;
|
size_t val = 0;
|
||||||
char c;
|
char c;
|
||||||
|
|
||||||
while ((*Stream != (bgFlag ? ']' : '}')) && (c = *Stream++)) {
|
while ((*Stream != (bgFlag ? ']' : '}')) && (c = *(++Stream))) {
|
||||||
char v = ((c & 0xF) + (c >> 6)) | ((c >> 3) & 0x8);
|
char v = ((c & 0xF) + (c >> 6)) | ((c >> 3) & 0x8);
|
||||||
val = (val << 4) | (size_t) v;
|
val = (val << 4) | (size_t) v;
|
||||||
}
|
}
|
||||||
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user