Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

windows: it's rude to clobber quick edit mode

Closes #1429
  • Loading branch information...
DrPizza authored and piscisaureus committed Jul 31, 2011
1 parent 061811f commit de978991d8dc11843a4d11ab438f53aea18d2526
Showing with 12 additions and 5 deletions.
  1. +12 −5 src/node_stdio_win32.cc
@@ -178,21 +178,28 @@ static Handle<Value> IsATTY(const Arguments& args) {
/* Whether stdio is currently in raw mode */
/* -1 means that it has not been set */
static int rawMode = -1;

static DWORD naturalMode = 0;

static void setRawMode(int newMode) {
DWORD flags;
DWORD flags = 0;
BOOL result;

if(rawMode == -1) {
GetConsoleMode((HANDLE)_get_osfhandle(STDIN_FILENO), &naturalMode);
}

flags |= (naturalMode & ENABLE_QUICK_EDIT_MODE);
flags |= flags ? ENABLE_EXTENDED_FLAGS : 0;

if (newMode != rawMode) {
if (newMode) {
// raw input
flags = ENABLE_WINDOW_INPUT;
flags |= ENABLE_WINDOW_INPUT;
} else {
// input not raw, but still processing enough messages to make the
// tty watcher work (this mode is not the windows default)
flags = ENABLE_ECHO_INPUT | ENABLE_INSERT_MODE | ENABLE_LINE_INPUT |
ENABLE_PROCESSED_INPUT | ENABLE_WINDOW_INPUT;
flags |= ENABLE_ECHO_INPUT | ENABLE_INSERT_MODE | ENABLE_LINE_INPUT |
ENABLE_EXTENDED_FLAGS | ENABLE_PROCESSED_INPUT | ENABLE_WINDOW_INPUT;
}

result = SetConsoleMode((HANDLE)_get_osfhandle(STDIN_FILENO), flags);

0 comments on commit de97899

Please sign in to comment.
You can’t perform that action at this time.