Add coloring for completion of vector components
This commit is contained in:
parent
f7c48cf803
commit
35802374ac
|
@ -344,14 +344,16 @@ public:
|
||||||
Vector<Pair<int, int>> matches;
|
Vector<Pair<int, int>> matches;
|
||||||
Vector<Pair<int, int>> last_matches = { { -1, -1 } }; // This value correspond to an impossible match
|
Vector<Pair<int, int>> last_matches = { { -1, -1 } }; // This value correspond to an impossible match
|
||||||
int location = LOCATION_OTHER;
|
int location = LOCATION_OTHER;
|
||||||
|
String theme_color_name;
|
||||||
|
|
||||||
CodeCompletionOption() {}
|
CodeCompletionOption() {}
|
||||||
|
|
||||||
CodeCompletionOption(const String &p_text, CodeCompletionKind p_kind, int p_location = LOCATION_OTHER) {
|
CodeCompletionOption(const String &p_text, CodeCompletionKind p_kind, int p_location = LOCATION_OTHER, const String &p_theme_color_name = "") {
|
||||||
display = p_text;
|
display = p_text;
|
||||||
insert_text = p_text;
|
insert_text = p_text;
|
||||||
kind = p_kind;
|
kind = p_kind;
|
||||||
location = p_location;
|
location = p_location;
|
||||||
|
theme_color_name = p_theme_color_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
TypedArray<int> get_option_characteristics(const String &p_base);
|
TypedArray<int> get_option_characteristics(const String &p_base);
|
||||||
|
|
|
@ -858,6 +858,9 @@
|
||||||
<member name="text_editor/completion/code_complete_enabled" type="bool" setter="" getter="">
|
<member name="text_editor/completion/code_complete_enabled" type="bool" setter="" getter="">
|
||||||
If [code]true[/code], code completion will be triggered automatically after [member text_editor/completion/code_complete_delay]. If [code]false[/code], you can still trigger completion manually by pressing [kbd]Ctrl + Space[/kbd] ([kbd]Cmd + Space[/kbd] on macOS).
|
If [code]true[/code], code completion will be triggered automatically after [member text_editor/completion/code_complete_delay]. If [code]false[/code], you can still trigger completion manually by pressing [kbd]Ctrl + Space[/kbd] ([kbd]Cmd + Space[/kbd] on macOS).
|
||||||
</member>
|
</member>
|
||||||
|
<member name="text_editor/completion/colorize_suggestions" type="bool" setter="" getter="">
|
||||||
|
If [code]true[/code] enables the coloring for some items in the autocompletion suggestions, like vector components.
|
||||||
|
</member>
|
||||||
<member name="text_editor/completion/complete_file_paths" type="bool" setter="" getter="">
|
<member name="text_editor/completion/complete_file_paths" type="bool" setter="" getter="">
|
||||||
If [code]true[/code], provides autocompletion suggestions for file paths in methods such as [code]load()[/code] and [code]preload()[/code].
|
If [code]true[/code], provides autocompletion suggestions for file paths in methods such as [code]load()[/code] and [code]preload()[/code].
|
||||||
</member>
|
</member>
|
||||||
|
|
|
@ -938,7 +938,9 @@ void CodeTextEditor::_complete_request() {
|
||||||
|
|
||||||
for (const ScriptLanguage::CodeCompletionOption &e : entries) {
|
for (const ScriptLanguage::CodeCompletionOption &e : entries) {
|
||||||
Color font_color = completion_font_color;
|
Color font_color = completion_font_color;
|
||||||
if (e.insert_text.begins_with("\"") || e.insert_text.begins_with("\'")) {
|
if (!e.theme_color_name.is_empty() && EDITOR_GET("text_editor/completion/colorize_suggestions")) {
|
||||||
|
font_color = get_theme_color(e.theme_color_name, SNAME("Editor"));
|
||||||
|
} else if (e.insert_text.begins_with("\"") || e.insert_text.begins_with("\'")) {
|
||||||
font_color = completion_string_color;
|
font_color = completion_string_color;
|
||||||
} else if (e.insert_text.begins_with("#") || e.insert_text.begins_with("//")) {
|
} else if (e.insert_text.begins_with("#") || e.insert_text.begins_with("//")) {
|
||||||
font_color = completion_comment_color;
|
font_color = completion_comment_color;
|
||||||
|
|
|
@ -609,6 +609,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
|
||||||
_initial_set("text_editor/completion/complete_file_paths", true);
|
_initial_set("text_editor/completion/complete_file_paths", true);
|
||||||
_initial_set("text_editor/completion/add_type_hints", false);
|
_initial_set("text_editor/completion/add_type_hints", false);
|
||||||
_initial_set("text_editor/completion/use_single_quotes", false);
|
_initial_set("text_editor/completion/use_single_quotes", false);
|
||||||
|
_initial_set("text_editor/completion/colorize_suggestions", true);
|
||||||
|
|
||||||
// Help
|
// Help
|
||||||
_initial_set("text_editor/help/show_help_index", true);
|
_initial_set("text_editor/help/show_help_index", true);
|
||||||
|
|
|
@ -1207,6 +1207,9 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base
|
||||||
for (const PropertyInfo &E : members) {
|
for (const PropertyInfo &E : members) {
|
||||||
if (!String(E.name).contains("/")) {
|
if (!String(E.name).contains("/")) {
|
||||||
ScriptLanguage::CodeCompletionOption option(E.name, ScriptLanguage::CODE_COMPLETION_KIND_MEMBER);
|
ScriptLanguage::CodeCompletionOption option(E.name, ScriptLanguage::CODE_COMPLETION_KIND_MEMBER);
|
||||||
|
if (GDScriptParser::theme_color_names.has(E.name)) {
|
||||||
|
option.theme_color_name = GDScriptParser::theme_color_names[E.name];
|
||||||
|
}
|
||||||
r_result.insert(option.display, option);
|
r_result.insert(option.display, option);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,10 @@ Variant::Type GDScriptParser::get_builtin_type(const StringName &p_type) {
|
||||||
return Variant::VARIANT_MAX;
|
return Variant::VARIANT_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef TOOLS_ENABLED
|
||||||
|
HashMap<String, String> GDScriptParser::theme_color_names;
|
||||||
|
#endif
|
||||||
|
|
||||||
void GDScriptParser::cleanup() {
|
void GDScriptParser::cleanup() {
|
||||||
builtin_types.clear();
|
builtin_types.clear();
|
||||||
}
|
}
|
||||||
|
@ -121,6 +125,15 @@ GDScriptParser::GDScriptParser() {
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
is_ignoring_warnings = !(bool)GLOBAL_GET("debug/gdscript/warnings/enable");
|
is_ignoring_warnings = !(bool)GLOBAL_GET("debug/gdscript/warnings/enable");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef TOOLS_ENABLED
|
||||||
|
if (theme_color_names.is_empty()) {
|
||||||
|
theme_color_names.insert("x", "axis_x_color");
|
||||||
|
theme_color_names.insert("y", "axis_y_color");
|
||||||
|
theme_color_names.insert("z", "axis_z_color");
|
||||||
|
theme_color_names.insert("w", "axis_w_color");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
GDScriptParser::~GDScriptParser() {
|
GDScriptParser::~GDScriptParser() {
|
||||||
|
|
|
@ -1540,6 +1540,10 @@ public:
|
||||||
int get_last_line_number() const { return current.end_line; }
|
int get_last_line_number() const { return current.end_line; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef TOOLS_ENABLED
|
||||||
|
static HashMap<String, String> theme_color_names;
|
||||||
|
#endif // TOOLS_ENABLED
|
||||||
|
|
||||||
GDScriptParser();
|
GDScriptParser();
|
||||||
~GDScriptParser();
|
~GDScriptParser();
|
||||||
|
|
||||||
|
|
|
@ -10497,6 +10497,7 @@ Error ShaderLanguage::complete(const String &p_code, const ShaderCompileInfo &p_
|
||||||
const char colv[4] = { 'r', 'g', 'b', 'a' };
|
const char colv[4] = { 'r', 'g', 'b', 'a' };
|
||||||
const char coordv[4] = { 'x', 'y', 'z', 'w' };
|
const char coordv[4] = { 'x', 'y', 'z', 'w' };
|
||||||
const char coordt[4] = { 's', 't', 'p', 'q' };
|
const char coordt[4] = { 's', 't', 'p', 'q' };
|
||||||
|
const String theme_color_names[4] = { "axis_x_color", "axis_y_color", "axis_z_color", "axis_w_color" };
|
||||||
|
|
||||||
int limit = 0;
|
int limit = 0;
|
||||||
|
|
||||||
|
@ -10527,9 +10528,9 @@ Error ShaderLanguage::complete(const String &p_code, const ShaderCompileInfo &p_
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < limit; i++) {
|
for (int i = 0; i < limit; i++) {
|
||||||
r_options->push_back(ScriptLanguage::CodeCompletionOption(String::chr(colv[i]), ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT));
|
r_options->push_back(ScriptLanguage::CodeCompletionOption(String::chr(colv[i]), ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT, ScriptLanguage::LOCATION_OTHER, theme_color_names[i]));
|
||||||
r_options->push_back(ScriptLanguage::CodeCompletionOption(String::chr(coordv[i]), ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT));
|
r_options->push_back(ScriptLanguage::CodeCompletionOption(String::chr(coordv[i]), ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT, ScriptLanguage::LOCATION_OTHER, theme_color_names[i]));
|
||||||
r_options->push_back(ScriptLanguage::CodeCompletionOption(String::chr(coordt[i]), ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT));
|
r_options->push_back(ScriptLanguage::CodeCompletionOption(String::chr(coordt[i]), ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT, ScriptLanguage::LOCATION_OTHER, theme_color_names[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
|
|
Loading…
Reference in New Issue