commit ebdc7d5993bf38648fd6f6e02bf6f67c83efa2b5
Author: Jon Bell <j.to.the.bell@gmail.com>
AuthorDate: Fri Mar 11 07:09:19 2022 -0700
Commit: Jon Bell <j.to.the.bell@gmail.com>
CommitDate: Fri Mar 11 07:09:19 2022 -0700
Add cursor jump p8scii control code
---
source/printHelper.cpp | 6 ++++++
test/printHelperTests.cpp | 16 ++++++++++++++++
2 files changed, 22 insertions(+)
diff --git a/source/printHelper.cpp b/source/printHelper.cpp
index 97d4735..dc13994 100644
--- a/source/printHelper.cpp
+++ b/source/printHelper.cpp
@@ -172,6 +172,12 @@ int print(std::string str, int x, int y, uint8_t c) {
homeX = x;
homeY = y;
}
+ else if (commandChar == 'j'){
+ uint8_t xChar = str[++n];
+ uint8_t yChar = str[++n];
+ x = p0CharToNum(xChar) * 4;
+ y = p0CharToNum(yChar) * 4;
+ }
}
else if (ch == 12) { //"\f{p0}" draw text with this foreground color
diff --git a/test/printHelperTests.cpp b/test/printHelperTests.cpp
index 53662ea..872dd76 100644
--- a/test/printHelperTests.cpp
+++ b/test/printHelperTests.cpp
@@ -338,6 +338,22 @@ TEST_CASE("Print helper functions") {
checkPoints(graphics, expectedPoints);
}
+ SUBCASE("p8scii special control code move cursor(\\^j) ") {
+ graphics->cls();
+
+ // coordinates x=40 ("a" = 10, 10 * 4 = 40), y=48 ("c" = 12, 12 * 4 = 48)
+ print("\x06""jac:", 0, 0);
+
+ std::vector<coloredPoint> expectedPoints = {
+ {41, 48, 0},
+ {41, 49, 6},
+ {41, 50, 0},
+ {41, 51, 6},
+ {41, 52, 0}
+ };
+
+ checkPoints(graphics, expectedPoints);
+ }
delete stubHost;