diff --git a/other/TODO.txt b/other/TODO.txt index 9832f32..ef6f45b 100644 --- a/other/TODO.txt +++ b/other/TODO.txt @@ -6,10 +6,10 @@ ***Add scissoring to only draw inside the bounds of containers ***Implement Drag And Drop ***Implement a way to determine on what widget (in the hierarchy chain) and event must stop +***Implement const in stylesheet Add theme caching Implement mouse scroll callback Implement margin for widgets -Implement const in stylesheet Implement color constants in stylesheet diff --git a/src/ostd/io/Stylesheet.cpp b/src/ostd/io/Stylesheet.cpp index 61e8c75..f4662cd 100644 --- a/src/ostd/io/Stylesheet.cpp +++ b/src/ostd/io/Stylesheet.cpp @@ -47,6 +47,7 @@ namespace ostd m_values.clear(); std::vector lines = content.tokenize("\n", false, true).getRawData(); std::vector originalLines = lines; + auto richLines = getRichStringLines(lines); uint32_t lineNumber = 0; auto l_warn = [&](const ostd::String& msg) -> void { OX_WARN("%s in theme line. File: <%s:%d>", msg.c_str(), filePath.c_str(), lineNumber, originalLines[lineNumber - 1].c_str()); @@ -160,7 +161,7 @@ namespace ostd continue; custom_continue: if (debug_print) - std::cout << ostd::String("").add(lineNumber).addLeftPadding(lineNumberMaxWidth, ' ') << "| " << originalLines[lineNumber - 1] << "\n"; + std::cout << ostd::String("").add(lineNumber).addLeftPadding(lineNumberMaxWidth, ' ') << "| " << richLines[lineNumber - 1] << "\n"; } return *this; } @@ -357,4 +358,20 @@ custom_continue: return *p; return ""; } + + std::vector Stylesheet::getRichStringLines(const std::vector& lines) + { + std::vector richLines; + for (auto line : lines) + { + ostd::RegexRichString rgxrstr(line); + rgxrstr.fg("\\{|\\}|\\+|\\*|\\-|\\/|\\(|\\)|\\[|\\]", "Red"); //Operators + rgxrstr.fg("0x[0-9A-Fa-f]+|0b[0-1]+|(? #include #include @@ -55,6 +56,7 @@ namespace ostd void debugPrint(void); ostd::String typeVariantToString(const TypeVariant& v); + std::vector getRichStringLines(const std::vector& lines); private: bool parseThemeFileLine(const ostd::String& line);