mirror of
https://github.com/godotengine/godot.git
synced 2025-10-31 21:51:22 +00:00
Highlight doc comments in a different color
This commit is contained in:
parent
6916349697
commit
de7cbe8789
17 changed files with 86 additions and 6 deletions
|
|
@ -496,6 +496,7 @@ Ref<Texture2D> EditorScriptPreviewPlugin::generate(const Ref<Resource> &p_from,
|
|||
Color text_color = EDITOR_GET("text_editor/theme/highlighting/text_color");
|
||||
Color symbol_color = EDITOR_GET("text_editor/theme/highlighting/symbol_color");
|
||||
Color comment_color = EDITOR_GET("text_editor/theme/highlighting/comment_color");
|
||||
Color doc_comment_color = EDITOR_GET("text_editor/theme/highlighting/doc_comment_color");
|
||||
|
||||
if (bg_color.a == 0) {
|
||||
bg_color = Color(0, 0, 0, 0);
|
||||
|
|
@ -513,6 +514,7 @@ Ref<Texture2D> EditorScriptPreviewPlugin::generate(const Ref<Resource> &p_from,
|
|||
bool in_control_flow_keyword = false;
|
||||
bool in_keyword = false;
|
||||
bool in_comment = false;
|
||||
bool in_doc_comment = false;
|
||||
for (int i = 0; i < code.length(); i++) {
|
||||
char32_t c = code[i];
|
||||
if (c > 32) {
|
||||
|
|
@ -520,11 +522,17 @@ Ref<Texture2D> EditorScriptPreviewPlugin::generate(const Ref<Resource> &p_from,
|
|||
Color color = text_color;
|
||||
|
||||
if (c == '#') {
|
||||
in_comment = true;
|
||||
if (i < code.length() - 1 && code[i + 1] == '#') {
|
||||
in_doc_comment = true;
|
||||
} else {
|
||||
in_comment = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (in_comment) {
|
||||
color = comment_color;
|
||||
} else if (in_doc_comment) {
|
||||
color = doc_comment_color;
|
||||
} else {
|
||||
if (is_symbol(c)) {
|
||||
//make symbol a little visible
|
||||
|
|
@ -569,6 +577,7 @@ Ref<Texture2D> EditorScriptPreviewPlugin::generate(const Ref<Resource> &p_from,
|
|||
|
||||
if (c == '\n') {
|
||||
in_comment = false;
|
||||
in_doc_comment = false;
|
||||
|
||||
col = x0;
|
||||
line++;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue