From e49ac08c24a9a62c6766fdddcd1f9908002cb013 Mon Sep 17 00:00:00 2001 From: toger5 Date: Thu, 28 Sep 2017 16:10:30 +0200 Subject: [PATCH] do not overlap current line with selection color --- editor/editor_themes.cpp | 4 ++-- scene/gui/text_edit.cpp | 19 ++++++++++++++----- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 1ae898c4711..f6bfd03e116 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -811,8 +811,8 @@ Ref create_editor_theme(const Ref p_theme) { const Color dim_color = Color(font_color.r, font_color.g, font_color.b, 0.5); const float mono_value = mono_color.r; - const Color alpha1 = Color(mono_value, mono_value, mono_value, 0.1); - const Color alpha2 = Color(mono_value, mono_value, mono_value, 0.3); + const Color alpha1 = Color(mono_value, mono_value, mono_value, 0.07); + const Color alpha2 = Color(mono_value, mono_value, mono_value, 0.14); const Color alpha3 = Color(mono_value, mono_value, mono_value, 0.5); const Color alpha4 = Color(mono_value, mono_value, mono_value, 0.7); diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 7138c59c848..facd272eed4 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -733,10 +733,6 @@ void TextEdit::_notification(int p_what) { VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg, ofs_y, xmargin_end - xmargin_beg, get_row_height()), cache.mark_color); } - if (line == cursor.line) { - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(0, ofs_y, xmargin_end, get_row_height()), cache.current_line_color); - } - if (text.is_breakpoint(line) && !draw_breakpoint_gutter) { #ifdef TOOLS_ENABLED VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg, ofs_y + get_row_height() - EDSCALE, xmargin_end - xmargin_beg, EDSCALE), cache.breakpoint_color); @@ -765,6 +761,7 @@ void TextEdit::_notification(int p_what) { cache.font->draw(ci, Point2(cache.style_normal->get_margin(MARGIN_LEFT) + cache.breakpoint_gutter_width, ofs_y + cache.font->get_ascent()), fc, cache.line_number_color); } + //loop through charcters in one line for (int j = 0; j < str.length(); j++) { //look for keyword @@ -953,10 +950,22 @@ void TextEdit::_notification(int p_what) { } } + //current line highlighting bool in_selection = (selection.active && line >= selection.from_line && line <= selection.to_line && (line > selection.from_line || j >= selection.from_column) && (line < selection.to_line || j < selection.to_column)); + if (line == cursor.line) { + if (j == 0) + //first char + VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(0, ofs_y, (char_ofs + char_margin), get_row_height()), cache.current_line_color); + else if (j == str.length() - 1) + //last char + VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(char_ofs + char_margin + char_w, ofs_y, xmargin_end - (char_ofs + char_margin + char_w), get_row_height()), cache.current_line_color); + + if (!in_selection) + VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin, ofs_y), Size2i(char_w, get_row_height())), cache.current_line_color); + } + if (in_selection) { - //inside selection! VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin, ofs_y), Size2i(char_w, get_row_height())), cache.selection_color); }