|
|
@ -5,20 +5,20 @@ |
|
|
|
* SPDX-License-Identifier: GPL-3.0-only |
|
|
|
* SPDX-License-Identifier: GPL-3.0-only |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
#include "lua_version.hpp" |
|
|
|
#include "lua/lua_version.hpp" |
|
|
|
|
|
|
|
|
|
|
|
#include <string> |
|
|
|
#include <string> |
|
|
|
|
|
|
|
|
|
|
|
#include "bridge.hpp" |
|
|
|
|
|
|
|
#include "lua.hpp" |
|
|
|
#include "lua.hpp" |
|
|
|
|
|
|
|
#include "lua/bridge.hpp" |
|
|
|
|
|
|
|
|
|
|
|
#include "esp_app_desc.h" |
|
|
|
#include "esp_app_desc.h" |
|
|
|
#include "esp_log.h" |
|
|
|
#include "esp_log.h" |
|
|
|
#include "lauxlib.h" |
|
|
|
#include "lauxlib.h" |
|
|
|
#include "lua.h" |
|
|
|
#include "lua.h" |
|
|
|
#include "lua_thread.hpp" |
|
|
|
#include "lua/lua_thread.hpp" |
|
|
|
#include "luavgl.h" |
|
|
|
#include "luavgl.h" |
|
|
|
#include "themes.hpp" |
|
|
|
#include "ui/themes.hpp" |
|
|
|
|
|
|
|
|
|
|
|
namespace lua { |
|
|
|
namespace lua { |
|
|
|
|
|
|
|
|
|
|
@ -35,7 +35,7 @@ static auto set_style(lua_State* L) -> int { |
|
|
|
static auto set_theme(lua_State* L) -> int { |
|
|
|
static auto set_theme(lua_State* L) -> int { |
|
|
|
std::string class_name; |
|
|
|
std::string class_name; |
|
|
|
luaL_checktype(L, -1, LUA_TTABLE); |
|
|
|
luaL_checktype(L, -1, LUA_TTABLE); |
|
|
|
lua_pushnil(L); /* first key */ |
|
|
|
lua_pushnil(L); /* first key */ |
|
|
|
while (lua_next(L, -2) != 0) { |
|
|
|
while (lua_next(L, -2) != 0) { |
|
|
|
/* uses 'key' (at index -2) and 'value' (at index -1) */ |
|
|
|
/* uses 'key' (at index -2) and 'value' (at index -1) */ |
|
|
|
if (lua_type(L, -2) == LUA_TSTRING) { |
|
|
|
if (lua_type(L, -2) == LUA_TSTRING) { |
|
|
@ -43,11 +43,11 @@ static auto set_theme(lua_State* L) -> int { |
|
|
|
} |
|
|
|
} |
|
|
|
if (lua_type(L, -1) == LUA_TTABLE) { |
|
|
|
if (lua_type(L, -1) == LUA_TTABLE) { |
|
|
|
// Nesting
|
|
|
|
// Nesting
|
|
|
|
lua_pushnil(L); // First key
|
|
|
|
lua_pushnil(L); // First key
|
|
|
|
while (lua_next(L, -2) != 0) { |
|
|
|
while (lua_next(L, -2) != 0) { |
|
|
|
// Nesting the second
|
|
|
|
// Nesting the second
|
|
|
|
int selector = -1; |
|
|
|
int selector = -1; |
|
|
|
lua_pushnil(L); // First key
|
|
|
|
lua_pushnil(L); // First key
|
|
|
|
while (lua_next(L, -2) != 0) { |
|
|
|
while (lua_next(L, -2) != 0) { |
|
|
|
int idx = lua_tointeger(L, -2); |
|
|
|
int idx = lua_tointeger(L, -2); |
|
|
|
if (idx == 1) { |
|
|
|
if (idx == 1) { |
|
|
@ -60,12 +60,13 @@ static auto set_theme(lua_State* L) -> int { |
|
|
|
ESP_LOGI("lua_theme", "Style was null or malformed"); |
|
|
|
ESP_LOGI("lua_theme", "Style was null or malformed"); |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
ui::themes::Theme::instance()->AddStyle(class_name, selector, style); |
|
|
|
ui::themes::Theme::instance()->AddStyle(class_name, selector, |
|
|
|
|
|
|
|
style); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
lua_pop(L, 1);
|
|
|
|
lua_pop(L, 1); |
|
|
|
} |
|
|
|
} |
|
|
|
lua_pop(L, 1);
|
|
|
|
lua_pop(L, 1); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
/* removes 'value'; keeps 'key' for next iteration */ |
|
|
|
/* removes 'value'; keeps 'key' for next iteration */ |
|
|
@ -74,7 +75,9 @@ static auto set_theme(lua_State* L) -> int { |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static const struct luaL_Reg kThemeFuncs[] = {{"set", set_theme}, {"set_style", set_style}, {NULL, NULL}}; |
|
|
|
static const struct luaL_Reg kThemeFuncs[] = {{"set", set_theme}, |
|
|
|
|
|
|
|
{"set_style", set_style}, |
|
|
|
|
|
|
|
{NULL, NULL}}; |
|
|
|
|
|
|
|
|
|
|
|
static auto lua_theme(lua_State* L) -> int { |
|
|
|
static auto lua_theme(lua_State* L) -> int { |
|
|
|
luaL_newlib(L, kThemeFuncs); |
|
|
|
luaL_newlib(L, kThemeFuncs); |
|
|
|