Skip to content

Commit b99afac

Browse files
committed
feat: support virtual terminal input
1 parent 7ae18c1 commit b99afac

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

conpty_proxy.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,9 @@ static int stdio_run(conpty_t* pty) {
298298
DWORD readed = 0;
299299
DWORD writted = 0;
300300
while (1) {
301-
if (!ReadFile(GetStdHandle(STD_INPUT_HANDLE), pty->std_buf, 1, &readed, NULL)) {
301+
if (!ReadFile(GetStdHandle(STD_INPUT_HANDLE), pty->std_buf, sizeof(pty->std_buf), &readed, NULL)) {
302302
return -1;
303303
}
304-
305304
if (!WriteFile(pty->io_write, pty->std_buf, readed, &writted, NULL)) {
306305
return -1;
307306
}
@@ -318,6 +317,14 @@ static void setup_console(void) {
318317
SetConsoleOutputCP(CP_UTF8);
319318
SetConsoleCP(CP_UTF8);
320319
setlocale(LC_ALL, ".UTF-8");
320+
321+
HANDLE in = GetStdHandle(STD_INPUT_HANDLE);
322+
DWORD mode;
323+
324+
GetConsoleMode(in, &mode);
325+
mode &= ~(ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT);
326+
mode |= ENABLE_VIRTUAL_TERMINAL_INPUT;
327+
SetConsoleMode(in, mode);
321328
}
322329

323330
static int conpty_new(int argc, wchar_t* argv[]) {

0 commit comments

Comments
 (0)