Send characters as you type

This commit is contained in:
y4my4my4m 2023-05-11 19:27:51 +09:00
parent e27ec865c8
commit 741c0394b7

View file

@ -3,6 +3,7 @@
#define TELNET_PORT 23 #define TELNET_PORT 23
#define BUF_SIZE 8192 // way too big? #define BUF_SIZE 8192 // way too big?
#define INPUT_BUF_SIZE 32
#define TIMEOUT_DURATION 5000 #define TIMEOUT_DURATION 5000
#define NEGOTIATE 0xFF #define NEGOTIATE 0xFF
@ -97,7 +98,7 @@ U0 InputTask(U0 *args) {
// DocCursor; // DocCursor;
// WinBorder(OFF); // WinBorder(OFF);
U8 input_buffer[BUF_SIZE]; U8 input_buffer[INPUT_BUF_SIZE];
U8 *temp, ch; U8 *temp, ch;
I64 sc; I64 sc;
U8 *line = input_buffer; U8 *line = input_buffer;
@ -137,7 +138,7 @@ U0 InputTask(U0 *args) {
TCPSocketSendString(sock, "\x1B[B"); TCPSocketSendString(sock, "\x1B[B");
break; break;
case SC_TAB: case SC_TAB:
TCPSocketSendString(sock, 0x09); TCPSocketSend(sock, 0x09, 0);
break; break;
default: default:
break; break;
@ -145,7 +146,7 @@ U0 InputTask(U0 *args) {
break; break;
case CH_ESC: case CH_ESC:
TCPSocketSendString(sock, 0x27); TCPSocketSend(sock, 0x27, 0);
break; break;
case CH_SHIFT_ESC: case CH_SHIFT_ESC:
force_disconnect = TRUE; force_disconnect = TRUE;
@ -158,7 +159,7 @@ U0 InputTask(U0 *args) {
input_len = 0; input_len = 0;
Free(temp); Free(temp);
MemSet(input_buffer, 0, BUF_SIZE); MemSet(input_buffer, 0, INPUT_BUF_SIZE);
DocClear; DocClear;
DocBottom(input_task->put_doc); DocBottom(input_task->put_doc);
@ -168,7 +169,17 @@ U0 InputTask(U0 *args) {
if (key >= ' ' && key <= '~') { if (key >= ' ' && key <= '~') {
// Handle regular keys // Handle regular keys
input_buffer[input_len++] = key; input_buffer[input_len++] = key;
DocPrint(input_task->put_doc, "%c", key); // DocPrint(input_task->put_doc, "%c", key);
temp = MStrPrint("%s", input_buffer);
TCPSocketSendString(sock, temp);
input_len = 0;
Free(temp);
MemSet(input_buffer, 0, INPUT_BUF_SIZE);
DocClear;
DocBottom(input_task->put_doc);
"\n$$RED$$$BK,1$Input$BK,0$$$BLACK$$:";
} }
break; break;
} }