Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow all engine syntax highlighters in TextEdit #597

Closed
YuriSizov opened this issue Mar 18, 2020 · 2 comments · Fixed by godotengine/godot#38440
Closed

Allow all engine syntax highlighters in TextEdit #597

YuriSizov opened this issue Mar 18, 2020 · 2 comments · Fixed by godotengine/godot#38440
Milestone

Comments

@YuriSizov
Copy link
Contributor

Describe the project you are working on:
A game editor with a code generation capability.

Describe the problem or limitation you are having in your project:
Parts of my game are generated from a form of metadata, which is edited with a purpose-built Godot Editor plugin. There is a UI to create and edit code snippets within this plugin. It is implemented with TextEdit node, which has a lot of options making it "Script Editor"-lite. (And, I guess, is used internally by the Script Editor).

One of the options is syntax highlighting, but it does not provide full coverage for GDScript tokens. Most of the colors can be copied from Editor Settings, but there are several missing in theme properties:

"keyword_color"
"base_type_color"
"engine_type_color"
"user_type_color"
"comment_color"
"string_color"
"text_color"
"text_selected_color"
"line_length_guideline_color"
"search_result_color"
"search_result_border_color"

Hoping that this is only a theme limitation, I've looked through the engine code trying to figure out if it is possible to just add those colors. Unfortunately, the highlighter that is available in TextEdit by default is just a simplified ad-hoc implementation, that has nothing to do with the Script Editor and thus does not parse these missing tokens.

Describe the feature / enhancement and how it helps to overcome the problem or limitation:
Internal classes that use TextEdit (such as Script Editor) can set their own highlighters via interface not exposed in GDScript API. In GDScript API only the default implementation from TextEdit::_get_line_syntax_highlighting is available.

I think that at least all syntax highlighters available in engine should be present as an option for TextEdit. It may not be useful for many games, but it allows plugin creators to have more tools to naturally integrate their plugins into Godot Editor UI. Plus, having a full highlighter and a simplified one is excessive and serves no purpose in my opinion.

As a stretch goal, an ability to define custom highlighters in GDScript/GDNative API may come in handy as well.

Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:
I think, we either implicitly register all SyntaxHighlighter classes and access that list from TextEdit, or TextEdit has its own curated list of supported SyntaxHighlighters. Currently I see only GDScriptSyntaxHighlighter extending SyntaxHighlighter, but more can be added to support various text file formats.

If this enhancement will not be used often, can it be worked around with a few lines of script?:
Syntax highlighting is not exposed to scripts.

Is there a reason why this should be core and not an add-on in the asset library?:
It's a part of GDScript module.

@Jummit
Copy link

Jummit commented Mar 18, 2020

Related: godotengine/godot#31739

@YuriSizov
Copy link
Contributor Author

@Jummit Thanks!

It would be indeed better to separate TextEdit and code editing features into separate controls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants