diff options
author | Nao Pross <naopross@thearcway.org> | 2017-11-28 15:05:02 +0100 |
---|---|---|
committer | Nao Pross <naopross@thearcway.org> | 2017-11-28 15:05:02 +0100 |
commit | 12e86e71ca36a58d7e2ed64f0454b65ed6f7eb56 (patch) | |
tree | 466f7d2756b0619921e2d9d061862c8443649ed3 /src/ui/AsciiRenderer.cpp | |
parent | Update header ifdefs to match and clean up comments (diff) | |
download | OrbitingYeti-12e86e71ca36a58d7e2ed64f0454b65ed6f7eb56.tar.gz OrbitingYeti-12e86e71ca36a58d7e2ed64f0454b65ed6f7eb56.zip |
New data structure for Structogram and Statements
Diffstat (limited to '')
-rw-r--r-- | src/ui/AsciiRenderer.cpp | 100 |
1 files changed, 0 insertions, 100 deletions
diff --git a/src/ui/AsciiRenderer.cpp b/src/ui/AsciiRenderer.cpp deleted file mode 100644 index d06dadb..0000000 --- a/src/ui/AsciiRenderer.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Renderer.cpp - * - * Created on: Nov 23, 2017 - * Author: naopross - */ - -#include "AsciiRenderer.hpp" - -#include <memory> - -namespace samb { - -AsciiRenderer::AsciiRenderer(Structogram& structogram, unsigned int width): - m_structogram(structogram), m_width(width) {} - -AsciiRenderer::~AsciiRenderer() {} - -void AsciiRenderer::drawPadding(unsigned int amt) { - while (amt--) { - std::cout << " "; - } -} - -void AsciiRenderer::drawLine() const { - for (unsigned int i = 0; i < m_width; i++) { - std::cout << "-"; - } - - std::cout << std::endl; -} - -void AsciiRenderer::drawText(std::string text, unsigned int width, std::string before, std::string after) const { - - if (width == 0) { - width = m_width; - } - - unsigned int textWidth = width - before.length() - after.length(); - - std::cout << before; - for (std::size_t i = 0; i < text.length(); i++) { - if (i % textWidth == 0 && i != 0) { - std::cout << after << "\n" << before; - } - - std::cout << text[i]; - } - - std::cout << std::endl; -} - -void AsciiRenderer::drawDecision(std::string condition, std::string trueText, std::string falseText, unsigned int width) const { - if (width == 0) { - width = m_width -2; - } - - std::cout << "|"; - -// drawPadding(width - condition.length()); -} - -void AsciiRenderer::render() { - - for (Structogram::iterator it = m_structogram.begin(); it != m_structogram.end(); ++it) { - - switch (it->type) { - case Statement::Type::PROCESS: - drawLine(); - drawText(it->text); - drawLine(); - break; - - case Statement::Type::DECISION: - break; - - case Statement::Type::SWITCH: - break; - - case Statement::Type::SCOPE: - std::cout << "Title: " << it->text << std::endl; - break; - - case Statement::Type::WHILE: - break; - - case Statement::Type::UNTIL: - break; - - case Statement::Type::PARALLEL: - break; - - case Statement::END: - // do nothing - break; - } - } -} - -} /* namespace samb */ |