foxygit / fake-08-xbox360 Log in
commit a1c99d6458e59a4c046650b74ce6b71c0262f119
Author:     Jon Bell <j.to.the.bell@gmail.com>
AuthorDate: Fri Mar 11 06:55:49 2022 -0700
Commit:     Jon Bell <j.to.the.bell@gmail.com>
CommitDate: Fri Mar 11 06:55:49 2022 -0700

    Add p8scii ctrl code to clear screen
---
 source/printHelper.cpp    |  6 ++++++
 test/printHelperTests.cpp | 17 +++++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/source/printHelper.cpp b/source/printHelper.cpp
index cd2158e..ff4b132 100644
--- a/source/printHelper.cpp
+++ b/source/printHelper.cpp
@@ -156,6 +156,12 @@ int print(std::string str, int x, int y, uint8_t c) {
                 uint8_t framesChar = str[++n];
                 framesBetweenChars = p0CharToNum(framesChar);
             }
+            else if (commandChar == 'c'){
+                uint8_t colChar = str[++n];
+                uint8_t col = p0CharToNum(colChar);
+
+                _ph_graphics->cls(col);
+            }

 		}
 		else if (ch == 12) { //"\f{p0}" draw text with this foreground color
diff --git a/test/printHelperTests.cpp b/test/printHelperTests.cpp
index 2deace5..f6ce957 100644
--- a/test/printHelperTests.cpp
+++ b/test/printHelperTests.cpp
@@ -291,6 +291,23 @@ TEST_CASE("Print helper functions") {

         checkPoints(graphics, expectedPoints);
     }
+    SUBCASE("p8scii special control code clear screen(\\^c) ") {
+        graphics->cls(2);
+
+        print("88888");
+
+        print("\x06""c3", 0, 0);
+
+        std::vector<coloredPoint> expectedPoints = {
+            {1, 0, 3},
+            {1, 1, 3},
+            {1, 2, 3},
+            {1, 3, 3},
+            {1, 4, 3}
+        };
+
+        checkPoints(graphics, expectedPoints);
+    }


     delete stubHost;