Move safe line color into editor
This commit is contained in:
parent
d18a90b8f0
commit
33ab9cd621
@ -170,6 +170,16 @@ void ScriptTextEditor::_load_theme_settings() {
|
|||||||
CodeEdit *text_edit = code_editor->get_text_editor();
|
CodeEdit *text_edit = code_editor->get_text_editor();
|
||||||
text_edit->clear_keywords();
|
text_edit->clear_keywords();
|
||||||
|
|
||||||
|
Color updated_safe_line_number_color = EDITOR_GET("text_editor/highlighting/safe_line_number_color");
|
||||||
|
if (updated_safe_line_number_color != safe_line_number_color) {
|
||||||
|
safe_line_number_color = updated_safe_line_number_color;
|
||||||
|
for (int i = 0; i < text_edit->get_line_count(); i++) {
|
||||||
|
if (text_edit->get_line_gutter_item_color(i, line_number_gutter) != default_line_number_color) {
|
||||||
|
text_edit->set_line_gutter_item_color(i, line_number_gutter, safe_line_number_color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Color background_color = EDITOR_GET("text_editor/highlighting/background_color");
|
Color background_color = EDITOR_GET("text_editor/highlighting/background_color");
|
||||||
Color completion_background_color = EDITOR_GET("text_editor/highlighting/completion_background_color");
|
Color completion_background_color = EDITOR_GET("text_editor/highlighting/completion_background_color");
|
||||||
Color completion_selected_color = EDITOR_GET("text_editor/highlighting/completion_selected_color");
|
Color completion_selected_color = EDITOR_GET("text_editor/highlighting/completion_selected_color");
|
||||||
@ -178,7 +188,6 @@ void ScriptTextEditor::_load_theme_settings() {
|
|||||||
Color completion_font_color = EDITOR_GET("text_editor/highlighting/completion_font_color");
|
Color completion_font_color = EDITOR_GET("text_editor/highlighting/completion_font_color");
|
||||||
Color text_color = EDITOR_GET("text_editor/highlighting/text_color");
|
Color text_color = EDITOR_GET("text_editor/highlighting/text_color");
|
||||||
Color line_number_color = EDITOR_GET("text_editor/highlighting/line_number_color");
|
Color line_number_color = EDITOR_GET("text_editor/highlighting/line_number_color");
|
||||||
Color safe_line_number_color = EDITOR_GET("text_editor/highlighting/safe_line_number_color");
|
|
||||||
Color caret_color = EDITOR_GET("text_editor/highlighting/caret_color");
|
Color caret_color = EDITOR_GET("text_editor/highlighting/caret_color");
|
||||||
Color caret_background_color = EDITOR_GET("text_editor/highlighting/caret_background_color");
|
Color caret_background_color = EDITOR_GET("text_editor/highlighting/caret_background_color");
|
||||||
Color text_selected_color = EDITOR_GET("text_editor/highlighting/text_selected_color");
|
Color text_selected_color = EDITOR_GET("text_editor/highlighting/text_selected_color");
|
||||||
@ -203,7 +212,6 @@ void ScriptTextEditor::_load_theme_settings() {
|
|||||||
text_edit->add_theme_color_override("completion_font_color", completion_font_color);
|
text_edit->add_theme_color_override("completion_font_color", completion_font_color);
|
||||||
text_edit->add_theme_color_override("font_color", text_color);
|
text_edit->add_theme_color_override("font_color", text_color);
|
||||||
text_edit->add_theme_color_override("line_number_color", line_number_color);
|
text_edit->add_theme_color_override("line_number_color", line_number_color);
|
||||||
text_edit->add_theme_color_override("safe_line_number_color", safe_line_number_color);
|
|
||||||
text_edit->add_theme_color_override("caret_color", caret_color);
|
text_edit->add_theme_color_override("caret_color", caret_color);
|
||||||
text_edit->add_theme_color_override("caret_background_color", caret_background_color);
|
text_edit->add_theme_color_override("caret_background_color", caret_background_color);
|
||||||
text_edit->add_theme_color_override("font_color_selected", text_selected_color);
|
text_edit->add_theme_color_override("font_color_selected", text_selected_color);
|
||||||
@ -541,16 +549,16 @@ void ScriptTextEditor::_validate_script() {
|
|||||||
te->set_line_as_marked(i, line == i);
|
te->set_line_as_marked(i, line == i);
|
||||||
if (highlight_safe) {
|
if (highlight_safe) {
|
||||||
if (safe_lines.has(i + 1)) {
|
if (safe_lines.has(i + 1)) {
|
||||||
te->set_line_as_safe(i, true);
|
te->set_line_gutter_item_color(i, line_number_gutter, safe_line_number_color);
|
||||||
last_is_safe = true;
|
last_is_safe = true;
|
||||||
} else if (last_is_safe && (te->is_line_comment(i) || te->get_line(i).strip_edges().empty())) {
|
} else if (last_is_safe && (te->is_line_comment(i) || te->get_line(i).strip_edges().empty())) {
|
||||||
te->set_line_as_safe(i, true);
|
te->set_line_gutter_item_color(i, line_number_gutter, safe_line_number_color);
|
||||||
} else {
|
} else {
|
||||||
te->set_line_as_safe(i, false);
|
te->set_line_gutter_item_color(i, line_number_gutter, default_line_number_color);
|
||||||
last_is_safe = false;
|
last_is_safe = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
te->set_line_as_safe(i, false);
|
te->set_line_gutter_item_color(line, 1, default_line_number_color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -988,7 +996,12 @@ void ScriptTextEditor::_update_gutter_indexes() {
|
|||||||
for (int i = 0; i < code_editor->get_text_editor()->get_gutter_count(); i++) {
|
for (int i = 0; i < code_editor->get_text_editor()->get_gutter_count(); i++) {
|
||||||
if (code_editor->get_text_editor()->get_gutter_name(i) == "connection_gutter") {
|
if (code_editor->get_text_editor()->get_gutter_name(i) == "connection_gutter") {
|
||||||
connection_gutter = i;
|
connection_gutter = i;
|
||||||
break;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (code_editor->get_text_editor()->get_gutter_name(i) == "line_numbers") {
|
||||||
|
line_number_gutter = i;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1679,6 +1692,7 @@ void ScriptTextEditor::_enable_code_editor() {
|
|||||||
code_editor->get_text_editor()->connect("gutter_clicked", callable_mp(this, &ScriptTextEditor::_gutter_clicked));
|
code_editor->get_text_editor()->connect("gutter_clicked", callable_mp(this, &ScriptTextEditor::_gutter_clicked));
|
||||||
code_editor->get_text_editor()->connect("gui_input", callable_mp(this, &ScriptTextEditor::_text_edit_gui_input));
|
code_editor->get_text_editor()->connect("gui_input", callable_mp(this, &ScriptTextEditor::_text_edit_gui_input));
|
||||||
code_editor->show_toggle_scripts_button();
|
code_editor->show_toggle_scripts_button();
|
||||||
|
_update_gutter_indexes();
|
||||||
|
|
||||||
editor_box->add_child(warnings_panel);
|
editor_box->add_child(warnings_panel);
|
||||||
warnings_panel->add_theme_font_override(
|
warnings_panel->add_theme_font_override(
|
||||||
|
@ -85,6 +85,10 @@ class ScriptTextEditor : public ScriptEditorBase {
|
|||||||
void _gutter_clicked(int p_line, int p_gutter);
|
void _gutter_clicked(int p_line, int p_gutter);
|
||||||
void _update_gutter_indexes();
|
void _update_gutter_indexes();
|
||||||
|
|
||||||
|
int line_number_gutter = -1;
|
||||||
|
Color default_line_number_color = Color(1, 1, 1);
|
||||||
|
Color safe_line_number_color = Color(1, 1, 1);
|
||||||
|
|
||||||
PopupPanel *color_panel = nullptr;
|
PopupPanel *color_panel = nullptr;
|
||||||
ColorPicker *color_picker = nullptr;
|
ColorPicker *color_picker = nullptr;
|
||||||
Vector2 color_position;
|
Vector2 color_position;
|
||||||
|
@ -233,8 +233,12 @@ bool CodeEdit::is_line_numbers_zero_padded() const {
|
|||||||
void CodeEdit::_line_number_draw_callback(int p_line, int p_gutter, const Rect2 &p_region) {
|
void CodeEdit::_line_number_draw_callback(int p_line, int p_gutter, const Rect2 &p_region) {
|
||||||
String fc = String::num(p_line + 1).lpad(line_number_digits, line_number_padding);
|
String fc = String::num(p_line + 1).lpad(line_number_digits, line_number_padding);
|
||||||
|
|
||||||
int yofs = region.position.y + (cache.row_height - cache.font->get_height()) / 2;
|
int yofs = p_region.position.y + (cache.row_height - cache.font->get_height()) / 2;
|
||||||
cache.font->draw(get_canvas_item(), Point2(region.position.x, yofs + cache.font->get_ascent()), fc, line_number_color);
|
Color number_color = get_line_gutter_item_color(p_line, line_number_gutter);
|
||||||
|
if (number_color == Color(1, 1, 1)) {
|
||||||
|
number_color = line_number_color;
|
||||||
|
}
|
||||||
|
cache.font->draw(get_canvas_item(), Point2(p_region.position.x, yofs + cache.font->get_ascent()), fc, number_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fold Gutter */
|
/* Fold Gutter */
|
||||||
|
@ -196,7 +196,6 @@ void TextEdit::Text::insert(int p_at, const String &p_text) {
|
|||||||
Line line;
|
Line line;
|
||||||
line.gutters.resize(gutter_count);
|
line.gutters.resize(gutter_count);
|
||||||
line.marked = false;
|
line.marked = false;
|
||||||
line.safe = false;
|
|
||||||
line.hidden = false;
|
line.hidden = false;
|
||||||
line.width_cache = -1;
|
line.width_cache = -1;
|
||||||
line.wrap_amount_cache = -1;
|
line.wrap_amount_cache = -1;
|
||||||
@ -4723,7 +4722,6 @@ void TextEdit::_update_caches() {
|
|||||||
cache.font = get_theme_font("font");
|
cache.font = get_theme_font("font");
|
||||||
cache.caret_color = get_theme_color("caret_color");
|
cache.caret_color = get_theme_color("caret_color");
|
||||||
cache.caret_background_color = get_theme_color("caret_background_color");
|
cache.caret_background_color = get_theme_color("caret_background_color");
|
||||||
cache.safe_line_number_color = get_theme_color("safe_line_number_color");
|
|
||||||
cache.font_color = get_theme_color("font_color");
|
cache.font_color = get_theme_color("font_color");
|
||||||
cache.font_color_selected = get_theme_color("font_color_selected");
|
cache.font_color_selected = get_theme_color("font_color_selected");
|
||||||
cache.font_color_readonly = get_theme_color("font_color_readonly");
|
cache.font_color_readonly = get_theme_color("font_color_readonly");
|
||||||
@ -5378,17 +5376,6 @@ void TextEdit::set_line_as_marked(int p_line, bool p_marked) {
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextEdit::set_line_as_safe(int p_line, bool p_safe) {
|
|
||||||
ERR_FAIL_INDEX(p_line, text.size());
|
|
||||||
text.set_safe(p_line, p_safe);
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TextEdit::is_line_set_as_safe(int p_line) const {
|
|
||||||
ERR_FAIL_INDEX_V(p_line, text.size(), false);
|
|
||||||
return text.is_safe(p_line);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TextEdit::set_line_as_hidden(int p_line, bool p_hidden) {
|
void TextEdit::set_line_as_hidden(int p_line, bool p_hidden) {
|
||||||
ERR_FAIL_INDEX(p_line, text.size());
|
ERR_FAIL_INDEX(p_line, text.size());
|
||||||
if (is_hiding_enabled() || !p_hidden) {
|
if (is_hiding_enabled() || !p_hidden) {
|
||||||
|
@ -82,14 +82,12 @@ private:
|
|||||||
int width_cache : 24;
|
int width_cache : 24;
|
||||||
bool marked : 1;
|
bool marked : 1;
|
||||||
bool hidden : 1;
|
bool hidden : 1;
|
||||||
bool safe : 1;
|
|
||||||
int wrap_amount_cache : 24;
|
int wrap_amount_cache : 24;
|
||||||
String data;
|
String data;
|
||||||
Line() {
|
Line() {
|
||||||
width_cache = 0;
|
width_cache = 0;
|
||||||
marked = false;
|
marked = false;
|
||||||
hidden = false;
|
hidden = false;
|
||||||
safe = false;
|
|
||||||
wrap_amount_cache = 0;
|
wrap_amount_cache = 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -115,8 +113,6 @@ private:
|
|||||||
bool is_marked(int p_line) const { return text[p_line].marked; }
|
bool is_marked(int p_line) const { return text[p_line].marked; }
|
||||||
void set_hidden(int p_line, bool p_hidden) { text.write[p_line].hidden = p_hidden; }
|
void set_hidden(int p_line, bool p_hidden) { text.write[p_line].hidden = p_hidden; }
|
||||||
bool is_hidden(int p_line) const { return text[p_line].hidden; }
|
bool is_hidden(int p_line) const { return text[p_line].hidden; }
|
||||||
void set_safe(int p_line, bool p_safe) { text.write[p_line].safe = p_safe; }
|
|
||||||
bool is_safe(int p_line) const { return text[p_line].safe; }
|
|
||||||
void insert(int p_at, const String &p_text);
|
void insert(int p_at, const String &p_text);
|
||||||
void remove(int p_at);
|
void remove(int p_at);
|
||||||
int size() const { return text.size(); }
|
int size() const { return text.size(); }
|
||||||
@ -455,7 +451,6 @@ protected:
|
|||||||
Color completion_font_color;
|
Color completion_font_color;
|
||||||
Color caret_color;
|
Color caret_color;
|
||||||
Color caret_background_color;
|
Color caret_background_color;
|
||||||
Color safe_line_number_color;
|
|
||||||
Color font_color;
|
Color font_color;
|
||||||
Color font_color_selected;
|
Color font_color_selected;
|
||||||
Color font_color_readonly;
|
Color font_color_readonly;
|
||||||
@ -576,8 +571,6 @@ public:
|
|||||||
void insert_at(const String &p_text, int at);
|
void insert_at(const String &p_text, int at);
|
||||||
int get_line_count() const;
|
int get_line_count() const;
|
||||||
void set_line_as_marked(int p_line, bool p_marked);
|
void set_line_as_marked(int p_line, bool p_marked);
|
||||||
void set_line_as_safe(int p_line, bool p_safe);
|
|
||||||
bool is_line_set_as_safe(int p_line) const;
|
|
||||||
|
|
||||||
void set_line_as_hidden(int p_line, bool p_hidden);
|
void set_line_as_hidden(int p_line, bool p_hidden);
|
||||||
bool is_line_hidden(int p_line) const;
|
bool is_line_hidden(int p_line) const;
|
||||||
|
@ -401,7 +401,6 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
|
|||||||
theme->set_color("caret_color", "TextEdit", control_font_color);
|
theme->set_color("caret_color", "TextEdit", control_font_color);
|
||||||
theme->set_color("caret_background_color", "TextEdit", Color(0, 0, 0));
|
theme->set_color("caret_background_color", "TextEdit", Color(0, 0, 0));
|
||||||
theme->set_color("brace_mismatch_color", "TextEdit", Color(1, 0.2, 0.2));
|
theme->set_color("brace_mismatch_color", "TextEdit", Color(1, 0.2, 0.2));
|
||||||
theme->set_color("safe_line_number_color", "TextEdit", Color(0.67, 0.78, 0.67, 0.6));
|
|
||||||
theme->set_color("word_highlighted_color", "TextEdit", Color(0.8, 0.9, 0.9, 0.15));
|
theme->set_color("word_highlighted_color", "TextEdit", Color(0.8, 0.9, 0.9, 0.15));
|
||||||
|
|
||||||
theme->set_constant("completion_lines", "TextEdit", 7);
|
theme->set_constant("completion_lines", "TextEdit", 7);
|
||||||
|
Loading…
Reference in New Issue
Block a user