mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 19:48:20 +02:00
Unbuffering stdout
This commit is contained in:
parent
bc5c425d1b
commit
4a819762e6
3 changed files with 17 additions and 6 deletions
|
@ -90,13 +90,12 @@ namespace System
|
||||||
|
|
||||||
static function void(StringView str) OutString = => OutString_Simple;
|
static function void(StringView str) OutString = => OutString_Simple;
|
||||||
|
|
||||||
public static extern void PutChar(char8 c);
|
private static extern void PutChars(char8* c, int32 len);
|
||||||
public static extern void ReopenHandles();
|
public static extern void ReopenHandles();
|
||||||
|
|
||||||
static void OutString_Simple(StringView str)
|
static void OutString_Simple(StringView str)
|
||||||
{
|
{
|
||||||
for (var c in str.RawChars)
|
PutChars(str.Ptr, (.)str.Length);
|
||||||
PutChar(c);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void OutString_Ex(StringView str)
|
static void OutString_Ex(StringView str)
|
||||||
|
|
|
@ -183,8 +183,9 @@ namespace bf
|
||||||
|
|
||||||
class Console
|
class Console
|
||||||
{
|
{
|
||||||
|
private:
|
||||||
|
BFRT_EXPORT static void PutChars(char* ptr, int len);
|
||||||
public:
|
public:
|
||||||
BFRT_EXPORT static void PutChar(char c);
|
|
||||||
BFRT_EXPORT static void ReopenHandles();
|
BFRT_EXPORT static void ReopenHandles();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -292,9 +292,20 @@ static void NTAPI TlsFreeFunc(void* ptr)
|
||||||
gBfRtCallbacks.Thread_Exiting();
|
gBfRtCallbacks.Thread_Exiting();
|
||||||
}
|
}
|
||||||
|
|
||||||
void bf::System::Console::PutChar(char c)
|
void bf::System::Console::PutChars(char* ptr, int len)
|
||||||
{
|
{
|
||||||
putchar(c);
|
#ifdef BF_PLATFORM_WINDOWS
|
||||||
|
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
|
if (handle != INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
|
DWORD numBytesWritten = 0;
|
||||||
|
::WriteFile(handle, ptr, (DWORD)len, &numBytesWritten, NULL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (int i = 0; i < len; i++)
|
||||||
|
putchar(ptr[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void bf::System::Console::ReopenHandles()
|
void bf::System::Console::ReopenHandles()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue