[ion/simulator] Headless simulator maps Ion::Console to stdio

This commit is contained in:
Romain Goyet
2020-09-17 20:12:54 -04:00
committed by Léa Saviot
parent a834c954b8
commit 2f2e45a6a5
9 changed files with 101 additions and 53 deletions

View File

@@ -6,6 +6,7 @@
class KDIonContext : public KDContext {
public:
static KDIonContext * sharedContext();
static void putchar(char c);
private:
KDIonContext();
void pushRect(KDRect rect, const KDColor * pixels) override;

View File

@@ -1,5 +1,5 @@
#include <kandinsky/ion_context.h>
#include <ion.h>
#include <ion/display.h>
KDIonContext * KDIonContext::sharedContext() {
static KDIonContext context;
@@ -23,3 +23,12 @@ void KDIonContext::pushRectUniform(KDRect rect, KDColor color) {
void KDIonContext::pullRect(KDRect rect, KDColor * pixels) {
Ion::Display::pullRect(rect, pixels);
}
void KDIonContext::putchar(char c) {
static KDPoint cursor = KDPointZero;
char text[2] = {c, 0};
cursor = sharedContext()->drawString(text, cursor);
if (cursor.y() > Ion::Display::Height) {
cursor = KDPoint(cursor.x(), 0);
}
}