mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2024-12-25 23:10:32 +00:00
telnet cleanup
This commit is contained in:
parent
7d9d6c4d65
commit
85b5eca553
2 changed files with 22 additions and 54 deletions
|
@ -79,7 +79,6 @@ I64 TelnetOpen(U8 *host, U16 port) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// sock(CTCPSocket *)->timeout = TCP_TIMEOUT;
|
// sock(CTCPSocket *)->timeout = TCP_TIMEOUT;
|
||||||
|
|
||||||
return sock;
|
return sock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +145,7 @@ U0 InputTask(U0 *args) {
|
||||||
break;
|
break;
|
||||||
// send buffer on enter
|
// send buffer on enter
|
||||||
case '\n':
|
case '\n':
|
||||||
SysLog(input_buffer);
|
// SysLog(input_buffer);
|
||||||
temp = MStrPrint("%s\r\n", input_buffer);
|
temp = MStrPrint("%s\r\n", input_buffer);
|
||||||
TCPSocketSendString(sock, temp);
|
TCPSocketSendString(sock, temp);
|
||||||
|
|
||||||
|
@ -178,13 +177,6 @@ U0 Telnet(U8 *host, U16 port=TELNET_PORT) {
|
||||||
I64 window_width = 80;
|
I64 window_width = 80;
|
||||||
I64 window_height = 25;
|
I64 window_height = 25;
|
||||||
|
|
||||||
// I64 window_left = (GR_WIDTH - window_width) / 2;
|
|
||||||
// I64 window_top = (Fs->win_bottom - Fs->win_top - window_height+1) / 2;
|
|
||||||
|
|
||||||
// WinHorz(Fs->win_left, Fs->win_left+window_width, Fs);
|
|
||||||
// WinVert(Fs->win_top + window_top, Fs->win_top + window_top + window_height+1, Fs);
|
|
||||||
|
|
||||||
|
|
||||||
Fs->win_width = window_width;
|
Fs->win_width = window_width;
|
||||||
WinHorz((TEXT_COLS / 2) - (Fs->win_width / 2),
|
WinHorz((TEXT_COLS / 2) - (Fs->win_width / 2),
|
||||||
(TEXT_COLS / 2) - (Fs->win_width / 2) +
|
(TEXT_COLS / 2) - (Fs->win_width / 2) +
|
||||||
|
@ -195,17 +187,17 @@ U0 Telnet(U8 *host, U16 port=TELNET_PORT) {
|
||||||
(TEXT_ROWS / 2) - (Fs->win_height / 2) +
|
(TEXT_ROWS / 2) - (Fs->win_height / 2) +
|
||||||
(Fs->win_height - 1),
|
(Fs->win_height - 1),
|
||||||
Fs);
|
Fs);
|
||||||
DocPrint(, "$$WW,1$$");
|
DocClear;
|
||||||
// DocCursor(OFF);
|
|
||||||
|
|
||||||
// WinToTop(Fs);
|
// probably should use word wrap?
|
||||||
// WinFocus(Fs);
|
// DocPrint(, "$$WW,1$$");
|
||||||
|
|
||||||
sock = TelnetOpen(host, port);
|
sock = TelnetOpen(host, port);
|
||||||
if (sock <= 0) {
|
if (sock <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Spawn input window
|
||||||
input_task = Spawn(&InputTask, &sock, "Telnet Input");
|
input_task = Spawn(&InputTask, &sock, "Telnet Input");
|
||||||
input_task->win_inhibit = WIG_USER_TASK_DEFAULT;
|
input_task->win_inhibit = WIG_USER_TASK_DEFAULT;
|
||||||
LBts(&input_task->display_flags, DISPLAYf_SHOW);
|
LBts(&input_task->display_flags, DISPLAYf_SHOW);
|
||||||
|
@ -216,8 +208,6 @@ U0 Telnet(U8 *host, U16 port=TELNET_PORT) {
|
||||||
input_task->win_left = Fs->win_left;
|
input_task->win_left = Fs->win_left;
|
||||||
input_task->win_right = Fs->win_left+window_width - 1;
|
input_task->win_right = Fs->win_left+window_width - 1;
|
||||||
|
|
||||||
DocClear;
|
|
||||||
|
|
||||||
"$$BG,RED$$$$WHITE$$Connected$$FG$$$$BG$$\n";
|
"$$BG,RED$$$$WHITE$$Connected$$FG$$$$BG$$\n";
|
||||||
|
|
||||||
while (!force_disconnect) {
|
while (!force_disconnect) {
|
||||||
|
@ -405,7 +395,7 @@ U0 Telnet(U8 *host, U16 port=TELNET_PORT) {
|
||||||
if (col > window_width)
|
if (col > window_width)
|
||||||
col = window_width-1;
|
col = window_width-1;
|
||||||
|
|
||||||
// SysLog("H or f AFTER row:%d, col:%d, cnt:%d\n", row, col, ansi_param_count);
|
SysLog("H or f AFTER row:%d, col:%d, cnt:%d\n", row, col, ansi_param_count);
|
||||||
// "$$CM,%d,%d$$", row, col;
|
// "$$CM,%d,%d$$", row, col;
|
||||||
"$$CM,LE=%d,RE=%d$$", row, col;
|
"$$CM,LE=%d,RE=%d$$", row, col;
|
||||||
ptr++;
|
ptr++;
|
||||||
|
@ -471,16 +461,8 @@ U0 Telnet(U8 *host, U16 port=TELNET_PORT) {
|
||||||
|
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case 25:
|
case 25:
|
||||||
if (*ptr == 'l') {
|
if (*ptr == 'l') DocCursor(OFF); // Hide cursor
|
||||||
// Hide cursor
|
if (*ptr == 'h') DocCursor(ON); // Show 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:
|
||||||
|
@ -530,19 +512,6 @@ U0 Telnet(U8 *host, U16 port=TELNET_PORT) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// is this handled by the client or the server?
|
|
||||||
// regardless, this is not taking <esc> into account, any actual | is captured
|
|
||||||
// else if (*ptr == '|') {
|
|
||||||
// // U8 code[3];
|
|
||||||
// // code[0] = ptr++;
|
|
||||||
// // code[1] = ptr++;
|
|
||||||
// // code[2] = '\0';
|
|
||||||
// // I64 fg_code = ToI64(code);
|
|
||||||
// // AppendColorString(fg_code);
|
|
||||||
// SysLog("Pipe code: %c%c\n", ptr[1], ptr[2]);
|
|
||||||
// ptr += 3; // Skip the pipe code characters
|
|
||||||
// // ptr++;
|
|
||||||
// }
|
|
||||||
else {
|
else {
|
||||||
// Print the received character
|
// Print the received character
|
||||||
HandleControlCodes(*ptr);
|
HandleControlCodes(*ptr);
|
||||||
|
@ -557,7 +526,6 @@ U0 Telnet(U8 *host, U16 port=TELNET_PORT) {
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// SysLog("Error: %0x%02X\n", ch);
|
|
||||||
"Error: Connection closed by the remote host.\n";
|
"Error: Connection closed by the remote host.\n";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -575,20 +543,6 @@ U0 Telnet(U8 *host, U16 port=TELNET_PORT) {
|
||||||
"Telnet connection closed.\n";
|
"Telnet connection closed.\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
class CHostForm {
|
|
||||||
U8 host[256] format "$$DA-P,LEN=255,A=\"Host:%s\"$$";
|
|
||||||
U16 port format "A=\"Port:%d\"";
|
|
||||||
};
|
|
||||||
|
|
||||||
U0 TelnetPrompt() {
|
|
||||||
CHostForm form;
|
|
||||||
|
|
||||||
form.host[0] = 0;
|
|
||||||
form.port = TELNET_PORT;
|
|
||||||
if (PopUpForm(&form)) {
|
|
||||||
Telnet(form.host, form.port);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// dev server
|
// dev server
|
||||||
Telnet("localhost", 8888);
|
Telnet("localhost", 8888);
|
14
src/Home/Telnet/TelnetPrompt.ZC
Normal file
14
src/Home/Telnet/TelnetPrompt.ZC
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
class CHostForm {
|
||||||
|
U8 host[256] format "$$DA-P,LEN=255,A=\"Host:%s\"$$";
|
||||||
|
U16 port format "A=\"Port:%d\"";
|
||||||
|
};
|
||||||
|
|
||||||
|
U0 TelnetPrompt() {
|
||||||
|
CHostForm form;
|
||||||
|
|
||||||
|
form.host[0] = 0;
|
||||||
|
form.port = TELNET_PORT;
|
||||||
|
if (PopUpForm(&form)) {
|
||||||
|
Telnet(form.host, form.port);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue