add gui.clear_markup(...)
This commit is contained in:
parent
98de0d45ef
commit
16698cc68b
@ -39,3 +39,14 @@ gui.get_locales_info() -> table of tables {
|
|||||||
```
|
```
|
||||||
|
|
||||||
Returns information about all loaded locales (res/texts/\*).
|
Returns information about all loaded locales (res/texts/\*).
|
||||||
|
|
||||||
|
```lua
|
||||||
|
gui.clear_markup(
|
||||||
|
-- markup language ("md" - Markdown)
|
||||||
|
language: str,
|
||||||
|
-- text with markup
|
||||||
|
text: str
|
||||||
|
) -> str
|
||||||
|
```
|
||||||
|
|
||||||
|
Removes markup from text.
|
||||||
|
|||||||
@ -36,3 +36,14 @@ gui.get_locales_info() -> таблица таблиц где
|
|||||||
```
|
```
|
||||||
|
|
||||||
Возвращает информацию о всех загруженных локалях (res/texts/\*).
|
Возвращает информацию о всех загруженных локалях (res/texts/\*).
|
||||||
|
|
||||||
|
```lua
|
||||||
|
gui.clear_markup(
|
||||||
|
-- язык разметки ("md" - Markdown)
|
||||||
|
language: str,
|
||||||
|
-- текст с разметкой
|
||||||
|
text: str
|
||||||
|
) -> str
|
||||||
|
```
|
||||||
|
|
||||||
|
Удаляет разметку из текста.
|
||||||
|
|||||||
@ -12,6 +12,8 @@
|
|||||||
#include "graphics/ui/elements/TrackBar.hpp"
|
#include "graphics/ui/elements/TrackBar.hpp"
|
||||||
#include "graphics/ui/elements/UINode.hpp"
|
#include "graphics/ui/elements/UINode.hpp"
|
||||||
#include "graphics/ui/gui_util.hpp"
|
#include "graphics/ui/gui_util.hpp"
|
||||||
|
#include "graphics/ui/markdown.hpp"
|
||||||
|
#include "graphics/core/Font.hpp"
|
||||||
#include "items/Inventories.hpp"
|
#include "items/Inventories.hpp"
|
||||||
#include "util/stringutil.hpp"
|
#include "util/stringutil.hpp"
|
||||||
#include "world/Level.hpp"
|
#include "world/Level.hpp"
|
||||||
@ -726,6 +728,16 @@ static int l_gui_getviewport(lua::State* L) {
|
|||||||
return lua::pushvec2(L, engine->getGUI()->getContainer()->getSize());
|
return lua::pushvec2(L, engine->getGUI()->getContainer()->getSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int l_gui_clear_markup(lua::State* L) {
|
||||||
|
auto lang = lua::require_string(L, 1);
|
||||||
|
std::string text = lua::require_string(L, 2);
|
||||||
|
if (std::strcmp(lang, "md") == 0) {
|
||||||
|
auto [processed, _] = markdown::process(text, true);
|
||||||
|
text = std::move(processed);
|
||||||
|
}
|
||||||
|
return lua::pushstring(L, text);
|
||||||
|
}
|
||||||
|
|
||||||
const luaL_Reg guilib[] = {
|
const luaL_Reg guilib[] = {
|
||||||
{"get_viewport", lua::wrap<l_gui_getviewport>},
|
{"get_viewport", lua::wrap<l_gui_getviewport>},
|
||||||
{"getattr", lua::wrap<l_gui_getattr>},
|
{"getattr", lua::wrap<l_gui_getattr>},
|
||||||
@ -733,5 +745,6 @@ const luaL_Reg guilib[] = {
|
|||||||
{"get_env", lua::wrap<l_gui_get_env>},
|
{"get_env", lua::wrap<l_gui_get_env>},
|
||||||
{"str", lua::wrap<l_gui_str>},
|
{"str", lua::wrap<l_gui_str>},
|
||||||
{"get_locales_info", lua::wrap<l_gui_get_locales_info>},
|
{"get_locales_info", lua::wrap<l_gui_get_locales_info>},
|
||||||
|
{"clear_markup", lua::wrap<l_gui_clear_markup>},
|
||||||
{"__reindex", lua::wrap<l_gui_reindex>},
|
{"__reindex", lua::wrap<l_gui_reindex>},
|
||||||
{NULL, NULL}};
|
{NULL, NULL}};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user