diff --git a/api/Terminal.hpp b/api/Terminal.hpp index e97060f3..d310563a 100644 --- a/api/Terminal.hpp +++ b/api/Terminal.hpp @@ -152,6 +152,7 @@ class Terminal { // The following fields are available in API version 10.1 and later. bool frozen = false; // Whether the terminal should stop rendering + bool forcedUpdate = false; // Ignores `frozen` to render the terminal once // The following fields are available in API version 10.2 and later. std::list mouseButtonOrder; // An ordered list of mouse buttons that have been pressed diff --git a/src/apis/term.cpp b/src/apis/term.cpp index c8d13bcd..34b7e4ba 100644 --- a/src/apis/term.cpp +++ b/src/apis/term.cpp @@ -649,6 +649,15 @@ static int term_getFrozen(lua_State *L) { return 1; } +static int term_forceUpdate(lua_State *L) { + lastCFunction = __func__; + Terminal * term = get_comp(L)->term; + if (term == NULL) return 0; + std::lock_guard lock(term->locked); + term->forcedUpdate = true; + return 0; +} + /* export */ int term_benchmark(lua_State *L) { lastCFunction = __func__; if (get_comp(L)->term == NULL) return 0; @@ -695,6 +704,7 @@ static luaL_Reg term_reg[] = { {"relativeMouse", term_relativeMouse}, {"setFrozen", term_setFrozen}, {"getFrozen", term_getFrozen}, + {"forceUpdate", term_forceUpdate}, {NULL, NULL} }; diff --git a/src/peripheral/monitor.cpp b/src/peripheral/monitor.cpp index 5ad0f507..e5fba4cf 100644 --- a/src/peripheral/monitor.cpp +++ b/src/peripheral/monitor.cpp @@ -569,6 +569,14 @@ int monitor::setBlockSize(lua_State *L) { return 0; } +int monitor::forceUpdate(lua_State *L) { + lastCFunction = __func__; + if (term == NULL) return 0; + std::lock_guard lock(term->locked); + term->forcedUpdate = true; + return 0; +} + int monitor::call(lua_State *L, const char * method) { std::string m(method); if (m == "write") return write(L); diff --git a/src/peripheral/monitor.hpp b/src/peripheral/monitor.hpp index 553cc1f0..269d92e3 100644 --- a/src/peripheral/monitor.hpp +++ b/src/peripheral/monitor.hpp @@ -51,6 +51,7 @@ class monitor : public peripheral { int getFrozen(lua_State *L); int setSize(lua_State *L); int setBlockSize(lua_State *L); + int forceUpdate(lua_State *L); public: Terminal * term; static library_t methods; diff --git a/src/termsupport.cpp b/src/termsupport.cpp index 04e5187a..0aabb9a5 100644 --- a/src/termsupport.cpp +++ b/src/termsupport.cpp @@ -582,8 +582,9 @@ static bool renderTerminal(Terminal * term, bool& pushEvent) { term->last_blink = std::chrono::high_resolution_clock::now(); term->changed = true; } - if (term->frozen) return false; + if (term->frozen && !term->forcedUpdate) return false; changed = term->changed; + term->forcedUpdate = false; } try { term->render();