From 7beb6c69a49601fe3943c4093463c0ad72c5f975 Mon Sep 17 00:00:00 2001 From: y4my4my4m <8145020+y4my4my4m@users.noreply.github.com> Date: Tue, 2 May 2023 03:00:19 +0900 Subject: [PATCH] Keys --- src/Home/Telnet/ANSI.ZC | 129 -------------------------------------- src/Home/Telnet/Telnet.ZC | 71 ++++++++++----------- 2 files changed, 36 insertions(+), 164 deletions(-) delete mode 100644 src/Home/Telnet/ANSI.ZC diff --git a/src/Home/Telnet/ANSI.ZC b/src/Home/Telnet/ANSI.ZC deleted file mode 100644 index f7183627..00000000 --- a/src/Home/Telnet/ANSI.ZC +++ /dev/null @@ -1,129 +0,0 @@ -#define MODE_TEXT 0 -#define MODE_ESCAPE 1 -#define MODE_CSI 2 - -#define CMD_RESET 0 -#define CMD_SLOW_BLINK 5 -#define CMD_FAST_BLINK 6 -#define CMD_FG 3 -#define CMD_BG 4 -#define CMB_B_FG 9 -#define CMD_B_BG 1 - -U0 PrintANSI(U8 *str, I64 len=-1) { - U64 state = MODE_TEXT; - U64 cmd = -1; - if (len < 0) len = StrLen(str); - U64 i; - for (i=0; i '9') - throw('ICSIC'); - - U64 code = ch - '0'; - #define next_ch { if (i+1 >= len) { throw("Expected character"); } ch = str[++i]; code = ch - '0'; } - - switch (code) { - case CMD_RESET: - "$$FG$$$$BG$$"; - break; - case CMD_SLOW_BLINK: - case CMD_FAST_BLINK: - // FIXME: Add blink - break; - case 'A': // Cursor Up - case 'B': // Cursor Down - case 'C': // Cursor Forward (Right) - case 'D': // Cursor Backward (Left) - case 'E': // Cursor Next Line - case 'F': // Cursor Previous Line - case 'G': // Cursor Horizontal Absolute - case 'H': // Cursor Position (default: top-left corner) - case 'f': // Same as 'H' - case 'J': // Erase Display - ptr++; - DocClear; - break; - case 'K': // Erase Line - case 'S': // Scroll Up - case 'T': // Scroll Down - case '?': // DEC Private Mode - case 'h': // Set Mode - case 'l': // Reset Mode - case 'c': // Device Attributes (Request) - case CMD_FG: - next_ch; - - switch (code) { - case 0: "$$BLACK$$"; break; - case 1: "$$RED$$"; break; - case 2: "$$GREEN$$"; break; - case 3: "$$YELLOW$$"; break; - case 4: "$$BLUE$$"; break; - case 5: "$$PURPLE$$"; break; - case 6: "$$CYAN$$"; break; - case 7: "$$WHITE$$"; break; - // FIXME: Handle 8 - case 9: "$$FG$$"; break; - } - break; - case CMD_BG: - next_ch; - - switch (code) { - case 0: "$$BG,BLACK$$"; break; - case 1: "$$BG,RED$$"; break; - case 2: "$$BG,GREEN$$"; break; - case 3: "$$BG,YELLOW$$"; break; - case 4: "$$BG,BLUE$$"; break; - case 5: "$$BG,PURPLE$$"; break; - case 6: "$$BG,CYAN$$"; break; - case 7: "$$BG,WHITE$$"; break; - // FIXME: Handle 8 - case 9: "$$BG$$"; break; - } - break; - default: - "\nCOde: %d\n", code; - throw('ICSI'); - } - - next_ch; - if (ch == ';') { - next_ch; - goto csi; - } - goto start_iter; - break; - default: - throw('ISTE'); - } - - next_iter: - } -} - -// PrintANSI("He\x1b[33;45mllo\x1b[0m yoooo\n"); diff --git a/src/Home/Telnet/Telnet.ZC b/src/Home/Telnet/Telnet.ZC index bbcf9a3c..3e207083 100755 --- a/src/Home/Telnet/Telnet.ZC +++ b/src/Home/Telnet/Telnet.ZC @@ -302,40 +302,40 @@ U0 Telnet(U8 *host, U16 port=TELNET_PORT) { U8 *line = input_buffer; U8 *end_of_line = line; while (1) { - switch (KeyGet(&sc)) - { - case 0: - switch (sc.u8[0]) - { - case SC_CURSOR_UP: - TCPSocketSendString(sock, "CU01"); - SysLog("Cursor up"); - break; - case SC_CURSOR_DOWN: - TCPSocketSendString(sock, "CD01"); - SysLog("Cursor down"); - break; - case SC_CURSOR_LEFT: - TCPSocketSendString(sock, "CB01"); - SysLog("Cursor left"); - if (line > input_buffer) { - line--; - "%c", 8; - } - break; - case SC_CURSOR_RIGHT: - SysLog("Cursor right"); - TCPSocketSendString(sock, "CF01"); - if (line < end_of_line) { - "%c", *line++; - } - break; - default: - break; - } - default: - break; - } + // switch (KeyGet(&sc)) + // { + // case 0: + // switch (sc.u8[0]) + // { + // case SC_CURSOR_UP: + // TCPSocketSendString(sock, "CU01"); + // SysLog("Cursor up"); + // break; + // case SC_CURSOR_DOWN: + // TCPSocketSendString(sock, "CD01"); + // SysLog("Cursor down"); + // break; + // case SC_CURSOR_LEFT: + // TCPSocketSendString(sock, "CB01"); + // SysLog("Cursor left"); + // if (line > input_buffer) { + // line--; + // "%c", 8; + // } + // break; + // case SC_CURSOR_RIGHT: + // SysLog("Cursor right"); + // TCPSocketSendString(sock, "CF01"); + // if (line < end_of_line) { + // "%c", *line++; + // } + // break; + // default: + // break; + // } + // default: + // break; + // } ch = CharGet(, FALSE); if (ch == '\r' || ch == '\n') { break; @@ -366,6 +366,7 @@ U0 Telnet(U8 *host, U16 port=TELNET_PORT) { // TCPSocketSend(sock, line, 16); } else { "Force disconnecting...\n"; + goto disconnect; break; } } else { @@ -374,7 +375,7 @@ U0 Telnet(U8 *host, U16 port=TELNET_PORT) { break; } } - +disconnect: TCPSocketClose(sock); "Telnet connection closed.\n"; }