From 6d61aca3608010109a68243d92a5d58c00b10789 Mon Sep 17 00:00:00 2001 From: y4my4my4m <8145020+y4my4my4m@users.noreply.github.com> Date: Mon, 1 May 2023 02:25:54 +0900 Subject: [PATCH] update --- src/Home/Telnet/ANSI.ZC | 129 ++++++++++++++++++++ src/Home/Telnet/Art/MATRIX.ANS | Bin 0 -> 3490 bytes src/Home/Telnet/Art/ZealBanner.DD | 7 ++ src/Home/Telnet/Art/ZealSplash.ans | 21 ++++ src/Home/{Net/Programs => Telnet}/Telnet.ZC | 29 ++++- 5 files changed, 181 insertions(+), 5 deletions(-) create mode 100644 src/Home/Telnet/ANSI.ZC create mode 100644 src/Home/Telnet/Art/MATRIX.ANS create mode 100644 src/Home/Telnet/Art/ZealBanner.DD create mode 100644 src/Home/Telnet/Art/ZealSplash.ans rename src/Home/{Net/Programs => Telnet}/Telnet.ZC (93%) diff --git a/src/Home/Telnet/ANSI.ZC b/src/Home/Telnet/ANSI.ZC new file mode 100644 index 00000000..f7183627 --- /dev/null +++ b/src/Home/Telnet/ANSI.ZC @@ -0,0 +1,129 @@ +#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/Art/MATRIX.ANS b/src/Home/Telnet/Art/MATRIX.ANS new file mode 100644 index 0000000000000000000000000000000000000000..0a5985446d7ef80c9a8630e6066a064b04542b48 GIT binary patch literal 3490 zcmb7Hv2NQi5Ovl9nYtA9;tt)V$aV%zaZwZ<0u%_Ep`JQ)t3IHAW$AY$K>yLH@9uac zk0K?M2yE+keD~htiBk60s=I%4$c_EAZkwh(p1WJ$-}bpglhXJ7FpfPX=HNKS3(nm* zPD{KLjNk?-yoEQ9qs3cbf&YvQ zj6zHc0&SjMrp7#HAK-}TP?@5>B(|0)S&Ocv4x=G-iHHlsmzhoTg>=Swqp3|7No_iz z=}9?n^?FQXnCwNX%PQv2J&0`D;Dr)TI#?%`IxSA3vD;7CeNh2Ho%J0%A%-|b^JHyz zVeLgrRVGP~oD*_eaTkH&M0Q&?5R2hsBFcTbN?11O?uC%z_y}RR-iTPFt|}p6h+~RI zxSix?BuWKNhG4jGEZj0fgZc&4Mx0+^go*(p`2{^~Q@6(xtQ@j~csGwNB$JPMczx zugM8qAxwZ;z5rT~6w3)1u>=!E6YyQ=8Up&v^il^q5aqAF&PW=Rus0JDS8wIu~Cn)7N*Wy zurhdJlGxxY#<~)CTb5S)0$HeHv2ALBj)IVle$&EquHXGG;gxVjPC(A!>SSU;6!x7N z$mlFPzZK3WYn1DXs{ts8;inisGu$moFNDdlojW~C)_}1*OTrz`)-9d`InekR?r%LW z99LF`Q`Y?2Ur+qb-|!1yOaB0L^TCOHaEj4!&0|Lu5y2MV!n~jX(Q7n*1mdP>=>j0< z?&IrojSX?%{;^kDvmIyJ^il?J(SUai8HlMadevcF?_Zw2fBIZiKYsoEeYw1>;r}^y m_*=`6xrgeZsZLe>;eNNfyZg3#x8w2l>*e|I`sGQk{O3PU(2@NB literal 0 HcmV?d00001 diff --git a/src/Home/Telnet/Art/ZealBanner.DD b/src/Home/Telnet/Art/ZealBanner.DD new file mode 100644 index 00000000..24346eb2 --- /dev/null +++ b/src/Home/Telnet/Art/ZealBanner.DD @@ -0,0 +1,7 @@ + oooooooooooo oooo oooooooooo. oooooooooo. .oooooo..o +d'""""""d888' `888 `888' `Y8b `888' `Y8b d8P' `Y8 + .888P .ooooo. .oooo. 888 888 888 888 888 Y88bo. + d888' d88' `88b `P )88b 888 888oooo888' 888oooo888' `"Y8888o. + .888P 888ooo888 .oP"888 888 888 `88b 888 `88b `"Y88b + d888' .P 888 .o d8( 888 888 888 .88P 888 .88P oo .d8P +.8888888888P `Y8bod8P' `Y888""8o o888o o888bood8P' o888bood8P' 8""88888P' diff --git a/src/Home/Telnet/Art/ZealSplash.ans b/src/Home/Telnet/Art/ZealSplash.ans new file mode 100644 index 00000000..86b640b7 --- /dev/null +++ b/src/Home/Telnet/Art/ZealSplash.ans @@ -0,0 +1,21 @@ +²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²² +²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²±±±±±±±±±±±±±±±±±±±±±±±±²²²²²²²²²² +²²²²²²²²²²²²²²²²²²²±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±°°  ²²²² +²²²²²²² °±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±°°°   ²²²²²²²²²²²²²²²²²²²²²²²²²²²² +²²²²²²²²²²²²²²² °±±±°°°  ²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²² +²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²² +²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²² +²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²   °°±±±±±±±±±±±±±±± ²²²²²²²²²²²²²²²²²²²² +²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²±±±±±±±±±±±±±±±±±±±± ²²²²²²²²²²²²²²²²²²²²²²²²² +²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²±±±±±±±±±±±±±±±±±±±°²²²²²²²²²²²²²²²²²²²²²²²²²²²²²² +²²²²²²²²²²²²²²²²²²²²²²²²²±±±±±±±±±±±±±±±±±±±± ²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²² +²²²²²²²²²²²²²²²²²²²²±±±±±±±±±±±±±±±±±±±± ²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²² +²²²²²²²²²²²²²²²±±±±±±±±±±±±±±±±±±±±°²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²² +²²²²²²²²²²±±±±±±±±±±±±±±±±±±±±± ²²²²²²²²²² ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±²²²²²²²² +²²²²²±±±±±±±±±±±±±±±±±±±±± ²²²²²²²²²²²±±±±±±±±±±±±±±±±±±±±±±±±±±±±±°°°   ²²²²²²² +²²²²²²²²² °±±±±±±±±±±° ²²²²²²²²²² ±±±±±±±°°°   ²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²² +²²²²²²²²²²²²²²²² ²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²² +²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²² +²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²² +²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²² + \ No newline at end of file diff --git a/src/Home/Net/Programs/Telnet.ZC b/src/Home/Telnet/Telnet.ZC similarity index 93% rename from src/Home/Net/Programs/Telnet.ZC rename to src/Home/Telnet/Telnet.ZC index 4fbf68fb..47c8b112 100755 --- a/src/Home/Net/Programs/Telnet.ZC +++ b/src/Home/Telnet/Telnet.ZC @@ -115,7 +115,7 @@ U0 HandleControlCodes(U8 ch) { DocClear; break; case 13: // CR (Carriage Return) - "\r\n\0"; + // "\r\n\0"; skip_input = TRUE; break; case 14: // SO (Shift Out) @@ -128,7 +128,8 @@ U0 HandleControlCodes(U8 ch) { break; } } else { - "%c", ch; + // dont print for now + // "%c", ch; } } @@ -138,6 +139,19 @@ U0 Telnet(U8 *host, U16 port=TELNET_PORT) { U8 buffer[BUF_SIZE], input_buffer[BUF_SIZE], *ptr, ch; Bool force_disconnect = FALSE; + // would be nice to resize to 25x80 + // CTask *task; + // task=User; + // TaskWait(task); + // task->border_src=BDS_CONST; + // task->border_attr=LTGRAY<<4+DriveTextAttrGet(':')&15; + // task->text_attr =LTGRAY<<4+BLUE; + // task->win_inhibit= WIG_TASK_DEFAULT-WIF_SELF_BORDER; + // WinHorz(Fs->win_left,Fs->win_right,task); + // WinVert(Fs->win_top,(Fs->win_top+Fs->win_bottom)>>2-1,task); + // WinVert(task->win_bottom+3,Fs->win_bottom); + // WinToTop(Fs); + sock = TelnetOpen(host, port); if (sock <= 0) { return; @@ -247,6 +261,7 @@ U0 Telnet(U8 *host, U16 port=TELNET_PORT) { ptr++; // Skip 'h' or 'l' break; } else { + ptr++; break; // Invalid character, exit loop } } @@ -257,6 +272,7 @@ U0 Telnet(U8 *host, U16 port=TELNET_PORT) { ptr++; } } + skip_input = WaitForInputOrTimeout(TIMEOUT_DURATION); if (!skip_input) @@ -326,6 +342,9 @@ U0 TelnetPrompt() { // Dev auto-connect to test server // Telnet("mbrserver.com"); -Telnet("freechess.org"); -//Telnet("dura-bbs.net", 6359); -//Telnet("darkrealms.ca"); \ No newline at end of file +// Telnet("freechess.org"); +// Telnet("dura-bbs.net", 6359); +// Telnet("darkrealms.ca"); + +// ZealBBS dev server +Telnet("localhost", 8888); \ No newline at end of file