This commit is contained in:
y4my4my4m 2023-05-09 19:51:54 +09:00
parent 263b800bf8
commit e32433ad0b

View file

@ -25,6 +25,7 @@
CTask *input_task = NULL; CTask *input_task = NULL;
Bool force_disconnect = FALSE; Bool force_disconnect = FALSE;
Bool input_request = FALSE; Bool input_request = FALSE;
I64 color_code;
U8 IsDigit(U8 ch) { U8 IsDigit(U8 ch) {
return '0' <= ch <= '9'; return '0' <= ch <= '9';
@ -39,23 +40,6 @@ Bool CursorInWin(CTask *task, I64 x, I64 y)
return FALSE; return FALSE;
} }
U0 AppendColorString(I64 color_code) {
U8 *color;
switch (color_code) {
case 0: color = "$$BLACK$$"; break;
case 1: color = "$$RED$$"; break;
case 2: color = "$$GREEN$$"; break;
case 3: color = "$$YELLOW$$"; break;
case 4: color = "$$BLUE$$"; break;
case 5: color = "$$PURPLE$$"; break;
case 6: color = "$$CYAN$$"; break;
case 7: color = "$$WHITE$$"; break;
case 8: color = "$$FG$$"; break;
default: color = ""; break;
}
"%s", color;
}
U0 SendWindowSize(I64 sock, U16 rows, U16 cols) { U0 SendWindowSize(I64 sock, U16 rows, U16 cols) {
U8 buf[9]; U8 buf[9];
@ -123,9 +107,9 @@ U0 HandleControlCodes(U8 ch) {
if (ch == 0x24) { if (ch == 0x24) {
// ch = "//$$$$"; // ch = "//$$$$";
} }
"%c", ch; "%c", ch;
}
} }
}
I64 TelnetOpen(U8 *host, U16 port) { I64 TelnetOpen(U8 *host, U16 port) {
I64 sock; I64 sock;
@ -311,7 +295,9 @@ U0 Telnet(U8 *host, U16 port=TELNET_PORT) {
response[3] = '\0'; response[3] = '\0';
TCPSocketSendString(sock, response); TCPSocketSendString(sock, response);
ptr += 3; ptr += 3;
} }
// check for pipecode here??
// https://github.com/wwivbbs/docs/blob/main/docs/cfg/displaying_text.md#pipe-screen-and-cursor-control
else if (*ptr == ANSI_ESC) { else if (*ptr == ANSI_ESC) {
// ANSI escape sequence // ANSI escape sequence
ptr++; ptr++;
@ -325,11 +311,11 @@ U0 Telnet(U8 *host, U16 port=TELNET_PORT) {
ptr++; ptr++;
} }
// Process ansi_code // Process ansi_code
if (*ptr == ' ') { // if (*ptr == ' ') {
// skip empty space // // skip empty space
ptr++; // ptr++;
} // }
else if (*ptr == ';') { if (*ptr == ';') {
ptr++; ptr++;
} }
else { else {
@ -353,7 +339,6 @@ U0 Telnet(U8 *host, U16 port=TELNET_PORT) {
TCPSocketSendString(sock, "\x1B[?1;0c"); TCPSocketSendString(sock, "\x1B[?1;0c");
ptr++; ptr++;
} else if (*ptr == 'm') { } else if (*ptr == 'm') {
I64 color_code;
if (ansi_code >= 30 && ansi_code <= 37) { if (ansi_code >= 30 && ansi_code <= 37) {
color_code = ansi_code - 30; // Set foreground color color_code = ansi_code - 30; // Set foreground color
} else if (ansi_code >= 40 && ansi_code <= 47) { } else if (ansi_code >= 40 && ansi_code <= 47) {
@ -379,9 +364,10 @@ U0 Telnet(U8 *host, U16 port=TELNET_PORT) {
case 2: "$$GREEN$$"; break; case 2: "$$GREEN$$"; break;
case 3: "$$YELLOW$$"; break; case 3: "$$YELLOW$$"; break;
case 4: "$$BLUE$$"; break; case 4: "$$BLUE$$"; break;
case 5: "$$BROWN$$"; break; case 5: "$$PURPLE$$"; break;
case 6: "$$CYAN$$"; break; case 6: "$$CYAN$$"; break;
case 7: "$$WHITE$$"; break; case 7: "$$WHITE$$"; break;
case 8: "$$BG$$$$FG$$"; break; // reset
default: break; default: break;
} }
ptr++; ptr++;
@ -403,10 +389,6 @@ U0 Telnet(U8 *host, U16 port=TELNET_PORT) {
if (move_count == 0) { if (move_count == 0) {
move_count = 1; // Default value if no number is provided move_count = 1; // Default value if no number is provided
} }
// for (i = 0; i < move_count; i++) {
// Print(" ");
// }
CursorInWin(Fs, move_count, 0); // Cursor Right CursorInWin(Fs, move_count, 0); // Cursor Right
ptr++; ptr++;
} else if (*ptr == 'D') { } else if (*ptr == 'D') {
@ -453,6 +435,7 @@ U0 Telnet(U8 *host, U16 port=TELNET_PORT) {
ptr++; // Move past 'l' or 'h' ptr++; // Move past 'l' or 'h'
break; break;
default: default:
ptr++;
break; break;
} }
} else if (*ptr == 's') { } else if (*ptr == 's') {
@ -467,6 +450,7 @@ U0 Telnet(U8 *host, U16 port=TELNET_PORT) {
} else { } else {
ptr++; ptr++;
} }
ptr++;
break; break;
} }
} }