From 0102a74906eb6dc34cddda6d383da886f47c8f30 Mon Sep 17 00:00:00 2001 From: Julian Hinxlage Date: Wed, 27 Nov 2019 12:02:14 +0100 Subject: [PATCH] + update text on RenderText event --- main/main.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/main/main.cpp b/main/main.cpp index a13a01d..cd16cca 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -1,7 +1,7 @@ -//#include "add.h" #include "Bitmap.h" #include "Font.h" - +#include "TextRenderer.h" +#include "internal.hpp" #include bool isQuit(std::string command); @@ -13,8 +13,6 @@ bool isQuit(std::string command); * A string is converted and displayed in the console. * Currently only to test. */ - -#include "TextRenderer.h" void outPutPixel(int windowHeight, int windowWidth, vkvm::Color fontColor); int main() { @@ -22,6 +20,7 @@ int main() { std::string currentText; + /*************************set back to shared memory(only for test)********************************************/ int windowWidth = vkvm::getWidth(); int windowHeight = vkvm::getHeight(); @@ -45,6 +44,14 @@ int main() { textRenderer.setBottomMargin(1); /*************************get Text and update back to shared meomory********************************************/ + vkvm::registerEvent(vkvm::EventType::RenderText, [&textRenderer](){ + std::string currentText = vkvm::getText(); + textRenderer.update(currentText); + vkvm::callEvent(vkvm::EventType::Redraw); + }); + + + std::string command; std::cout << "TextRender: "; std::getline(std::cin, command); @@ -61,6 +68,7 @@ int main() { } } + std::cout << "TextRender finished." << std::endl; return 0;