~ calling render text event on text update
~ small fixes for unit tests
This commit is contained in:
parent
1a6b8e0f2b
commit
868682e9d9
@ -61,7 +61,6 @@ constexpr int keyboardBufferSize = 16;
|
|||||||
std::vector<std::function<void()>> eventTable;
|
std::vector<std::function<void()>> eventTable;
|
||||||
bool localMemoryWarn = true;
|
bool localMemoryWarn = true;
|
||||||
char *sharedMemory = nullptr;
|
char *sharedMemory = nullptr;
|
||||||
int maxTextLength = 60;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern Impl impl;
|
extern Impl impl;
|
||||||
|
@ -165,7 +165,7 @@ namespace vkvm {
|
|||||||
lockSharedMemory();
|
lockSharedMemory();
|
||||||
char *ptr = getTextArea();
|
char *ptr = getTextArea();
|
||||||
for (int i = 0; i < text.size(); i++) {
|
for (int i = 0; i < text.size(); i++) {
|
||||||
if (i < getCharactersPerColumn() * getCharactersPerRow() && i < impl.maxTextLength) {
|
if (i < getCharactersPerColumn() * getCharactersPerRow()) {
|
||||||
ptr[i] = text[i];
|
ptr[i] = text[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -173,6 +173,7 @@ namespace vkvm {
|
|||||||
ptr[text.size()] = '\0';
|
ptr[text.size()] = '\0';
|
||||||
}
|
}
|
||||||
unlockSharedMemory();
|
unlockSharedMemory();
|
||||||
|
callEvent(EventType::RenderText);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,11 +184,12 @@ namespace vkvm {
|
|||||||
auto clearText() -> bool {
|
auto clearText() -> bool {
|
||||||
lockSharedMemory();
|
lockSharedMemory();
|
||||||
char *ptr = getTextArea();
|
char *ptr = getTextArea();
|
||||||
for (int i = 0; i < impl.maxTextLength; ++i) {
|
for (int i = 0; i < getCharactersPerColumn() * getCharactersPerRow(); ++i) {
|
||||||
ptr[i] = '\0';
|
ptr[i] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
unlockSharedMemory();
|
unlockSharedMemory();
|
||||||
|
callEvent(EventType::RenderText);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ TEST_CASE("AREA") {
|
|||||||
|
|
||||||
SECTION("Out of bounds") {
|
SECTION("Out of bounds") {
|
||||||
|
|
||||||
REQUIRE(!vkvm::setPixel(400, 400, vkvm::white));
|
REQUIRE_FALSE(vkvm::setPixel(400, 400, vkvm::white));
|
||||||
REQUIRE(vkvm::getPixel(400, 400) == vkvm::black);
|
REQUIRE(vkvm::getPixel(400, 400) == vkvm::black);
|
||||||
|
|
||||||
vkvm::setBackgroundColor(vkvm::blue);
|
vkvm::setBackgroundColor(vkvm::blue);
|
||||||
|
@ -20,5 +20,5 @@ TEST_CASE("Text") {
|
|||||||
REQUIRE(vkvm::getCharactersPerRow() == 1);
|
REQUIRE(vkvm::getCharactersPerRow() == 1);
|
||||||
|
|
||||||
REQUIRE(vkvm::setText("Hello World"));
|
REQUIRE(vkvm::setText("Hello World"));
|
||||||
REQUIRE(vkvm::getText() == "Hello");
|
REQUIRE(vkvm::getText() == "Hello World");
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user