add gui.set_syntax_styles
This commit is contained in:
@@ -80,6 +80,14 @@ std::shared_ptr<Menu> GUI::getMenu() {
|
||||
return menu;
|
||||
}
|
||||
|
||||
void GUI::setSyntaxColorScheme(std::unique_ptr<FontStylesScheme> scheme) {
|
||||
syntaxColorScheme = std::move(scheme);
|
||||
}
|
||||
|
||||
FontStylesScheme* GUI::getSyntaxColorScheme() const {
|
||||
return syntaxColorScheme.get();
|
||||
}
|
||||
|
||||
void GUI::onAssetsLoad(Assets* assets) {
|
||||
rootDocument->rebuildIndices();
|
||||
assets->store(rootDocument, "core:root");
|
||||
|
||||
@@ -17,6 +17,7 @@ struct CursorState;
|
||||
class Engine;
|
||||
class Input;
|
||||
class Window;
|
||||
struct FontStylesScheme;
|
||||
|
||||
namespace devtools {
|
||||
class Editor;
|
||||
@@ -73,6 +74,7 @@ namespace gui {
|
||||
std::shared_ptr<UINode> focus;
|
||||
std::shared_ptr<UINode> tooltip;
|
||||
std::shared_ptr<UiDocument> rootDocument;
|
||||
std::unique_ptr<FontStylesScheme> syntaxColorScheme;
|
||||
std::unordered_map<std::string, std::shared_ptr<UINode>> storage;
|
||||
|
||||
std::unique_ptr<Camera> uicamera;
|
||||
@@ -157,6 +159,9 @@ namespace gui {
|
||||
/// @deprecated
|
||||
std::shared_ptr<Container> getContainer() const;
|
||||
|
||||
void setSyntaxColorScheme(std::unique_ptr<FontStylesScheme> scheme);
|
||||
FontStylesScheme* getSyntaxColorScheme() const;
|
||||
|
||||
void onAssetsLoad(Assets* assets);
|
||||
|
||||
void postRunnable(const runnable& callback);
|
||||
|
||||
@@ -918,7 +918,9 @@ void TextBox::onTab(bool shiftPressed) {
|
||||
void TextBox::refreshSyntax() {
|
||||
if (!syntax.empty()) {
|
||||
const auto& processor = gui.getEditor().getSyntaxProcessor();
|
||||
if (auto styles = processor.highlight(syntax, input)) {
|
||||
auto scheme = gui.getSyntaxColorScheme();
|
||||
if (auto styles =
|
||||
processor.highlight(scheme ? *scheme : FontStylesScheme {}, syntax, input)) {
|
||||
label->setStyles(std::move(styles));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user