mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-08 12:31:51 +00:00
feat: custom languages syntax (WIP)
This commit is contained in:
parent
4360cd408b
commit
5253be6c56
18 changed files with 278 additions and 88 deletions
|
|
@ -364,3 +364,7 @@ Input& GUI::getInput() {
|
|||
Window& GUI::getWindow() {
|
||||
return engine.getWindow();
|
||||
}
|
||||
|
||||
devtools::Editor& GUI::getEditor() {
|
||||
return engine.getEditor();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,10 @@ class Engine;
|
|||
class Input;
|
||||
class Window;
|
||||
|
||||
namespace devtools {
|
||||
class Editor;
|
||||
}
|
||||
|
||||
/*
|
||||
Some info about padding and margin.
|
||||
Padding is element inner space, margin is outer
|
||||
|
|
@ -159,5 +163,6 @@ namespace gui {
|
|||
const Input& getInput() const;
|
||||
Input& getInput();
|
||||
Window& getWindow();
|
||||
devtools::Editor& getEditor();
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@
|
|||
#include "../markdown.hpp"
|
||||
#include "Label.hpp"
|
||||
#include "assets/Assets.hpp"
|
||||
#include "devtools/syntax_highlighting.hpp"
|
||||
#include "devtools/Editor.hpp"
|
||||
#include "devtools/SyntaxProcessor.hpp"
|
||||
#include "engine/Engine.hpp"
|
||||
#include "graphics/core/Batch2D.hpp"
|
||||
#include "graphics/core/DrawContext.hpp"
|
||||
|
|
@ -811,7 +812,8 @@ void TextBox::stepDefaultUp(bool shiftPressed, bool breakSelection) {
|
|||
|
||||
void TextBox::refreshSyntax() {
|
||||
if (!syntax.empty()) {
|
||||
if (auto styles = devtools::syntax_highlight(syntax, input)) {
|
||||
const auto& processor = gui.getEditor().getSyntaxProcessor();
|
||||
if (auto styles = processor.highlight(syntax, input)) {
|
||||
label->setStyles(std::move(styles));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue