[+] Added AuConsole example
[*] Update (ROXTL and) Runtime Git fucked up and wont let me stage ROXTL. Fuck recloning bc git sucks.
This commit is contained in:
parent
6a430b5f3f
commit
2facfac20d
@ -1 +1 @@
|
|||||||
Subproject commit a66fb2c5107487287fd6a7c2223efd92c63813f8
|
Subproject commit 45975e475571bf76dace0aab9bd30b263eec0192
|
69
Tests/Public/22. Hello Console/Main.cpp
Normal file
69
Tests/Public/22. Hello Console/Main.cpp
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
/***
|
||||||
|
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||||
|
|
||||||
|
File: Main.cpp
|
||||||
|
Date: 2022-2-18
|
||||||
|
Author: Reece
|
||||||
|
***/
|
||||||
|
#include <AuroraRuntime.hpp>
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
static void PrintDebug()
|
||||||
|
{
|
||||||
|
AuConsole::TTYFill(' ', AuConsole::EAnsiColor::eBoldMagenta, AuConsole::EAnsiColor::eBoldMagenta);
|
||||||
|
AuConsole::TTYWrite("Hello Red and Blue\r\n", AuConsole::EAnsiColor::eRed, AuConsole::EAnsiColor::eBlue);
|
||||||
|
AuConsole::TTYWrite("To blank\r\n");
|
||||||
|
AuConsole::TTYMoveY(1);
|
||||||
|
AuConsole::TTYClearLine(AuConsole::EAnsiColor::eBoldMagenta);
|
||||||
|
AuConsole::TTYWrite("Overwritten\r\n");
|
||||||
|
AuConsole::TTYWrite("Hello Red and Blue\r\n", AuConsole::EAnsiColor::eRed, AuConsole::EAnsiColor::eBoldGreen);
|
||||||
|
AuConsole::TTYWrite("Hello Bold Red and Blue\r\n", AuConsole::EAnsiColor::eBoldRed, AuConsole::EAnsiColor::eBoldGreen);
|
||||||
|
AuConsole::TTYWrite("Hello Green and Blue\r\n", AuConsole::EAnsiColor::eGreen, AuConsole::EAnsiColor::eBoldGreen);
|
||||||
|
AuConsole::TTYWrite("Hello Bold Green and Blue\r\n", AuConsole::EAnsiColor::eBoldGreen, AuConsole::EAnsiColor::eBlue);
|
||||||
|
AuConsole::TTYWrite("Hello Yellow and Blue\r\n", AuConsole::EAnsiColor::eYellow, AuConsole::EAnsiColor::eBoldGreen);
|
||||||
|
AuConsole::TTYWrite("Hello Bold Yellow and Blue\r\n", AuConsole::EAnsiColor::eBoldYellow, AuConsole::EAnsiColor::eBoldGreen);
|
||||||
|
AuConsole::TTYWrite("Hello Blue and Blue\r\n", AuConsole::EAnsiColor::eBlue, AuConsole::EAnsiColor::eBoldGreen);
|
||||||
|
AuConsole::TTYWrite("Hello Bold Blue and Blue\r\n", AuConsole::EAnsiColor::eBoldBlue, AuConsole::EAnsiColor::eBoldGreen);
|
||||||
|
AuConsole::TTYWrite("Hello Magenta and Blue\r\n", AuConsole::EAnsiColor::eMagenta, AuConsole::EAnsiColor::eBoldGreen);
|
||||||
|
AuConsole::TTYWrite("Hello Bold Magenta and Blue\r\n", AuConsole::EAnsiColor::eBoldMagenta, AuConsole::EAnsiColor::eBoldGreen);
|
||||||
|
AuConsole::TTYWrite("Hello Cyan and Blue\r\n", AuConsole::EAnsiColor::eCyan, AuConsole::EAnsiColor::eBoldGreen);
|
||||||
|
AuConsole::TTYWrite("Hello Bold Cyan and Blue\r\n", AuConsole::EAnsiColor::eBoldCyan, AuConsole::EAnsiColor::eBoldGreen);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ReadStdInNonBlocking()
|
||||||
|
{
|
||||||
|
AuLogInfo("Awaiting input (10s)");
|
||||||
|
|
||||||
|
auto loop = Aurora::Loop::NewLoopQueue();
|
||||||
|
auto source = AuConsole::StdInBufferLoopSource();
|
||||||
|
|
||||||
|
ASSERT_TRUE(loop->SourceAdd(source));
|
||||||
|
|
||||||
|
ASSERT_TRUE(loop->Commit());
|
||||||
|
|
||||||
|
if (loop->WaitAll(10 * 1000))
|
||||||
|
{
|
||||||
|
char binary[512];
|
||||||
|
int length = AuConsole::ReadStdIn(binary, AuArraySize(binary));
|
||||||
|
AuLogInfo("Got input binary (!!!): {}", AuString(binary, binary + length));
|
||||||
|
|
||||||
|
ASSERT_FALSE(source->IsSignaled());
|
||||||
|
ASSERT_FALSE(source->WaitOn(100));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AuLogInfo("Got nothing");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RunTests()
|
||||||
|
{
|
||||||
|
Aurora::RuntimeStartInfo info;
|
||||||
|
info.console.fio.enableLogging = false;
|
||||||
|
info.console.enableStdPassthrough = true; // for ReadStdIn
|
||||||
|
info.console.enableStdOut = false; // give back stdout to the logger
|
||||||
|
Aurora::RuntimeStart(info);
|
||||||
|
|
||||||
|
PrintDebug();
|
||||||
|
ReadStdInNonBlocking();
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user