|
|
|
@ -43,6 +43,16 @@ int prepare_windows_terminal(tinfo* ti, size_t* tablelen, size_t* tableused){
|
|
|
|
|
}
|
|
|
|
|
ti->caps.rgb = true;
|
|
|
|
|
ti->caps.colors = 256;
|
|
|
|
|
ti->inhandle = GetStdHandle(STD_INPUT_HANDLE);
|
|
|
|
|
ti->outhandle = GetStdHandle(STD_OUTPUT_HANDLE);
|
|
|
|
|
if(ti->inhandle == INVALID_HANDLE_VALUE){
|
|
|
|
|
logerror("couldn't get input handle\n");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
if(ti->outhandle == INVALID_HANDLE_VALUE){
|
|
|
|
|
logerror("couldn't get output handle\n");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
if(!SetConsoleOutputCP(65001)){
|
|
|
|
|
logerror("couldn't set output page to utf8\n");
|
|
|
|
|
return -1;
|
|
|
|
@ -51,34 +61,29 @@ int prepare_windows_terminal(tinfo* ti, size_t* tablelen, size_t* tableused){
|
|
|
|
|
logerror("couldn't set input page to utf8\n");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
HANDLE in = GetStdHandle(STD_INPUT_HANDLE);
|
|
|
|
|
if(in == INVALID_HANDLE_VALUE){
|
|
|
|
|
logerror("couldn't get input handle\n");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
// if we're a true Windows Terminal, SetConsoleMode() ought succeed.
|
|
|
|
|
// otherwise, we're something else; go ahead and query.
|
|
|
|
|
// disable: ENABLE_ECHO_INPUT | ENABLE_INSERT_MODE | ENABLE_LINE_INPUT
|
|
|
|
|
if(!SetConsoleMode(in, ENABLE_MOUSE_INPUT
|
|
|
|
|
| ENABLE_PROCESSED_INPUT
|
|
|
|
|
| ENABLE_QUICK_EDIT_MODE
|
|
|
|
|
| ENABLE_EXTENDED_FLAGS
|
|
|
|
|
| ENABLE_WINDOW_INPUT
|
|
|
|
|
| ENABLE_VIRTUAL_TERMINAL_INPUT)){
|
|
|
|
|
logerror("couldn't set input console mode\n");
|
|
|
|
|
// otherwise, we're something else; go ahead and try.
|
|
|
|
|
if(!SetConsoleMode(ti->outhandle, ENABLE_PROCESSED_OUTPUT
|
|
|
|
|
| ENABLE_WRAP_AT_EOL_OUTPUT
|
|
|
|
|
| ENABLE_VIRTUAL_TERMINAL_PROCESSING
|
|
|
|
|
| DISABLE_NEWLINE_AUTO_RETURN
|
|
|
|
|
| ENABLE_LVB_GRID_WORLDWIDE)){
|
|
|
|
|
logerror("couldn't set output console mode\n");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
HANDLE out = GetStdHandle(STD_OUTPUT_HANDLE);
|
|
|
|
|
if(out == INVALID_HANDLE_VALUE){
|
|
|
|
|
logerror("couldn't get output handle\n");
|
|
|
|
|
DWORD inmode;
|
|
|
|
|
if(!GetConsoleMode(ti->inhandle, &inmode)){
|
|
|
|
|
logerror("couldn't get input console mode\n");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
if(!SetConsoleMode(out, ENABLE_PROCESSED_OUTPUT
|
|
|
|
|
| ENABLE_WRAP_AT_EOL_OUTPUT
|
|
|
|
|
| ENABLE_VIRTUAL_TERMINAL_PROCESSING
|
|
|
|
|
| DISABLE_NEWLINE_AUTO_RETURN
|
|
|
|
|
| ENABLE_LVB_GRID_WORLDWIDE)){
|
|
|
|
|
logerror("couldn't set output console mode\n");
|
|
|
|
|
// we don't explicitly disable ENABLE_ECHO_INPUT and ENABLE_LINE_INPUT
|
|
|
|
|
// yet; those are handled in cbreak_mode(). just get ENABLE_INSERT_MODE.
|
|
|
|
|
inmode &= ~ENABLE_INSERT_MODE;
|
|
|
|
|
inmode |= ENABLE_MOUSE_INPUT | ENABLE_PROCESSED_INPUT
|
|
|
|
|
| ENABLE_QUICK_EDIT_MODE | ENABLE_EXTENDED_FLAGS
|
|
|
|
|
| ENABLE_WINDOW_INPUT | ENABLE_VIRTUAL_TERMINAL_INPUT;
|
|
|
|
|
if(!SetConsoleMode(ti->inhandle, inmode)){
|
|
|
|
|
logerror("couldn't set input console mode\n");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
ti->caps.quadrants = true;
|
|
|
|
|