mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2024-12-25 23:10:32 +00:00
parse ansi
This commit is contained in:
parent
81bf25c5ba
commit
a16030394a
1 changed files with 17 additions and 10 deletions
|
@ -32,6 +32,7 @@ I64 TelnetOpen(U8 *host, U16 port) {
|
||||||
// StrCopy(buf, ""); // Default to empty string if an invalid color code is given
|
// StrCopy(buf, ""); // Default to empty string if an invalid color code is given
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
U0 GetColorString(I64 color_code, U8 *buf) {
|
U0 GetColorString(I64 color_code, U8 *buf) {
|
||||||
switch (color_code) {
|
switch (color_code) {
|
||||||
case 0: StrCopy(buf, "$$BLACK$$"); break;
|
case 0: StrCopy(buf, "$$BLACK$$"); break;
|
||||||
|
@ -73,17 +74,23 @@ U0 TelnetClient(U8 *host, U16 port) {
|
||||||
ptr++;
|
ptr++;
|
||||||
if (*ptr == '[') {
|
if (*ptr == '[') {
|
||||||
ptr++;
|
ptr++;
|
||||||
I64 ansi_code = 0;
|
I64 ansi_code;
|
||||||
while (*ptr >= '0' && *ptr <= '9') {
|
while (1) {
|
||||||
ansi_code = ansi_code * 10 + (*ptr - '0');
|
ansi_code = 0;
|
||||||
ptr++;
|
while (*ptr >= '0' && *ptr <= '9') {
|
||||||
|
ansi_code = ansi_code * 10 + (*ptr - '0');
|
||||||
|
ptr++;
|
||||||
|
}
|
||||||
|
// Process ansi_code
|
||||||
|
if (*ptr == ';') {
|
||||||
|
ptr++; // Move to next part of the sequence
|
||||||
|
} else if (*ptr == 'm') {
|
||||||
|
ptr++; // Move past 'm'
|
||||||
|
break; // End of the escape sequence
|
||||||
|
} else {
|
||||||
|
break; // Invalid character, exit loop
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Convert ANSI color code to ZealOS color
|
|
||||||
I64 templeos_color = 7; // Default color
|
|
||||||
if (ansi_code >= 30 && ansi_code <= 37) {
|
|
||||||
templeos_color = ansi_code - 30;
|
|
||||||
}
|
|
||||||
// GrColor(templeos_color);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Print the received character
|
// Print the received character
|
||||||
|
|
Loading…
Reference in a new issue