mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2024-12-24 22:50:28 +00:00
backspace fixed
This commit is contained in:
parent
1fe467a1cf
commit
5862425d45
2 changed files with 146 additions and 39 deletions
|
@ -20,7 +20,7 @@ Cd(__DIR__);;
|
|||
|
||||
// If you're using a custom palette, the colors might not seem right.
|
||||
CBGR24 original_palette[COLORS_NUM];
|
||||
Bool dark_mode = FALSE;
|
||||
Bool dark_mode = TRUE; // since ZealOS is dark by default
|
||||
Bool original_colors = FALSE;
|
||||
Bool force_disconnect = FALSE;
|
||||
|
||||
|
@ -53,7 +53,7 @@ U0 HandleControlCodes(U8 ch) {
|
|||
break;
|
||||
case 8: // BS (Backspace)
|
||||
// "%c%c%c", 8, ' ', 8; // Move cursor back, erase character, move cursor back again
|
||||
DocPrint(term.doc, "$$CM,-8,0$$");
|
||||
DocPrint(term.doc, "$$CM,-1,0$$");
|
||||
break;
|
||||
case 9: // HT (Horizontal Tab)
|
||||
// " "; // 8 spaces
|
||||
|
@ -66,7 +66,9 @@ U0 HandleControlCodes(U8 ch) {
|
|||
SysLog("Vertical Tab\n");
|
||||
break;
|
||||
case 12: // FF (Form Feed)
|
||||
SysLog("form feed");
|
||||
DocClear(term.doc);
|
||||
// DocPrint(term.doc, "\f");
|
||||
break;
|
||||
case 13: // CR (Carriage Return)
|
||||
DocPrint(term.doc, "\r");
|
||||
|
@ -108,7 +110,7 @@ U0 HandleControlCodes(U8 ch) {
|
|||
default:
|
||||
// some ch make Zeal crash or behave weird because they're commands?
|
||||
// SysLog("CC %c happened\n", ch);
|
||||
SysLog("CC happened\n");
|
||||
SysLog("CC 0x%X happened\n", ch);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -487,18 +489,20 @@ U0 ANSIParse()
|
|||
ptr++;
|
||||
break;
|
||||
}
|
||||
// SysLog("H or f AFTER row:%d, col:%d, cnt:%d\n", row, col, ansi_param_count);
|
||||
// row--;
|
||||
// col--;
|
||||
SysLog("H or f row:%d, col:%d, cnt:%d\n", row, col, ansi_param_count);
|
||||
|
||||
if (row > term.window_height)
|
||||
row = term.window_height-1;
|
||||
if (col > term.window_width)
|
||||
col = term.window_width-1;
|
||||
// if (row > term.window_height)
|
||||
// row = term.window_height-1;
|
||||
// else if (col > term.window_width)
|
||||
// col = term.window_width-1;
|
||||
// "$$CM,0,0$$";
|
||||
DocPrint(term.doc, "$$CM+LX+TY,LE=%d,RE=%d$$", col-1, row-1);
|
||||
ptr++;
|
||||
break;
|
||||
case 'J':
|
||||
// SysLog("J code, %d %d\n", ansi_param_count, ansi_code[0]);
|
||||
SysLog("J code, %d %d\n", ansi_param_count, ansi_code[0]);
|
||||
// Erase in Display
|
||||
if (ansi_code[0] == 0) {
|
||||
// Erase from cursor to end of display
|
||||
|
@ -534,6 +538,7 @@ U0 ANSIParse()
|
|||
break;
|
||||
case 'L':
|
||||
SysLog("L code\n");
|
||||
// DocPrint(term.doc, "\n");
|
||||
ptr++;
|
||||
break;
|
||||
case 'S':
|
||||
|
@ -601,13 +606,37 @@ U0 ANSIParse()
|
|||
SysLog("h or l case \n");
|
||||
ptr++; // Skip 'h' or 'l'
|
||||
break;
|
||||
case 't':
|
||||
// for (m = 0; m <= ansi_param_count; m++) {
|
||||
// // SysLog("ansi_code[%d]: %d\n", m, ansi_code[m]);
|
||||
// }
|
||||
if (ansi_param_count == 3) {
|
||||
if (ansi_code[0] == 8) {
|
||||
term.window_width = ansi_code[1];
|
||||
term.window_height = ansi_code[2];
|
||||
Fs->win_width = term.window_width;
|
||||
WinHorz((TEXT_COLS / 2) - (Fs->win_width / 2),
|
||||
(TEXT_COLS / 2) - (Fs->win_width / 2) +
|
||||
(Fs->win_width - 1),
|
||||
Fs);
|
||||
Fs->win_height = term.window_height;
|
||||
WinVert((TEXT_ROWS / 2) - (Fs->win_height / 2),
|
||||
(TEXT_ROWS / 2) - (Fs->win_height / 2) +
|
||||
(Fs->win_height - 1),
|
||||
Fs);
|
||||
}
|
||||
}
|
||||
|
||||
ptr++;
|
||||
break;
|
||||
case '=':
|
||||
SysLog("ScreenMode attempt\n");
|
||||
ptr++;
|
||||
break;
|
||||
default:
|
||||
if(!IsDigit(*ptr)) {
|
||||
SysLog("Unknown code: %c\n", *ptr);
|
||||
// if(!IsDigit(*ptr)) {
|
||||
if(*ptr > 32) {
|
||||
SysLog("Unknown code: 0x%X\n", *ptr);
|
||||
}
|
||||
ptr++;
|
||||
break;
|
||||
|
@ -774,8 +803,32 @@ init_connection:
|
|||
default:
|
||||
break;
|
||||
}
|
||||
case 255:
|
||||
switch (sc.u8[0])
|
||||
{
|
||||
case SC_PAGE_UP: if (term.sock_ready) TCPSocketSendString(term.sock, "\033[V"); break;
|
||||
case SC_PAGE_DOWN:if (term.sock_ready) TCPSocketSendString(term.sock, "\033[U"); break;
|
||||
case SC_HOME: if (term.sock_ready) TCPSocketSendString(term.sock, "\033[H"); break;
|
||||
case SC_END: if (term.sock_ready) TCPSocketSendString(term.sock, "\033[K"); break;
|
||||
case SC_DELETE: if (term.sock_ready) TCPSocketSendString(term.sock, "\x7F"); break;
|
||||
case SC_F1: if (term.sock_ready) TCPSocketSendString(term.sock, "\033OP"); break;
|
||||
case SC_F2: if (term.sock_ready) TCPSocketSendString(term.sock, "\033OQ"); break;
|
||||
case SC_F3: if (term.sock_ready) TCPSocketSendString(term.sock, "\033OR"); break;
|
||||
case SC_F4: if (term.sock_ready) TCPSocketSendString(term.sock, "\033OS"); break;
|
||||
case SC_F5: if (term.sock_ready) TCPSocketSendString(term.sock, "\033Ot"); break;
|
||||
case SC_F6: if (term.sock_ready) TCPSocketSendString(term.sock, "\033[17~"); break;
|
||||
case SC_F7: if (term.sock_ready) TCPSocketSendString(term.sock, "\033[18~"); break;
|
||||
case SC_F8: if (term.sock_ready) TCPSocketSendString(term.sock, "\033[19~"); break;
|
||||
case SC_F9: if (term.sock_ready) TCPSocketSendString(term.sock, "\033[20~"); break;
|
||||
case SC_F10: if (term.sock_ready) TCPSocketSendString(term.sock, "\033[21~"); break;
|
||||
case SC_F11: if (term.sock_ready) TCPSocketSendString(term.sock, "\033[23~"); break;
|
||||
case SC_F12: if (term.sock_ready) TCPSocketSendString(term.sock, "\033[24~"); break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
case CH_BACKSPACE:
|
||||
if (term.sock_ready) TCPSocketSendString(term.sock, "\x08");
|
||||
if (term.sock_ready) TCPSocketSendString(term.sock, "\x7F");
|
||||
break;
|
||||
case CH_ESC:
|
||||
if (term.sock_ready) TCPSocketSendString(term.sock, "\x1B");
|
||||
|
|
|
@ -12,15 +12,33 @@
|
|||
#define SB 0xFA
|
||||
#define SE 0xF0
|
||||
|
||||
U0 SendWindowSize(I64 sock, U16 rows, U16 cols) {
|
||||
// #define TELNET_IAC 255 /* 0xff - Interpret as command */
|
||||
// #define TELNET_DONT 254 /* 0xfe - Don't do option */
|
||||
// #define TELNET_DO 253 /* 0xfd - Do option */
|
||||
// #define TELNET_WONT 252 /* 0xfc - Won't do option */
|
||||
// #define TELNET_WILL 251 /* 0xfb - Will do option */
|
||||
|
||||
// #define TELNET_SB 250 /* 0xfa - sub-negotiation */
|
||||
// #define TELNET_GA 249 /* 0xf9 - Go ahead */
|
||||
// #define TELNET_EL 248 /* 0xf8 - Erase line */
|
||||
// #define TELNET_EC 247 /* 0xf7 - Erase char */
|
||||
// #define TELNET_AYT 246 /* 0xf6 - Are you there? */
|
||||
// #define TELNET_AO 245 /* 0xf5 - Abort output */
|
||||
// #define TELNET_IP 244 /* 0xf4 - Interrupt process */
|
||||
// #define TELNET_BRK 243 /* 0xf3 - Break */
|
||||
// #define TELNET_SYNC 242 /* 0xf2 - Data mark */
|
||||
// #define TELNET_NOP 241 /* 0xf1 - No operation */
|
||||
|
||||
U0 SendWindowSize(I64 sock, U16 rows, U16 cols)
|
||||
{
|
||||
U8 buf[9];
|
||||
|
||||
buf[0] = IAC;
|
||||
buf[1] = SB;
|
||||
buf[1] = SB;
|
||||
buf[2] = NAWS;
|
||||
buf[3] = cols >> 8; // High byte of columns
|
||||
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[5] = rows >> 8; // High byte of rows
|
||||
buf[6] = rows & 0xFF; // Low byte of rows
|
||||
buf[7] = IAC;
|
||||
buf[8] = SE;
|
||||
|
@ -29,7 +47,8 @@ U0 SendWindowSize(I64 sock, U16 rows, U16 cols) {
|
|||
TCPSocketSendString(sock, buf);
|
||||
}
|
||||
|
||||
U0 SendTerminalType(I64 sock, U8 *terminal_type) {
|
||||
U0 SendTerminalType(I64 sock, U8 *terminal_type)
|
||||
{
|
||||
U8 response[256];
|
||||
I64 len = StrLen(terminal_type);
|
||||
|
||||
|
@ -56,49 +75,84 @@ U0 TelnetNegotiate(I64 sock, U8 ptr)
|
|||
U8 response[4];
|
||||
response[0] = IAC;
|
||||
|
||||
if (negotiation_code == DO || negotiation_code == DONT) {
|
||||
if (option_code == ECHO) {
|
||||
if (negotiation_code == DO) {
|
||||
if (negotiation_code == DO || negotiation_code == DONT)
|
||||
{
|
||||
if (option_code == ECHO)
|
||||
{
|
||||
if (negotiation_code == DO)
|
||||
{
|
||||
response[1] = WILL;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
response[1] = WONT;
|
||||
}
|
||||
} else if (option_code == SUPPRESS_GO_AHEAD) {
|
||||
if (negotiation_code == DO) {
|
||||
}
|
||||
else if (option_code == SUPPRESS_GO_AHEAD)
|
||||
{
|
||||
if (negotiation_code == DO)
|
||||
{
|
||||
response[1] = WILL;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
response[1] = WONT;
|
||||
}
|
||||
} else if (option_code == TERMINAL_TYPE) {
|
||||
if (negotiation_code == DO) {
|
||||
}
|
||||
else if (option_code == TERMINAL_TYPE)
|
||||
{
|
||||
if (negotiation_code == DO)
|
||||
{
|
||||
response[1] = WILL;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
response[1] = WONT;
|
||||
}
|
||||
} else if (option_code == NAWS) {
|
||||
if (negotiation_code == DO) {
|
||||
}
|
||||
else if (option_code == NAWS)
|
||||
{
|
||||
if (negotiation_code == DO)
|
||||
{
|
||||
response[1] = WILL;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
response[1] = WONT;
|
||||
}
|
||||
} else if (option_code == LINEMODE) {
|
||||
if (negotiation_code == DO) {
|
||||
}
|
||||
else if (option_code == LINEMODE)
|
||||
{
|
||||
if (negotiation_code == DO)
|
||||
{
|
||||
response[1] = WILL;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
response[1] = WONT;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
response[1] = WONT;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
response[1] = DONT;
|
||||
}
|
||||
|
||||
response[2] = option_code;
|
||||
response[3] = '\0';
|
||||
// TCPSocketSendString(sock, response);
|
||||
// the bugged out SendTerminalType and SendWindowsSize was what crashed the BBS...
|
||||
// if (option_code == TERMINAL_TYPE) SendTerminalType(sock, "ANSI-BBS");
|
||||
// else if (option_code == NAWS) SendWindowSize(sock, 25, 80);
|
||||
|
||||
if (term.sock_ready)
|
||||
{
|
||||
TCPSocketSendString(sock, response);
|
||||
// the bugged out SendTerminalType and SendWindowsSize was what crashed the BBS...
|
||||
if (option_code == TERMINAL_TYPE) SendTerminalType(sock, "ANSI-BBS");
|
||||
else if (option_code == NAWS) SendWindowSize(sock, 25, 80);
|
||||
// TCPSocketSendString(term.sock, "\xdb\b \xdb\b \xdb\b[\xdb\b[\xdb\b \xdb\bM\xdb\ba\xdb\bi\xdb\bn\xdb\bt\xdb\be\xdb\bn\xdb\ba\xdb\bn\xdb\bc\xdb\be\xdb\b \xdb\bC\xdb\bo\xdb\bm\xdb\bp\xdb\bl\xdb\be\xdb\bt\xdb\be\xdb\b \xdb\b]\xdb\b]\xdb\b \b\r\n\r\n\x1b[0m\x1b[2J\r\n\r\n\x1b[0;1;30mHX Force retinal scan in progress ... \x1b[0;0;30m");
|
||||
// TCPSocketSendString(term.sock, "\033[s\033[99B\033[99B\033[99B_\033[99C\033[99C\033[99C_\033[6n\033[u\033[0m_\033[2J\033[H");
|
||||
}
|
||||
ptr += 3;
|
||||
}
|
Loading…
Reference in a new issue