add gui.set_syntax_styles

This commit is contained in:
MihailRis
2025-11-23 18:10:06 +03:00
parent 1676c47093
commit 50f6c48771
11 changed files with 149 additions and 43 deletions
+37
View File
@@ -0,0 +1,37 @@
#include "FontStyle.hpp"
#include "data/dv.hpp"
#include "data/dv_util.hpp"
#include "devtools/SyntaxProcessor.hpp"
FontStyle FontStyle::parse(const dv::value& src) {
FontStyle style {};
src.at("bold").get(style.bold);
src.at("italic").get(style.italic);
src.at("strikethrough").get(style.strikethrough);
src.at("underline").get(style.underline);
dv::get_vec(src, "color", style.color);
return style;
}
static void parse_style(
const dv::value& src,
FontStylesScheme& scheme,
const std::string& name,
devtools::SyntaxStyles tag
) {
if (src.has(name)) {
scheme.palette[static_cast<int>(tag)] = FontStyle::parse(src[name]);
}
}
FontStylesScheme FontStylesScheme::parse(const dv::value& src) {
FontStylesScheme scheme {};
scheme.palette.resize(8);
parse_style(src, scheme, "default", devtools::SyntaxStyles::DEFAULT);
parse_style(src, scheme, "keyword", devtools::SyntaxStyles::KEYWORD);
parse_style(src, scheme, "literal", devtools::SyntaxStyles::LITERAL);
parse_style(src, scheme, "comment", devtools::SyntaxStyles::COMMENT);
parse_style(src, scheme, "error", devtools::SyntaxStyles::ERROR);
return scheme;
}
+39
View File
@@ -0,0 +1,39 @@
#pragma once
#include "data/dv_fwd.hpp"
#include <vector>
#include <glm/glm.hpp>
struct FontStyle {
bool bold = false;
bool italic = false;
bool strikethrough = false;
bool underline = false;
glm::vec4 color {1, 1, 1, 1};
FontStyle() = default;
FontStyle(
bool bold,
bool italic,
bool strikethrough,
bool underline,
glm::vec4 color
)
: bold(bold),
italic(italic),
strikethrough(strikethrough),
underline(underline),
color(std::move(color)) {
}
static FontStyle parse(const dv::value& src);
};
struct FontStylesScheme {
std::vector<FontStyle> palette;
std::vector<unsigned char> map;
static FontStylesScheme parse(const dv::value& src);
};