Ability to change the caret color

(cherry picked from commit c7519f091d)
This commit is contained in:
Paulb23 2016-04-05 17:06:56 +01:00 committed by Rémi Verschelde
parent d4d810faac
commit b7f5418f8d
4 changed files with 8 additions and 4 deletions

View File

@ -910,9 +910,9 @@ void TextEdit::_notification(int p_what) {
cursor_pos = Point2i( char_ofs+char_margin, ofs_y ); cursor_pos = Point2i( char_ofs+char_margin, ofs_y );
if (insert_mode) { if (insert_mode) {
cursor_pos.y += get_row_height(); cursor_pos.y += get_row_height();
VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(cursor_pos, Size2i(char_w,1)),cache.font_color); VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(cursor_pos, Size2i(char_w,1)),cache.caret_color);
} else { } else {
VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(cursor_pos, Size2i(1,get_row_height())),cache.font_color); VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(cursor_pos, Size2i(1,get_row_height())),cache.caret_color);
} }
@ -927,9 +927,9 @@ void TextEdit::_notification(int p_what) {
if (insert_mode) { if (insert_mode) {
cursor_pos.y += get_row_height(); cursor_pos.y += get_row_height();
int char_w = cache.font->get_char_size(' ').width; int char_w = cache.font->get_char_size(' ').width;
VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(cursor_pos, Size2i(char_w,1)),cache.font_color); VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(cursor_pos, Size2i(char_w,1)),cache.caret_color);
} else { } else {
VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(cursor_pos, Size2i(1,get_row_height())),cache.font_color); VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(cursor_pos, Size2i(1,get_row_height())),cache.caret_color);
} }
} }
} }
@ -3046,6 +3046,7 @@ void TextEdit::_update_caches() {
cache.style_normal=get_stylebox("normal"); cache.style_normal=get_stylebox("normal");
cache.style_focus=get_stylebox("focus"); cache.style_focus=get_stylebox("focus");
cache.font=get_font("font"); cache.font=get_font("font");
cache.caret_color=get_color("caret_color");
cache.font_color=get_color("font_color"); cache.font_color=get_color("font_color");
cache.font_selected_color=get_color("font_selected_color"); cache.font_selected_color=get_color("font_selected_color");
cache.keyword_color=get_color("keyword_color"); cache.keyword_color=get_color("keyword_color");

View File

@ -73,6 +73,7 @@ class TextEdit : public Control {
Ref<StyleBox> style_normal; Ref<StyleBox> style_normal;
Ref<StyleBox> style_focus; Ref<StyleBox> style_focus;
Ref<Font> font; Ref<Font> font;
Color caret_color;
Color font_color; Color font_color;
Color font_selected_color; Color font_selected_color;
Color keyword_color; Color keyword_color;

View File

@ -470,6 +470,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
hints["global/default_project_export_path"]=PropertyInfo(Variant::STRING,"global/default_project_export_path",PROPERTY_HINT_GLOBAL_DIR); hints["global/default_project_export_path"]=PropertyInfo(Variant::STRING,"global/default_project_export_path",PROPERTY_HINT_GLOBAL_DIR);
set("global/show_script_in_scene_tabs",false); set("global/show_script_in_scene_tabs",false);
set("text_editor/background_color",Color::html("3b000000")); set("text_editor/background_color",Color::html("3b000000"));
set("text_editor/caret_color",Color::html("aaaaaa"));
set("text_editor/text_color",Color::html("aaaaaa")); set("text_editor/text_color",Color::html("aaaaaa"));
set("text_editor/text_selected_color",Color::html("000000")); set("text_editor/text_selected_color",Color::html("000000"));
set("text_editor/keyword_color",Color::html("ffffb3")); set("text_editor/keyword_color",Color::html("ffffb3"));

View File

@ -288,6 +288,7 @@ void ScriptTextEditor::_load_theme_settings() {
get_text_edit()->set_custom_bg_color(EDITOR_DEF("text_editor/background_color",Color(0,0,0,0))); get_text_edit()->set_custom_bg_color(EDITOR_DEF("text_editor/background_color",Color(0,0,0,0)));
get_text_edit()->add_color_override("font_color",EDITOR_DEF("text_editor/text_color",Color(0,0,0))); get_text_edit()->add_color_override("font_color",EDITOR_DEF("text_editor/text_color",Color(0,0,0)));
get_text_edit()->add_color_override("caret_color",EDITOR_DEF("text_editor/caret_color",Color(0,0,0)));
get_text_edit()->add_color_override("font_selected_color",EDITOR_DEF("text_editor/text_selected_color",Color(1,1,1))); get_text_edit()->add_color_override("font_selected_color",EDITOR_DEF("text_editor/text_selected_color",Color(1,1,1)));
get_text_edit()->add_color_override("selection_color",EDITOR_DEF("text_editor/selection_color",Color(0.2,0.2,1))); get_text_edit()->add_color_override("selection_color",EDITOR_DEF("text_editor/selection_color",Color(0.2,0.2,1)));
get_text_edit()->add_color_override("brace_mismatch_color",EDITOR_DEF("text_editor/brace_mismatch_color",Color(1,0.2,0.2))); get_text_edit()->add_color_override("brace_mismatch_color",EDITOR_DEF("text_editor/brace_mismatch_color",Color(1,0.2,0.2)));