mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-25 19:18:01 +02:00
Properly handle console mode ENABLE_LINE_INPUT
This commit is contained in:
parent
035335bf7b
commit
015bf14156
2 changed files with 48 additions and 26 deletions
|
@ -265,7 +265,21 @@ namespace System
|
|||
|
||||
public static Result<char8> Read() => In.Read();
|
||||
|
||||
public static Result<void> ReadLine(String strBuffer) => In.ReadLine(strBuffer);
|
||||
public static Result<void> ReadLine(String strBuffer)
|
||||
{
|
||||
#if BF_PLATFORM_WINDOWS
|
||||
var fs = In.BaseStream as FileStream;
|
||||
GetConsoleMode((.)fs.Handle, var consoleMode);
|
||||
consoleMode |= ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT;
|
||||
SetConsoleMode((.)fs.Handle, consoleMode);
|
||||
#endif
|
||||
var result = In.ReadLine(strBuffer);
|
||||
#if BF_PLATFORM_WINDOWS
|
||||
SetConsoleMode((.)fs.Handle, consoleMode);
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Task<String> ReadLineAsync() => In.ReadLineAsync();
|
||||
|
||||
|
|
|
@ -3046,6 +3046,14 @@ BFP_EXPORT intptr BFP_CALLTYPE BfpFile_Read(BfpFile* file, void* buffer, intptr
|
|||
bool forceNormalRead = false;
|
||||
|
||||
if ((file->mIsStd) && (file->mHandle == GetStdHandle(STD_INPUT_HANDLE)))
|
||||
{
|
||||
DWORD consoleMode = 0;
|
||||
GetConsoleMode(file->mHandle, &consoleMode);
|
||||
if ((consoleMode & ENABLE_LINE_INPUT) != 0)
|
||||
{
|
||||
forceNormalRead = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
INPUT_RECORD record;
|
||||
DWORD numRead;
|
||||
|
@ -3081,7 +3089,7 @@ BFP_EXPORT intptr BFP_CALLTYPE BfpFile_Read(BfpFile* file, void* buffer, intptr
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if ((timeoutMS != -1) && (!forceNormalRead))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue