1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-07 12:30:27 +00:00

Add syntax highlighting for ConfigFile/TSCN/TRES/project.godot

A single highligher is used for all these formats, as they're fairly
close to each other.
This commit is contained in:
Hugo Locurcio
2023-06-07 18:54:19 +02:00
parent 6c9765d87e
commit ecc1f08386
2 changed files with 67 additions and 0 deletions

View File

@@ -137,6 +137,28 @@ public:
EditorMarkdownSyntaxHighlighter() { highlighter.instantiate(); }
};
class EditorConfigFileSyntaxHighlighter : public EditorSyntaxHighlighter {
GDCLASS(EditorConfigFileSyntaxHighlighter, EditorSyntaxHighlighter)
private:
Ref<CodeHighlighter> highlighter;
public:
virtual void _update_cache() override;
virtual Dictionary _get_line_syntax_highlighting_impl(int p_line) override { return highlighter->get_line_syntax_highlighting(p_line); }
// While not explicitly designed for those formats, this highlighter happens
// to handle TSCN, TRES, `project.godot` well. We can expose it in case the
// user opens one of these using the script editor (which can be done using
// the All Files filter).
virtual PackedStringArray _get_supported_languages() const override { return PackedStringArray{ "ini", "cfg", "tscn", "tres", "godot" }; }
virtual String _get_name() const override { return TTR("ConfigFile"); }
virtual Ref<EditorSyntaxHighlighter> _create() const override;
EditorConfigFileSyntaxHighlighter() { highlighter.instantiate(); }
};
///////////////////////////////////////////////////////////////////////////////
class ScriptEditorQuickOpen : public ConfirmationDialog {