replace 'markdown' (bool) property with 'markup' (str)
This commit is contained in:
@@ -82,7 +82,7 @@ glm::vec2 Label::calcSize() {
|
||||
}
|
||||
|
||||
void Label::setText(std::wstring text) {
|
||||
if (isMarkdown()) {
|
||||
if (markup == "md") {
|
||||
auto [processedText, styles] = markdown::process(text, true);
|
||||
text = std::move(processedText);
|
||||
setStyles(std::move(styles));
|
||||
@@ -248,13 +248,13 @@ bool Label::isTextWrapping() const {
|
||||
return textWrap;
|
||||
}
|
||||
|
||||
void Label::setMarkdown(bool flag) {
|
||||
markdown = flag;
|
||||
void Label::setMarkup(std::string_view lang) {
|
||||
markup = lang;
|
||||
setText(text);
|
||||
}
|
||||
|
||||
bool Label::isMarkdown() const {
|
||||
return markdown;
|
||||
const std::string& Label::getMarkup() const {
|
||||
return markup;
|
||||
}
|
||||
|
||||
void Label::setStyles(std::unique_ptr<FontStylesScheme> styles) {
|
||||
|
||||
@@ -53,8 +53,8 @@ namespace gui {
|
||||
/// @brief Auto resize label to fit text
|
||||
bool autoresize = false;
|
||||
|
||||
/// @brief Enable text markdown
|
||||
bool markdown = false;
|
||||
/// @brief Text markup language
|
||||
std::string markup;
|
||||
|
||||
std::unique_ptr<FontStylesScheme> styles;
|
||||
public:
|
||||
@@ -116,8 +116,8 @@ namespace gui {
|
||||
virtual void setTextWrapping(bool flag);
|
||||
virtual bool isTextWrapping() const;
|
||||
|
||||
virtual void setMarkdown(bool flag);
|
||||
virtual bool isMarkdown() const;
|
||||
virtual void setMarkup(std::string_view lang);
|
||||
virtual const std::string& getMarkup() const;
|
||||
|
||||
virtual void setStyles(std::unique_ptr<FontStylesScheme> styles);
|
||||
};
|
||||
|
||||
@@ -194,7 +194,7 @@ void TextBox::refreshLabel() {
|
||||
label->setColor(textColor * glm::vec4(input.empty() ? 0.5f : 1.0f));
|
||||
|
||||
const auto& displayText = input.empty() && !hint.empty() ? hint : getText();
|
||||
if (markdown) {
|
||||
if (markup == "md") {
|
||||
auto [processedText, styles] = markdown::process(displayText, !focused);
|
||||
label->setText(std::move(processedText));
|
||||
label->setStyles(std::move(styles));
|
||||
@@ -850,7 +850,7 @@ bool TextBox::isShowLineNumbers() const {
|
||||
return showLineNumbers;
|
||||
}
|
||||
|
||||
void TextBox::setSyntax(const std::string& lang) {
|
||||
void TextBox::setSyntax(std::string_view lang) {
|
||||
syntax = lang;
|
||||
if (syntax.empty()) {
|
||||
label->setStyles(nullptr);
|
||||
@@ -859,10 +859,10 @@ void TextBox::setSyntax(const std::string& lang) {
|
||||
}
|
||||
}
|
||||
|
||||
void TextBox::setMarkdown(bool flag) {
|
||||
markdown = flag;
|
||||
void TextBox::setMarkup(std::string_view lang) {
|
||||
markup = lang;
|
||||
}
|
||||
|
||||
bool TextBox::isMarkdown() const {
|
||||
return markdown;
|
||||
const std::string& TextBox::getMarkup() const {
|
||||
return markup;
|
||||
}
|
||||
|
||||
@@ -56,8 +56,7 @@ namespace gui {
|
||||
bool editable = true;
|
||||
bool autoresize = false;
|
||||
bool showLineNumbers = false;
|
||||
bool markdown = false;
|
||||
|
||||
std::string markup;
|
||||
std::string syntax;
|
||||
|
||||
void stepLeft(bool shiftPressed, bool breakSelection);
|
||||
@@ -227,9 +226,9 @@ namespace gui {
|
||||
virtual void setOnUpPressed(const runnable &callback);
|
||||
virtual void setOnDownPressed(const runnable &callback);
|
||||
|
||||
virtual void setSyntax(const std::string& lang);
|
||||
virtual void setSyntax(std::string_view lang);
|
||||
|
||||
virtual void setMarkdown(bool flag);
|
||||
virtual bool isMarkdown() const;
|
||||
virtual void setMarkup(std::string_view lang);
|
||||
virtual const std::string& getMarkup() const;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -278,8 +278,8 @@ static std::shared_ptr<UINode> readLabel(
|
||||
if (element.has("text-wrap")) {
|
||||
label->setTextWrapping(element.attr("text-wrap").asBool());
|
||||
}
|
||||
if (element.has("markdown")) {
|
||||
label->setMarkdown(element.attr("markdown").asBool());
|
||||
if (element.has("markup")) {
|
||||
label->setMarkup(element.attr("markup").getText());
|
||||
}
|
||||
return label;
|
||||
}
|
||||
@@ -384,8 +384,8 @@ static std::shared_ptr<UINode> readTextBox(UiXmlReader& reader, const xml::xmlel
|
||||
if (element.has("line-numbers")) {
|
||||
textbox->setShowLineNumbers(element.attr("line-numbers").asBool());
|
||||
}
|
||||
if (element.has("markdown")) {
|
||||
textbox->setMarkdown(element.attr("markdown").asBool());
|
||||
if (element.has("markup")) {
|
||||
textbox->setMarkup(element.attr("markup").getText());
|
||||
}
|
||||
if (element.has("consumer")) {
|
||||
textbox->setTextConsumer(scripting::create_wstring_consumer(
|
||||
|
||||
Reference in New Issue
Block a user