mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-25 05:07:12 +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_syntax_highlighter.h"
|
||||||
|
|
||||||
#include "editor/editor_settings.h"
|
|
||||||
#include "core/config/project_settings.h"
|
#include "core/config/project_settings.h"
|
||||||
|
#include "editor/editor_settings.h"
|
||||||
|
|
||||||
#include "editor_script_editor.h"
|
#include "editor_script_editor.h"
|
||||||
/*** SYNTAX HIGHLIGHTER ****/
|
/*** SYNTAX HIGHLIGHTER ****/
|
||||||
@ -143,11 +143,16 @@ void EditorStandardSyntaxHighlighter::_update_cache() {
|
|||||||
|
|
||||||
/* Reserved words. */
|
/* Reserved words. */
|
||||||
const Color keyword_color = EDITOR_GET("text_editor/highlighting/keyword_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;
|
List<String> keywords;
|
||||||
script->get_language()->get_reserved_words(&keywords);
|
script->get_language()->get_reserved_words(&keywords);
|
||||||
for (List<String>::Element *E = keywords.front(); E; E = E->next()) {
|
for (List<String>::Element *E = keywords.front(); E; E = E->next()) {
|
||||||
|
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);
|
highlighter->add_keyword_color(E->get(), keyword_color);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Member types. */
|
/* Member types. */
|
||||||
const Color member_variable_color = EDITOR_GET("text_editor/highlighting/member_variable_color");
|
const Color member_variable_color = EDITOR_GET("text_editor/highlighting/member_variable_color");
|
||||||
|
@ -168,13 +168,18 @@ void ShaderTextEditor::_load_theme_settings() {
|
|||||||
syntax_highlighter->set_member_variable_color(EDITOR_GET("text_editor/highlighting/member_variable_color"));
|
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 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;
|
List<String> keywords;
|
||||||
ShaderLanguage::get_keyword_list(&keywords);
|
ShaderLanguage::get_keyword_list(&keywords);
|
||||||
|
|
||||||
for (List<String>::Element *E = keywords.front(); E; E = E->next()) {
|
for (List<String>::Element *E = keywords.front(); E; E = E->next()) {
|
||||||
|
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);
|
syntax_highlighter->add_keyword_color(E->get(), keyword_color);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Colorize built-ins like `COLOR` differently to make them easier
|
// Colorize built-ins like `COLOR` differently to make them easier
|
||||||
// to distinguish from keywords at a quick glance.
|
// to distinguish from keywords at a quick glance.
|
||||||
|
@ -31,8 +31,8 @@
|
|||||||
#include "cscript_highlighter.h"
|
#include "cscript_highlighter.h"
|
||||||
#include "../cscript.h"
|
#include "../cscript.h"
|
||||||
#include "../cscript_tokenizer.h"
|
#include "../cscript_tokenizer.h"
|
||||||
#include "editor/editor_settings.h"
|
|
||||||
#include "core/config/project_settings.h"
|
#include "core/config/project_settings.h"
|
||||||
|
#include "editor/editor_settings.h"
|
||||||
|
|
||||||
static bool _is_char(CharType c) {
|
static bool _is_char(CharType c) {
|
||||||
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || 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;
|
return color_map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
String CScriptSyntaxHighlighter::_get_name() const {
|
String CScriptSyntaxHighlighter::_get_name() const {
|
||||||
return "CScript";
|
return "CScript";
|
||||||
}
|
}
|
||||||
@ -492,11 +491,16 @@ void CScriptSyntaxHighlighter::_update_cache() {
|
|||||||
|
|
||||||
/* Reserved words. */
|
/* Reserved words. */
|
||||||
const Color keyword_color = EDITOR_GET("text_editor/highlighting/keyword_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> keyword_list;
|
List<String> keyword_list;
|
||||||
cscript->get_reserved_words(&keyword_list);
|
cscript->get_reserved_words(&keyword_list);
|
||||||
for (List<String>::Element *E = keyword_list.front(); E; E = E->next()) {
|
for (List<String>::Element *E = keyword_list.front(); E; E = E->next()) {
|
||||||
|
if (cscript->is_control_flow_keyword(E->get())) {
|
||||||
|
keywords[E->get()] = control_flow_keyword_color;
|
||||||
|
} else {
|
||||||
keywords[E->get()] = keyword_color;
|
keywords[E->get()] = keyword_color;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Comments */
|
/* Comments */
|
||||||
const Color comment_color = EDITOR_GET("text_editor/highlighting/comment_color");
|
const Color comment_color = EDITOR_GET("text_editor/highlighting/comment_color");
|
||||||
|
@ -508,11 +508,16 @@ void GDScriptSyntaxHighlighter::_update_cache() {
|
|||||||
|
|
||||||
/* Reserved words. */
|
/* Reserved words. */
|
||||||
const Color keyword_color = EDITOR_GET("text_editor/highlighting/keyword_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> keyword_list;
|
List<String> keyword_list;
|
||||||
gdscript->get_reserved_words(&keyword_list);
|
gdscript->get_reserved_words(&keyword_list);
|
||||||
for (List<String>::Element *E = keyword_list.front(); E; E = E->next()) {
|
for (List<String>::Element *E = keyword_list.front(); E; E = E->next()) {
|
||||||
|
if (gdscript->is_control_flow_keyword(E->get())) {
|
||||||
|
keywords[E->get()] = control_flow_keyword_color;
|
||||||
|
} else {
|
||||||
keywords[E->get()] = keyword_color;
|
keywords[E->get()] = keyword_color;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Comments */
|
/* Comments */
|
||||||
const Color comment_color = EDITOR_GET("text_editor/highlighting/comment_color");
|
const Color comment_color = EDITOR_GET("text_editor/highlighting/comment_color");
|
||||||
|
Loading…
Reference in New Issue
Block a user