mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-24 04:46:48 +01:00
Ported: Highlight control flow keywords with a different color. This makes them easier to distinguish from other keywords.
- Calinou
e905e8f145
This commit is contained in:
parent
8eca52fc76
commit
c3f01e0b3d
@ -30,8 +30,8 @@
|
||||
|
||||
#include "editor_syntax_highlighter.h"
|
||||
|
||||
#include "editor/editor_settings.h"
|
||||
#include "core/config/project_settings.h"
|
||||
#include "editor/editor_settings.h"
|
||||
|
||||
#include "editor_script_editor.h"
|
||||
/*** SYNTAX HIGHLIGHTER ****/
|
||||
@ -143,10 +143,15 @@ void EditorStandardSyntaxHighlighter::_update_cache() {
|
||||
|
||||
/* Reserved words. */
|
||||
const Color keyword_color = EDITOR_GET("text_editor/highlighting/keyword_color");
|
||||
const Color control_flow_keyword_color = EDITOR_GET("text_editor/highlighting/control_flow_keyword_color");
|
||||
List<String> keywords;
|
||||
script->get_language()->get_reserved_words(&keywords);
|
||||
for (List<String>::Element *E = keywords.front(); E; E = E->next()) {
|
||||
highlighter->add_keyword_color(E->get(), keyword_color);
|
||||
if (script->get_language()->is_control_flow_keyword(E->get())) {
|
||||
highlighter->add_keyword_color(E->get(), control_flow_keyword_color);
|
||||
} else {
|
||||
highlighter->add_keyword_color(E->get(), keyword_color);
|
||||
}
|
||||
}
|
||||
|
||||
/* Member types. */
|
||||
|
@ -168,12 +168,17 @@ void ShaderTextEditor::_load_theme_settings() {
|
||||
syntax_highlighter->set_member_variable_color(EDITOR_GET("text_editor/highlighting/member_variable_color"));
|
||||
|
||||
const Color keyword_color = EDITOR_GET("text_editor/highlighting/keyword_color");
|
||||
const Color control_flow_keyword_color = EDITOR_GET("text_editor/highlighting/control_flow_keyword_color");
|
||||
|
||||
List<String> keywords;
|
||||
ShaderLanguage::get_keyword_list(&keywords);
|
||||
|
||||
for (List<String>::Element *E = keywords.front(); E; E = E->next()) {
|
||||
syntax_highlighter->add_keyword_color(E->get(), keyword_color);
|
||||
if (ShaderLanguage::is_control_flow_keyword(E->get())) {
|
||||
syntax_highlighter->add_keyword_color(E->get(), control_flow_keyword_color);
|
||||
} else {
|
||||
syntax_highlighter->add_keyword_color(E->get(), keyword_color);
|
||||
}
|
||||
}
|
||||
|
||||
// Colorize built-ins like `COLOR` differently to make them easier
|
||||
|
@ -31,8 +31,8 @@
|
||||
#include "cscript_highlighter.h"
|
||||
#include "../cscript.h"
|
||||
#include "../cscript_tokenizer.h"
|
||||
#include "editor/editor_settings.h"
|
||||
#include "core/config/project_settings.h"
|
||||
#include "editor/editor_settings.h"
|
||||
|
||||
static bool _is_char(CharType c) {
|
||||
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_';
|
||||
@ -412,7 +412,6 @@ Dictionary CScriptSyntaxHighlighter::_get_line_syntax_highlighting(int p_line) {
|
||||
return color_map;
|
||||
}
|
||||
|
||||
|
||||
String CScriptSyntaxHighlighter::_get_name() const {
|
||||
return "CScript";
|
||||
}
|
||||
@ -492,10 +491,15 @@ void CScriptSyntaxHighlighter::_update_cache() {
|
||||
|
||||
/* Reserved words. */
|
||||
const Color keyword_color = EDITOR_GET("text_editor/highlighting/keyword_color");
|
||||
const Color control_flow_keyword_color = EDITOR_GET("text_editor/highlighting/control_flow_keyword_color");
|
||||
List<String> keyword_list;
|
||||
cscript->get_reserved_words(&keyword_list);
|
||||
for (List<String>::Element *E = keyword_list.front(); E; E = E->next()) {
|
||||
keywords[E->get()] = keyword_color;
|
||||
if (cscript->is_control_flow_keyword(E->get())) {
|
||||
keywords[E->get()] = control_flow_keyword_color;
|
||||
} else {
|
||||
keywords[E->get()] = keyword_color;
|
||||
}
|
||||
}
|
||||
|
||||
/* Comments */
|
||||
|
@ -508,10 +508,15 @@ void GDScriptSyntaxHighlighter::_update_cache() {
|
||||
|
||||
/* Reserved words. */
|
||||
const Color keyword_color = EDITOR_GET("text_editor/highlighting/keyword_color");
|
||||
const Color control_flow_keyword_color = EDITOR_GET("text_editor/highlighting/control_flow_keyword_color");
|
||||
List<String> keyword_list;
|
||||
gdscript->get_reserved_words(&keyword_list);
|
||||
for (List<String>::Element *E = keyword_list.front(); E; E = E->next()) {
|
||||
keywords[E->get()] = keyword_color;
|
||||
if (gdscript->is_control_flow_keyword(E->get())) {
|
||||
keywords[E->get()] = control_flow_keyword_color;
|
||||
} else {
|
||||
keywords[E->get()] = keyword_color;
|
||||
}
|
||||
}
|
||||
|
||||
/* Comments */
|
||||
|
Loading…
Reference in New Issue
Block a user