mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2024-12-25 15:10:28 +00:00
Update
This commit is contained in:
parent
b9e7cd0c4a
commit
0ca6caa2fa
1 changed files with 60 additions and 8 deletions
|
@ -38,11 +38,11 @@ U0 GetColorString(I64 color_code, U8 *buf) {
|
||||||
case 0: StrCopy(buf, "$$BLACK$$"); break;
|
case 0: StrCopy(buf, "$$BLACK$$"); break;
|
||||||
case 1: StrCopy(buf, "$$RED$$"); break;
|
case 1: StrCopy(buf, "$$RED$$"); break;
|
||||||
case 2: StrCopy(buf, "$$GREEN$$"); break;
|
case 2: StrCopy(buf, "$$GREEN$$"); break;
|
||||||
case 3: StrCopy(buf, "$$YELLOW$$"); break;
|
case 3: StrCopy(buf, "$$BROWN$$"); break; // ANSI yellow is mapped to ZealOS brown
|
||||||
case 4: StrCopy(buf, "$$BLUE$$"); break;
|
case 4: StrCopy(buf, "$$BLUE$$"); break;
|
||||||
case 5: StrCopy(buf, "$$MAGENTA$$"); break;
|
case 5: StrCopy(buf, "$$MAGENTA$$"); break;
|
||||||
case 6: StrCopy(buf, "$$CYAN$$"); break;
|
case 6: StrCopy(buf, "$$CYAN$$"); break;
|
||||||
case 7: StrCopy(buf, "$$WHITE$$"); break;
|
case 7: StrCopy(buf, "$$GREY$$"); break; // ANSI white is mapped to ZealOS grey
|
||||||
default: StrCopy(buf, ""); break; // Default to empty string if an invalid color code is given
|
default: StrCopy(buf, ""); break; // Default to empty string if an invalid color code is given
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ U0 TelnetClient(U8 *host, U16 port) {
|
||||||
if (bytes_received > 0) {
|
if (bytes_received > 0) {
|
||||||
buffer[bytes_received] = '\0';
|
buffer[bytes_received] = '\0';
|
||||||
|
|
||||||
// Basic Telnet protocol parser: Ignore negotiation sequences
|
// Basic Telnet protocol parser
|
||||||
ptr = buffer;
|
ptr = buffer;
|
||||||
while (*ptr) {
|
while (*ptr) {
|
||||||
if (*ptr == 0xFF) { // Telnet negotiation sequence
|
if (*ptr == 0xFF) { // Telnet negotiation sequence
|
||||||
|
@ -106,12 +106,41 @@ U0 TelnetClient(U8 *host, U16 port) {
|
||||||
U8 response[3];
|
U8 response[3];
|
||||||
response[0] = 0xFF; // IAC
|
response[0] = 0xFF; // IAC
|
||||||
|
|
||||||
|
// Check if the negotiation code is DO or DONT
|
||||||
|
// if (negotiation_code == 0xFD || negotiation_code == 0xFE) {
|
||||||
|
// switch (option_code) {
|
||||||
|
// case 0x01: // Echo
|
||||||
|
// response[1] = (negotiation_code == 0xFD) ? 0xFB : 0xFC; // WILL if DO, WONT if DONT
|
||||||
|
// break;
|
||||||
|
// case 0x03: // Suppress Go Ahead
|
||||||
|
// response[1] = (negotiation_code == 0xFD) ? 0xFB : 0xFC; // WILL if DO, WONT if DONT
|
||||||
|
// break;
|
||||||
|
// case 0x18: // Terminal Type
|
||||||
|
// if (negotiation_code == 0xFD) {
|
||||||
|
// response[1] = 0xFB; // WILL
|
||||||
|
// TCPSocketSend(sock, response, 3);
|
||||||
|
// SendTerminalType(sock, "ANSI");
|
||||||
|
// ptr += 3;
|
||||||
|
// continue:
|
||||||
|
// } else {
|
||||||
|
// response[1] = 0xFC; // WONT
|
||||||
|
// }
|
||||||
|
// break;
|
||||||
|
// default:
|
||||||
|
// response[1] = 0xFC; // WONT
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// } else { // Else, assume the negotiation code is WILL or WONT
|
||||||
|
// response[1] = 0xFE; // DONT
|
||||||
|
// }
|
||||||
|
|
||||||
// Check if the negotiation code is DO or DONT
|
// Check if the negotiation code is DO or DONT
|
||||||
if (negotiation_code == 0xFD && option_code == 0x18) {
|
if (negotiation_code == 0xFD && option_code == 0x18) {
|
||||||
response[1] = 0xFB; // WILL
|
response[1] = 0xFB; // WILL
|
||||||
TCPSocketSend(sock, response, 3);
|
TCPSocketSend(sock, response, 3);
|
||||||
|
// doesn't seem to work
|
||||||
SendTerminalType(sock, "ANSI");
|
SendTerminalType(sock, "ANSI");
|
||||||
SendWindowSize(sock, 40, 80); // default window size is normally 24 rows and 80 columns
|
SendWindowSize(sock, 40, 80);
|
||||||
} else if (negotiation_code == 0xFD || negotiation_code == 0xFE) {
|
} else if (negotiation_code == 0xFD || negotiation_code == 0xFE) {
|
||||||
response[1] = 0xFC; // WONT
|
response[1] = 0xFC; // WONT
|
||||||
} else { // Else, assume the negotiation code is WILL or WONT
|
} else { // Else, assume the negotiation code is WILL or WONT
|
||||||
|
@ -137,10 +166,33 @@ U0 TelnetClient(U8 *host, U16 port) {
|
||||||
// Process ansi_code
|
// Process ansi_code
|
||||||
if (*ptr == ';') {
|
if (*ptr == ';') {
|
||||||
ptr++; // Move to next part of the sequence
|
ptr++; // Move to next part of the sequence
|
||||||
} else if (*ptr == 'm' || *ptr == 'H' || *ptr == 'J' || *ptr == 'K' ) {
|
} else if (*ptr == 'm' ) {
|
||||||
|
ptr++;
|
||||||
|
break;
|
||||||
|
} else if (*ptr == 'H' || *ptr == 'J' || *ptr == 'K' ) {
|
||||||
ptr++; // Move past the current character
|
ptr++; // Move past the current character
|
||||||
break; // End of the escape sequence
|
// Process color codes
|
||||||
} else if (*ptr == 'C') {
|
// if (ansi_code >= 30 && ansi_code <= 37) {
|
||||||
|
// // Set foreground color
|
||||||
|
// U8 color_buf[16];
|
||||||
|
// GetColorString(ansi_code - 30, color_buf);
|
||||||
|
// Print(color_buf);
|
||||||
|
// } else if (ansi_code >= 40 && ansi_code <= 47) {
|
||||||
|
// // Set background color
|
||||||
|
// U8 color_buf[16];
|
||||||
|
// GetColorString(ansi_code - 40, color_buf);
|
||||||
|
// Print(color_buf);
|
||||||
|
// }
|
||||||
|
I64 zeal_color = 7; // Default color
|
||||||
|
if (ansi_code >= 30 && ansi_code <= 37) {
|
||||||
|
zeal_color = ansi_code - 30;
|
||||||
|
}
|
||||||
|
U8 color_string[16];
|
||||||
|
GetColorString(zeal_color, color_string);
|
||||||
|
"%s", color_string;
|
||||||
|
// End of the escape sequence
|
||||||
|
break;
|
||||||
|
} else if (*ptr == 'C') {
|
||||||
// Custom 'C' escape code for centering text
|
// Custom 'C' escape code for centering text
|
||||||
// TODO: Handle the centering here
|
// TODO: Handle the centering here
|
||||||
ptr++;
|
ptr++;
|
||||||
|
@ -184,7 +236,7 @@ U0 TelnetClient(U8 *host, U16 port) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
*line++ = ch;
|
*line++ = ch;
|
||||||
"%c", ch;
|
"%c", ch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*line++ = '\r';
|
*line++ = '\r';
|
||||||
|
|
Loading…
Reference in a new issue