Windows: use ENABLE_VIRTUAL_TERMINAL_INPUT

This commit is contained in:
nick black 2021-08-24 05:17:04 -04:00
parent e384f4021c
commit e49f0eadf1

View File

@ -1590,7 +1590,20 @@ int ncinputlayer_init(tinfo* tcache, FILE* infp, queried_terminals_e* detected,
nilayer->user_wants_data = false;
nilayer->inner_wants_data = false;
pthread_cond_init(&nilayer->creport_cond, NULL);
#ifndef __MINGW64__
#ifdef __MINGW64__
HANDLE in = GetStdHandle(STD_INPUT_HANDLE);
if(in == INVALID_HANDLE_VALUE){
logerror("couldn't get input handle\n");
return -1;
}
if(!SetConsoleMode(in, ENABLE_MOUSE_INPUT
| ENABLE_VIRTUAL_TERMINAL_INPUT
| ENABLE_PROCESSED_INPUT
| ENABLE_WINDOW_INPUT)){
logerror("couldn't set input console mode\n");
return -1;
}
#else
// widnows terminal doesn't seem to reply to any queries =/
int csifd = nilayer->ttyfd >= 0 ? nilayer->ttyfd : nilayer->infd;
if(isatty(csifd)){
@ -1630,18 +1643,6 @@ int ncinputlayer_init(tinfo* tcache, FILE* infp, queried_terminals_e* detected,
*kittygraphs = true;
}
}
#else
HANDLE in = GetStdHandle(STD_INPUT_HANDLE);
if(in == INVALID_HANDLE_VALUE){
logerror("couldn't get input handle\n");
return -1;
}
if(!SetConsoleMode(in, ENABLE_MOUSE_INPUT
| ENABLE_PROCESSED_INPUT
| ENABLE_WINDOW_INPUT)){
logerror("couldn't set input console mode\n");
return -1;
}
#endif
return 0;
}