mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 11:38:21 +02:00
Fixed Console.Readline, added Console.KeyAvailable
This commit is contained in:
parent
e71cb928a6
commit
037cb39240
5 changed files with 92 additions and 10 deletions
|
@ -3043,7 +3043,48 @@ static void WINAPI OverlappedReadComplete(DWORD dwErrorCode, DWORD dwNumberOfByt
|
|||
|
||||
BFP_EXPORT intptr BFP_CALLTYPE BfpFile_Read(BfpFile* file, void* buffer, intptr size, int timeoutMS, BfpFileResult* outResult)
|
||||
{
|
||||
if (timeoutMS != -1)
|
||||
bool forceNormalRead = false;
|
||||
|
||||
if ((file->mIsStd) && (file->mHandle == GetStdHandle(STD_INPUT_HANDLE)))
|
||||
{
|
||||
INPUT_RECORD record;
|
||||
DWORD numRead;
|
||||
while (true)
|
||||
{
|
||||
if (timeoutMS != -1)
|
||||
{
|
||||
if (!GetNumberOfConsoleInputEvents(file->mHandle, &numRead))
|
||||
{
|
||||
forceNormalRead = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (numRead == 0)
|
||||
{
|
||||
OUTRESULT(BfpFileResult_Timeout);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ReadConsoleInput(file->mHandle, &record, 1, &numRead))
|
||||
{
|
||||
forceNormalRead = true;
|
||||
break;
|
||||
}
|
||||
if (numRead > 0)
|
||||
{
|
||||
if ((record.Event.KeyEvent.bKeyDown) && (record.Event.KeyEvent.uChar.AsciiChar != 0))
|
||||
{
|
||||
memset(buffer, record.Event.KeyEvent.uChar.AsciiChar, 1);
|
||||
OUTRESULT(BfpFileResult_Ok);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ((timeoutMS != -1) && (!forceNormalRead))
|
||||
{
|
||||
if (file->mAsyncData == NULL)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue