1
0
Fork 0
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:
Brian Fiete 2024-01-02 08:25:37 -05:00
parent 035335bf7b
commit 015bf14156
2 changed files with 48 additions and 26 deletions

View file

@ -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();