This commit is contained in:
y4my4my4m 2023-05-10 23:26:55 +09:00
parent c820e5b726
commit b64d0bb563
2 changed files with 69 additions and 10 deletions

View file

@ -26,13 +26,15 @@ U0 HandleControlCodes(U8 ch) {
case 0: // NUL (Null) - Typically ignored case 0: // NUL (Null) - Typically ignored
break; break;
case 7: // BEL (Bell) case 7: // BEL (Bell)
// Beep; Beep;
break; break;
case 8: // BS (Backspace) case 8: // BS (Backspace)
"%c%c%c", 8, ' ', 8; // Move cursor back, erase character, move cursor back again // "%c%c%c", 8, ' ', 8; // Move cursor back, erase character, move cursor back again
"$$CM,-8,0$$";
break; break;
case 9: // HT (Horizontal Tab) case 9: // HT (Horizontal Tab)
" "; // 8 spaces // " "; // 8 spaces
"$$CM,8,0$$";
break; break;
case 10: // LF (Line Feed) case 10: // LF (Line Feed)
"\n"; "\n";
@ -117,9 +119,9 @@ U0 InputTask(U0 *args) {
TCPSocketSendString(sock, 0x27); TCPSocketSendString(sock, 0x27);
break; break;
} }
else if (ch == CH_BACKSPACE) { // else if (ch == CH_BACKSPACE) {
break; // break;
} // }
else if (ch == 0x0F) { // TAB? else if (ch == 0x0F) { // TAB?
TCPSocketSendString(sock, 0x09); TCPSocketSendString(sock, 0x09);
break; break;
@ -366,7 +368,7 @@ U0 Telnet(U8 *host, U16 port=TELNET_PORT) {
// Not sure if really should do -1... // Not sure if really should do -1...
if (row > window_height) if (row > window_height)
row = window_heigh-1; row = window_height-1;
if (col > window_width) if (col > window_width)
col = window_width-1; col = window_width-1;
@ -375,7 +377,7 @@ U0 Telnet(U8 *host, U16 port=TELNET_PORT) {
ptr++; ptr++;
break; break;
case 'J': case 'J':
// SysLog("J code\n"); // SysLog("J code, %d %d\n", ansi_param_count, ansi_code[0]);
// Erase in Display // Erase in Display
if (ansi_code[0] == 0) { if (ansi_code[0] == 0) {
// Erase from cursor to end of display // Erase from cursor to end of display
@ -433,8 +435,16 @@ U0 Telnet(U8 *host, U16 port=TELNET_PORT) {
switch (code) { switch (code) {
case 25: case 25:
// if (*ptr == 'l') SysLog("code 25l\n");// Hide cursor if (*ptr == 'l') {
// if (*ptr == 'h') SysLog("code 25h\n");// Show cursor // Hide cursor
// SysLog("code 25l\n");
DocCursor(OFF);
}
if (*ptr == 'h') {
// Show cursor
// SysLog("code 25h\n");
DocCursor(ON);
}
ptr++; // Move past 'l' or 'h' ptr++; // Move past 'l' or 'h'
break; break;
case 47: case 47:

View file

@ -1,3 +1,52 @@
#define IAC 0xFF
#define WILL 0xFB
#define WONT 0xFC
#define DO 0xFD
#define DONT 0xFE
#define ECHO 0x01
#define SUPPRESS_GO_AHEAD 0x03
#define TERMINAL_TYPE 0x18
#define LINEMODE 0x22
#define NAWS 0x1F // (Negotiate About Window Size)
#define IS 0x00
#define SB 0xFA
#define SE 0xF0
U0 SendWindowSize(I64 sock, U16 rows, U16 cols) {
U8 buf[9];
buf[0] = IAC;
buf[1] = SB;
buf[2] = NAWS;
buf[3] = cols >> 8; // High byte of columns
buf[4] = cols & 0xFF; // Low byte of columns
buf[5] = rows >> 8; // High byte of rows
buf[6] = rows & 0xFF; // Low byte of rows
buf[7] = IAC;
buf[8] = SE;
SysLog("SendWindowSize: %d x %d\n", cols, rows);
TCPSocketSendString(sock, buf);
}
U0 SendTerminalType(I64 sock, U8 *terminal_type) {
U8 response[256];
I64 len = StrLen(terminal_type);
response[0] = IAC;
response[1] = SB;
response[2] = TERMINAL_TYPE;
response[3] = IS;
MemCopy(response + 4, terminal_type, len);
SysLog("SendTerminalType: %s\n", terminal_type);
response[len + 4] = IAC;
response[len + 5] = SE;
response[len + 6] = '\0';
TCPSocketSendString(sock, response);
}
U0 TelnetNegotiate() U0 TelnetNegotiate()
{ {
U8 negotiation_code = *(ptr + 1); U8 negotiation_code = *(ptr + 1);