mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2024-12-25 15:10:28 +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
|
||||
// }
|
||||
// }
|
||||
|
||||
U0 GetColorString(I64 color_code, U8 *buf) {
|
||||
switch (color_code) {
|
||||
case 0: StrCopy(buf, "$$BLACK$$"); break;
|
||||
|
@ -73,17 +74,23 @@ U0 TelnetClient(U8 *host, U16 port) {
|
|||
ptr++;
|
||||
if (*ptr == '[') {
|
||||
ptr++;
|
||||
I64 ansi_code = 0;
|
||||
I64 ansi_code;
|
||||
while (1) {
|
||||
ansi_code = 0;
|
||||
while (*ptr >= '0' && *ptr <= '9') {
|
||||
ansi_code = ansi_code * 10 + (*ptr - '0');
|
||||
ptr++;
|
||||
}
|
||||
// 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;
|
||||
// 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
|
||||
}
|
||||
}
|
||||
// GrColor(templeos_color);
|
||||
}
|
||||
} else {
|
||||
// Print the received character
|
||||
|
|
Loading…
Reference in a new issue