fix debug console on hardware (also fix gitignore)

This commit is contained in:
zetaPRIME 2017-05-08 04:21:14 -04:00
parent a3d3a0efcd
commit 53712cd94c
5 changed files with 10 additions and 8 deletions

1
.gitignore vendored
View File

@ -32,6 +32,7 @@
*.app
*.elf
*.3dsx
*.cia
# ...and icons
*.smdh

View File

@ -17,7 +17,6 @@ namespace {
//std::weak_ptr<DebugConsole> curDC = std::shared_ptr<DebugConsole>(nullptr);
DebugConsole* cs = nullptr;
// TODO: figure out how the fuck to make this not svcBreak on hardware!?
ssize_t consoleWrite(struct _reent* r, void* fd, const char* ptr, size_t len) {
if (!ptr) return -1;
@ -25,8 +24,8 @@ namespace {
//auto cs = curDC.lock();
if (cs == nullptr) return -1; // nullref but not expired???
cs->text.append("buh");//(ptr, len);
cs->buffer.reset();
cs->text.append(ptr, len);
cs->dirty = true;
return len;
}
@ -64,7 +63,6 @@ void DebugConsole::Start() {
setvbuf(stderr, NULL , _IONBF, 0);
}
text = "foop?\n";
}
void DebugConsole::PreDrawOffscreen() {
@ -72,7 +70,9 @@ void DebugConsole::PreDrawOffscreen() {
}
void DebugConsole::PreDraw() {
if (!buffer) {
if (dirty || !buffer) {
dirty = false;
static TextConfig textConfig = ThemeManager::GetMetric<TextConfig>("/textPresets/normal.12", TextConfig());
textConfig.font = ThemeManager::GetFont("mono.12");
textConfig.justification = Vector2(0, 1);
@ -85,7 +85,7 @@ void DebugConsole::PreDraw() {
text = text.substr(cfp);
}
buffer = std::make_unique<gfx::DrawContextCanvas>(rect.size + Vector2(0, 8));
if (!buffer) buffer = std::make_unique<gfx::DrawContextCanvas>(rect.size + Vector2(0, 8));
buffer->Clear();
GFXManager::PushContext(buffer.get());
textConfig.Print(buffer->rect, text);

View File

@ -23,6 +23,7 @@ namespace starlight {
std::string text = "";
std::unique_ptr<gfx::DrawContextCanvas> buffer;
bool dirty = false;
DebugConsole(VRect rect);
~DebugConsole() override;

View File

@ -73,8 +73,8 @@ void Core::Init() {
label->SetText("This is a form, coming in and nuking the non-form UI elements. Whoops.");
form->touchScreen->Add(label);*/
//auto console = form->topScreen->AddNew<sl::ui::DebugConsole>(VRect::topScreen);
//console->Start();
auto console = form->topScreen->AddNew<sl::ui::DebugConsole>(VRect::topScreen);
console->Start();
auto xbtn = std::make_shared<sl::ui::Button>(VRect(320-96,28,32,24));
xbtn->eOnTap = [](auto& btn){

Binary file not shown.