From 83626b6bc2f4307188b0d30071439a2ba72b5328 Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Fri, 8 Mar 2013 12:56:32 +0100 Subject: [PATCH] win/tty: don't touch insert mode or quick edit mode This is a back-port of 4abad23, whichi is supposed to fix joyent/node#4809. The private `original_console_mode` field in the uv_tty_t struct has been renamed, but couldn't be removed because changing the ABI isn't allowed on stable branches. --- include/uv-private/uv-win.h | 2 +- src/win/tty.c | 16 +++------------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/include/uv-private/uv-win.h b/include/uv-private/uv-win.h index 5b0aba619..8c49b5952 100644 --- a/include/uv-private/uv-win.h +++ b/include/uv-private/uv-win.h @@ -383,7 +383,7 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s); HANDLE read_line_handle; \ uv_buf_t read_line_buffer; \ HANDLE read_raw_wait; \ - DWORD original_console_mode; \ + DWORD dummy_original_console_mode; \ /* Fields used for translating win */ \ /* keystrokes into vt100 characters */ \ char last_key[8]; \ diff --git a/src/win/tty.c b/src/win/tty.c index f026bcd47..a01b9f9cd 100644 --- a/src/win/tty.c +++ b/src/win/tty.c @@ -100,11 +100,6 @@ int uv_tty_init(uv_loop_t* loop, uv_tty_t* tty, uv_file fd, int readable) { return -1; } - if (!GetConsoleMode(win_handle, &tty->original_console_mode)) { - uv__set_sys_error(loop, GetLastError()); - return -1; - } - /* Initialize virtual window size; if it fails, assume that this is stdin. */ if (GetConsoleScreenBufferInfo(win_handle, &info)) { EnterCriticalSection(&uv_tty_output_lock); @@ -143,7 +138,7 @@ int uv_tty_init(uv_loop_t* loop, uv_tty_t* tty, uv_file fd, int readable) { int uv_tty_set_mode(uv_tty_t* tty, int mode) { - DWORD flags = 0; + DWORD flags; unsigned char was_reading; uv_alloc_cb alloc_cb; uv_read_cb read_cb; @@ -152,17 +147,12 @@ int uv_tty_set_mode(uv_tty_t* tty, int mode) { return 0; } - if (tty->original_console_mode & ENABLE_QUICK_EDIT_MODE) { - flags = ENABLE_QUICK_EDIT_MODE | ENABLE_EXTENDED_FLAGS; - } - if (mode) { /* Raw input */ - flags |= ENABLE_WINDOW_INPUT; + flags = ENABLE_WINDOW_INPUT; } else { /* Line-buffered mode. */ - flags |= ENABLE_ECHO_INPUT | ENABLE_INSERT_MODE | ENABLE_LINE_INPUT | - ENABLE_EXTENDED_FLAGS | ENABLE_PROCESSED_INPUT; + flags = ENABLE_ECHO_INPUT | ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT; } if (!SetConsoleMode(tty->handle, flags)) {