mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2024-12-25 23:10:32 +00:00
linemode
This commit is contained in:
parent
366c3831fc
commit
38a21812a3
1 changed files with 23 additions and 12 deletions
|
@ -2,7 +2,7 @@
|
||||||
// Public Domain
|
// Public Domain
|
||||||
|
|
||||||
#define TELNET_PORT 23
|
#define TELNET_PORT 23
|
||||||
#define BUF_SIZE 2048 // way too big?
|
#define BUF_SIZE 4096 // way too big?
|
||||||
#define TIMEOUT_DURATION 5000
|
#define TIMEOUT_DURATION 5000
|
||||||
|
|
||||||
#define NEGOTIATE 0xFF
|
#define NEGOTIATE 0xFF
|
||||||
|
@ -14,6 +14,7 @@
|
||||||
#define ECHO 0x01
|
#define ECHO 0x01
|
||||||
#define SUPPRESS_GO_AHEAD 0x03
|
#define SUPPRESS_GO_AHEAD 0x03
|
||||||
#define TERMINAL_TYPE 0x18
|
#define TERMINAL_TYPE 0x18
|
||||||
|
#define LINEMODE 0x22
|
||||||
#define NAWS 0x1F
|
#define NAWS 0x1F
|
||||||
#define IS 0x00
|
#define IS 0x00
|
||||||
#define SE 0xF0
|
#define SE 0xF0
|
||||||
|
@ -98,7 +99,7 @@ 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
|
||||||
|
@ -198,6 +199,13 @@ U0 Telnet(U8 *host, U16 port=TELNET_PORT) {
|
||||||
} else {
|
} else {
|
||||||
response[1] = WONT;
|
response[1] = WONT;
|
||||||
}
|
}
|
||||||
|
} else if (option_code == LINEMODE) {
|
||||||
|
if (negotiation_code == DO) {
|
||||||
|
response[1] = WILL;
|
||||||
|
// Do we need LINEMODE?
|
||||||
|
} else {
|
||||||
|
response[1] = WONT;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
response[1] = WONT;
|
response[1] = WONT;
|
||||||
}
|
}
|
||||||
|
@ -233,17 +241,21 @@ U0 Telnet(U8 *host, U16 port=TELNET_PORT) {
|
||||||
else {
|
else {
|
||||||
// this helps for ANSI detection
|
// this helps for ANSI detection
|
||||||
if (*ptr == 'n') {
|
if (*ptr == 'n') {
|
||||||
if (ansi_code == 6) {
|
if (ansi_code == 5) {
|
||||||
|
// Respond with terminal readiness
|
||||||
|
SysLog("reported terminal readiness\n");
|
||||||
|
TCPSocketSendString(sock, "\x1B[0n");
|
||||||
|
}
|
||||||
|
else if (ansi_code == 6) {
|
||||||
// Respond with cursor position
|
// Respond with cursor position
|
||||||
// U8 response[32] = "\x1B[%d;%dR", window_width, window_height;
|
// U8 response[32] = "\x1B[%d;%dR", window_width, window_height;
|
||||||
|
SysLog("reported cursor position\n");
|
||||||
TCPSocketSendString(sock, "\x1B[25;80R");
|
TCPSocketSendString(sock, "\x1B[25;80R");
|
||||||
} else if (ansi_code == 5) {
|
|
||||||
// Respond with terminal readiness
|
|
||||||
TCPSocketSendString(sock, "\x1B[0n");
|
|
||||||
}
|
}
|
||||||
ptr++;
|
ptr++;
|
||||||
} else if (*ptr == 'c') {
|
} else if (*ptr == 'c') {
|
||||||
// Respond with device attributes
|
// Respond with device attributes
|
||||||
|
SysLog("reported device attributes\n");
|
||||||
TCPSocketSendString(sock, "\x1B[?1;0c");
|
TCPSocketSendString(sock, "\x1B[?1;0c");
|
||||||
ptr++;
|
ptr++;
|
||||||
} else if (*ptr == 'm') {
|
} else if (*ptr == 'm') {
|
||||||
|
@ -344,16 +356,15 @@ U0 Telnet(U8 *host, U16 port=TELNET_PORT) {
|
||||||
ptr++;
|
ptr++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// SysLog("?%d\n", code);
|
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case 25:
|
case 25:
|
||||||
if (*ptr == 'l') SysLog("code 25l");// Hide cursor
|
if (*ptr == 'l') SysLog("code 25l\n");// Hide cursor
|
||||||
if (*ptr == 'h') SysLog("code 25h");// Show cursor
|
if (*ptr == 'h') SysLog("code 25h\n");// Show cursor
|
||||||
ptr++; // Move past 'l' or 'h'
|
ptr++; // Move past 'l' or 'h'
|
||||||
break;
|
break;
|
||||||
case 1049:
|
case 1049:
|
||||||
if (*ptr == 'l') SysLog("code 1049l"); // Save screen and switch to alternate screen buffer
|
if (*ptr == 'l') SysLog("code 1049l\n"); // Save screen and switch to alternate screen buffer
|
||||||
if (*ptr == 'h') SysLog("code 1049h"); // Restore screen and switch back to main screen buffer
|
if (*ptr == 'h') SysLog("code 1049h\n"); // Restore screen and switch back to main screen buffer
|
||||||
ptr++; // Move past 'l' or 'h'
|
ptr++; // Move past 'l' or 'h'
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in a new issue