Show error message in Lua widgets instead of "disabled"
Also a new function drawTextLines(...) in draw_functions that splits a string over multiple lines
This commit is contained in:
@@ -442,10 +442,11 @@ void LuaWidget::setErrorMessage(const char * funcName)
|
||||
{
|
||||
TRACE("Error in widget %s %s function: %s", factory->getName(), funcName, lua_tostring(lsWidgets, -1));
|
||||
TRACE("Widget disabled");
|
||||
size_t needed = snprintf(NULL, 0, "%s: %s", funcName, lua_tostring(lsWidgets, -1)) + 1;
|
||||
errorMessage = (char *)malloc(needed);
|
||||
size_t needed = snprintf(NULL, 0, "ERROR in %s: %s", funcName, lua_tostring(lsWidgets, -1)) + 1;
|
||||
errorMessage = (char *)malloc(needed + 1);
|
||||
if (errorMessage) {
|
||||
snprintf(errorMessage, needed, "%s: %s", funcName, lua_tostring(lsWidgets, -1));
|
||||
snprintf(errorMessage, needed, "ERROR in %s: %s", funcName, lua_tostring(lsWidgets, -1));
|
||||
errorMessage[needed] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -459,8 +460,7 @@ void LuaWidget::refresh(BitmapBuffer* dc)
|
||||
if (lsWidgets == 0) return;
|
||||
|
||||
if (errorMessage) {
|
||||
lcdSetColor(RED);
|
||||
dc->drawText(0, 0, "Disabled", FONT(XS) | CUSTOM_COLOR);
|
||||
drawTextLines(dc, 0, 0, fullscreen ? LCD_W : rect.w, fullscreen ? LCD_H : rect.h, errorMessage, FONT(XS) | COLOR_THEME_WARNING);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user