Sync push

This commit is contained in:
OmniaX-Dev 2026-04-08 11:01:06 +02:00
parent c28829bd72
commit 37ded4be60
3 changed files with 21 additions and 2 deletions

View file

@ -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

View file

@ -47,6 +47,7 @@ namespace ostd
m_values.clear();
std::vector<ostd::String> lines = content.tokenize("\n", false, true).getRawData();
std::vector<ostd::String> 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<ostd::RegexRichString> Stylesheet::getRichStringLines(const std::vector<ostd::String>& lines)
{
std::vector<ostd::RegexRichString> richLines;
for (auto line : lines)
{
ostd::RegexRichString rgxrstr(line);
rgxrstr.fg("\\{|\\}|\\+|\\*|\\-|\\/|\\(|\\)|\\[|\\]", "Red"); //Operators
rgxrstr.fg("0x[0-9A-Fa-f]+|0b[0-1]+|(?<!\\w)[0-9]+(?!\\w)", "Blue"); //Number Constants
rgxrstr.fg("(?<!\\w)(r[1-9]|r10|fl|pp|rv|fp|sp|ip|acc)(?!\\w)", "BrightGreen", true); //Registers
rgxrstr.fg("\\%low", "Magenta");
rgxrstr.fg("\\$\\w+", "Cyan"); //Labels
richLines.push_back(rgxrstr);
}
return richLines;
}
}

View file

@ -20,6 +20,7 @@
#pragma once
#include "string/TextStyleParser.hpp"
#include <ostd/data/Color.hpp>
#include <ostd/math/Geometry.hpp>
#include <variant>
@ -55,6 +56,7 @@ namespace ostd
void debugPrint(void);
ostd::String typeVariantToString(const TypeVariant& v);
std::vector<ostd::RegexRichString> getRichStringLines(const std::vector<ostd::String>& lines);
private:
bool parseThemeFileLine(const ostd::String& line);