我想让我的stdin在Cygwin/Mintty中进入原始输入模式。我该怎么做?现在,它是行缓冲的。对于raw输入模式,我的意思是每个输入的字符都会返回read。
我更喜欢在没有更多依赖的情况下这样做。也就是说,我猜这可能可以通过链接Cygwin的一些库来完成,但是,如果可能的话,我想避免这种情况。
一些搜索结果:libuv issue,libuv win/tty.c,Cygwin tty.cc,Cygwin fhandler_tty.cc,Cygwin post (non-blocking stdin),Mintty issue,Msysgit issue
我试过通过SetConsoleMode,但这只适用于Windows控制台,而不适用于Mintty。即此代码:
// Setting terminal to raw mode...
HANDLE hStdin;
DWORD mode;
//hStdin = GetStdHandle(STD_INPUT_HANDLE);
hStdin = (HANDLE) _get_osfhandle(STDIN_FILENO);
if (GetFileType(hStdin) == FILE_TYPE_CHAR) {
cout << "stdin is file type char" << endl;
GetConsoleMode(hStdin, &mode);
if (
!SetConsoleMode(
hStdin,
mode & ~(ENABLE_LINE_INPUT|ENABLE_ECHO_INPUT))
) {
cerr << "Cannot set stdin to raw mode" << endl;
// ignore...
}
}发布于 2014-04-20 03:09:40
system( "stty -raw" );能工作吗?
https://stackoverflow.com/questions/22634788
复制相似问题