-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
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
Syntax highlighter refactor #38440
Syntax highlighter refactor #38440
Conversation
Thank you very much! I know that this breaks compatibility in some parts, but given the nature of this change and the careful way it was implemented, how possible it is to be included in 3.x at some point before 4.x release? I'd argue, that general uses of |
I got a bit surprised by this. Any reason why it should be a nested dictionary? Right now for a highlighter, forcing to create plenty of small dictionaries with string keys inside just to represent colors is calling for a lot of unnecessary allocations. At least if the goal is to allow more data (but which data?) it could use Variant, or have a wrapper object to fill in that data (like SurfaceTool does). |
@pycbouh Unfortunately it's unlikely to be included in a 3.x release in part due to the compatibility breakage. @Zylann Yeah I'm not the biggest fan of it either. The nested dictionary is |
@@ -355,6 +355,38 @@ ScriptCodeCompletionCache::ScriptCodeCompletionCache() { | |||
singleton = this; | |||
} | |||
|
|||
void ScriptLanguage::get_core_type_words(List<String> *p_core_type_words) const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could likely be used to remove the hardcoded core type names from modules/gdscript/gdscript_editor.cpp
.
That's likely work for another PR though. There might be more synergy possible between the syntax highlighter code and the auto-completion code, at least as far as identifying core types, classes and keywords goes. (Or maybe not, it has to be assessed whether it makes sense/would be convenient or would just be too cumbersome.)
p_core_type_words->push_back("StringName"); | ||
p_core_type_words->push_back("NodePath"); | ||
p_core_type_words->push_back("RID"); | ||
p_core_type_words->push_back("Callable"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From variant.h
you missed "Signal" after "Callable".
There's also Object
, null
, bool
, int
, float
, but I guess those are left out on purpose.
CC @neikeq as this might be relevant if we want to add C# syntax highlighting. |
e930f04
to
f910327
Compare
Added 'Signal' into the core type list. |
Needs a rebase after my recent style and init changes, otherwise should be good to merge. |
5649a0d
to
45c5a02
Compare
@ThakeeNathees No, the syntax highlighting part is unchanged. (#28866) |
45c5a02
to
d92d4b6
Compare
d92d4b6
to
5fcafc3
Compare
…hter - Extacted all syntax highlighting code from text edit - Removed enable syntax highlighting from text edit - Added line_edited_from signal to text_edit - Renamed get/set_syntax_highlighting to get/set_syntax_highlighter - Added EditorSyntaxHighligher
5fcafc3
to
bc4cee4
Compare
Thanks! |
@Paulb23 Raises those errors in a simple test project:
|
Will this allow complete control over text coloring? For my game it would be extremely useful to be able to color by character index range manually. |
First part of #31739
Started as part of #17923 however as we could not break compatibility full separation was not possible. This PR completed that work leaving the base concept intact.
Firstly, the
SyntaxHighlighter
class has been converted into a resource and exposed to GDScript. All syntax highlighting code is now managed by this class notTextEdit
.The return of
_get_line_syntax_highlighting
has been changed toDictionary<int, Dictionary>
instead of the structHighlighterInfo
to allow use in GDScript, currently the only supported value in thisDictionary
is the key 'color'.The
TextEdit
changes are as follows:get/set_syntax_highlighting
toget/set_syntax_highlighter
.syntax_coloring
property has been removed.line_edited_from
with the param of the changed line number.CodeHighlighter
syntax highlighter resource.On the editor side a new
EditorSyntaxHighlighter
resource extendingSyntaxHighlighter
has been created for use in the script editor. This class and the get/set methods have been exposed for tool scripts. There are now three editor highlighters:EditorStandardSyntaxHighlighter
EditorPlainTextSyntaxHighlighter
GDScriptSyntaxHighlighter
Lastly, It is now also possible to edit the syntax highlighter in the inspector.
Closes godotengine/godot-proposals/issues/597
Closes #33094
Part of #37540