From 644d96e42db61503b8c54ee4d6d7ea6faad1ca24 Mon Sep 17 00:00:00 2001 From: Jacek Jendrzej Date: Sun, 12 Jul 2015 21:13:22 +0200 Subject: [PATCH] src/gui/luainstance.cpp add switch enableUTF8 to ComponentsText --- src/gui/luainstance.cpp | 19 +++++++++++++++++++ src/gui/luainstance.h | 1 + 2 files changed, 20 insertions(+) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index f140f43c0..6587ef0c3 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -2072,6 +2072,7 @@ void CLuaInstance::ComponentsTextRegister(lua_State *L) { "setText", CLuaInstance::ComponentsTextSetText }, { "scroll", CLuaInstance::ComponentsTextScroll }, { "setCenterPos", CLuaInstance::ComponentsTextSetCenterPos }, + { "enableUTF8", CLuaInstance::ComponentsTextEnableUTF8 }, { "__gc", CLuaInstance::ComponentsTextDelete }, { NULL, NULL } }; @@ -2258,6 +2259,24 @@ int CLuaInstance::ComponentsTextSetCenterPos(lua_State *L) return 0; } +int CLuaInstance::ComponentsTextEnableUTF8(lua_State *L) +{ + lua_assert(lua_istable(L,1)); + CLuaComponentsText *m = ComponentsTextCheck(L, 1); + if (!m) return 0; + + bool utf8_encoded = true; + if (!tableLookup(L, "utf8_encoded", utf8_encoded)) + { + std::string tmp = "true"; + if (tableLookup(L, "utf8_encoded", tmp)) + paramBoolDeprecated(L, tmp.c_str()); + utf8_encoded = (tmp == "true" || tmp == "1" || tmp == "yes"); + } + m->ct->enableUTF8(utf8_encoded); + return 0; +} + int CLuaInstance::ComponentsTextDelete(lua_State *L) { DBG("CLuaInstance::%s %d\n", __func__, lua_gettop(L)); diff --git a/src/gui/luainstance.h b/src/gui/luainstance.h index 6b9cd9771..89956fed2 100644 --- a/src/gui/luainstance.h +++ b/src/gui/luainstance.h @@ -278,6 +278,7 @@ private: static int ComponentsTextSetText(lua_State *L); static int ComponentsTextScroll(lua_State *L); static int ComponentsTextSetCenterPos(lua_State *L); + static int ComponentsTextEnableUTF8(lua_State *L); static int ComponentsTextDelete(lua_State *L); static CLuaPicture *CPictureCheck(lua_State *L, int n);