add textbox.syntax, textbox.markup, label.markup properties
This commit is contained in:
parent
c782645603
commit
65f208fc61
@ -82,6 +82,8 @@ Properties:
|
||||
| textWrap | bool | yes | yes | automatic text wrapping (only with multiline: "true") |
|
||||
| valid | bool | yes | no | is the entered text correct |
|
||||
| textColor | vec4 | yes | yes | text color |
|
||||
| syntax | string | yes | yes | syntax highlighting ("lua" - Lua) |
|
||||
| markup | string | yes | yes | text markup language ("md" - Markdown) |
|
||||
|
||||
Methods:
|
||||
|
||||
@ -139,9 +141,10 @@ Properties:
|
||||
|
||||
Properties:
|
||||
|
||||
| Title | Type | Read | Write | Description |
|
||||
| ----- | ------ | ---- | ----- | ----------- |
|
||||
| text | string | yes | yes | label text |
|
||||
| Title | Type | Read | Write | Description |
|
||||
| ------ | ------ | ---- | ----- | -------------------------------------- |
|
||||
| text | string | yes | yes | label text |
|
||||
| markup | string | yes | yes | text markup language ("md" - Markdown) |
|
||||
|
||||
## Image
|
||||
|
||||
|
||||
@ -82,6 +82,8 @@ document["worlds-panel"]:clear()
|
||||
| textWrap | bool | да | да | автоматический перенос текста (только при multiline: "true") |
|
||||
| valid | bool | да | нет | является ли введенный текст корректным |
|
||||
| textColor | vec4 | да | да | цвет текста |
|
||||
| syntax | string | да | да | подсветка синтаксиса ("lua" - Lua) |
|
||||
| markup | string | да | да | язык разметки текста ("md" - Markdown) |
|
||||
|
||||
Методы:
|
||||
|
||||
@ -139,9 +141,10 @@ document["worlds-panel"]:clear()
|
||||
|
||||
Свойства:
|
||||
|
||||
| Название | Тип | Чтение | Запись | Описание |
|
||||
| -------- | ------ | ------ | ------ | ----------- |
|
||||
| text | string | да | да | текст метки |
|
||||
| Название | Тип | Чтение | Запись | Описание |
|
||||
| -------- | ------ | ------ | ------ | -------------------------------------- |
|
||||
| text | string | да | да | текст метки |
|
||||
| markup | string | да | да | язык разметки текста ("md" - Markdown) |
|
||||
|
||||
## Изображение (image)
|
||||
|
||||
|
||||
@ -859,6 +859,10 @@ void TextBox::setSyntax(std::string_view lang) {
|
||||
}
|
||||
}
|
||||
|
||||
const std::string& TextBox::getSyntax() const {
|
||||
return syntax;
|
||||
}
|
||||
|
||||
void TextBox::setMarkup(std::string_view lang) {
|
||||
markup = lang;
|
||||
}
|
||||
|
||||
@ -227,6 +227,7 @@ namespace gui {
|
||||
virtual void setOnDownPressed(const runnable &callback);
|
||||
|
||||
virtual void setSyntax(std::string_view lang);
|
||||
virtual const std::string& getSyntax() const;
|
||||
|
||||
virtual void setMarkup(std::string_view lang);
|
||||
virtual const std::string& getMarkup() const;
|
||||
|
||||
@ -299,6 +299,22 @@ static int p_get_line_numbers(UINode* node, lua::State* L) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int p_get_syntax(UINode* node, lua::State* L) {
|
||||
if (auto box = dynamic_cast<TextBox*>(node)) {
|
||||
return lua::pushstring(L, box->getSyntax());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int p_get_markup(UINode* node, lua::State* L) {
|
||||
if (auto box = dynamic_cast<TextBox*>(node)) {
|
||||
return lua::pushstring(L, box->getMarkup());
|
||||
} else if (auto label = dynamic_cast<Label*>(node)) {
|
||||
return lua::pushstring(L, label->getMarkup());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int p_get_src(UINode* node, lua::State* L) {
|
||||
if (auto image = dynamic_cast<Image*>(node)) {
|
||||
return lua::pushstring(L, image->getTexture());
|
||||
@ -420,6 +436,8 @@ static int l_gui_getattr(lua::State* L) {
|
||||
{"lineNumbers", p_get_line_numbers},
|
||||
{"lineAt", p_get_line_at},
|
||||
{"linePos", p_get_line_pos},
|
||||
{"syntax", p_get_syntax},
|
||||
{"markup", p_get_markup},
|
||||
{"src", p_get_src},
|
||||
{"value", p_get_value},
|
||||
{"min", p_get_min},
|
||||
@ -512,6 +530,18 @@ static void p_set_line_numbers(UINode* node, lua::State* L, int idx) {
|
||||
box->setShowLineNumbers(lua::toboolean(L, idx));
|
||||
}
|
||||
}
|
||||
static void p_set_syntax(UINode* node, lua::State* L, int idx) {
|
||||
if (auto box = dynamic_cast<TextBox*>(node)) {
|
||||
box->setSyntax(lua::require_string(L, idx));
|
||||
}
|
||||
}
|
||||
static void p_set_markup(UINode* node, lua::State* L, int idx) {
|
||||
if (auto box = dynamic_cast<TextBox*>(node)) {
|
||||
box->setMarkup(lua::require_string(L, idx));
|
||||
} else if (auto label = dynamic_cast<Label*>(node)) {
|
||||
label->setMarkup(lua::require_string(L, idx));
|
||||
}
|
||||
}
|
||||
static void p_set_src(UINode* node, lua::State* L, int idx) {
|
||||
if (auto image = dynamic_cast<Image*>(node)) {
|
||||
image->setTexture(lua::require_string(L, idx));
|
||||
@ -612,6 +642,8 @@ static int l_gui_setattr(lua::State* L) {
|
||||
{"text", p_set_text},
|
||||
{"editable", p_set_editable},
|
||||
{"lineNumbers", p_set_line_numbers},
|
||||
{"syntax", p_set_syntax},
|
||||
{"markup", p_set_markup},
|
||||
{"src", p_set_src},
|
||||
{"caret", p_set_caret},
|
||||
{"value", p_set_value},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user