diff options
-rw-r--r-- | editor/code_editor.cpp | 1 | ||||
-rw-r--r-- | editor/editor_settings.cpp | 1 | ||||
-rw-r--r-- | editor/editor_themes.cpp | 1 | ||||
-rw-r--r-- | editor/icons/icon_GUI_space.svg | 71 | ||||
-rw-r--r-- | scene/gui/text_edit.cpp | 17 | ||||
-rw-r--r-- | scene/gui/text_edit.h | 4 |
6 files changed, 95 insertions, 0 deletions
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index ec984e480a..7fd7b8dac3 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -755,6 +755,7 @@ void CodeTextEditor::update_editor_settings() { text_editor->set_indent_size(EditorSettings::get_singleton()->get("text_editor/indent/size")); text_editor->set_auto_indent(EditorSettings::get_singleton()->get("text_editor/indent/auto_indent")); text_editor->set_draw_tabs(EditorSettings::get_singleton()->get("text_editor/indent/draw_tabs")); + text_editor->set_draw_spaces(EditorSettings::get_singleton()->get("text_editor/indent/draw_spaces")); text_editor->set_show_line_numbers(EditorSettings::get_singleton()->get("text_editor/line_numbers/show_line_numbers")); text_editor->set_line_numbers_zero_padded(EditorSettings::get_singleton()->get("text_editor/line_numbers/line_numbers_zero_padded")); text_editor->set_show_line_length_guideline(EditorSettings::get_singleton()->get("text_editor/line_numbers/show_line_length_guideline")); diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index b65a484b16..e879894841 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -424,6 +424,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { _initial_set("text_editor/indent/auto_indent", true); _initial_set("text_editor/indent/convert_indent_on_save", false); _initial_set("text_editor/indent/draw_tabs", true); + _initial_set("text_editor/indent/draw_spaces", false); // Line numbers _initial_set("text_editor/line_numbers/show_line_numbers", true); diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index b8dd29cecc..17b474a121 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -831,6 +831,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_stylebox("read_only", "TextEdit", style_widget_disabled); theme->set_constant("side_margin", "TabContainer", 0); theme->set_icon("tab", "TextEdit", theme->get_icon("GuiTab", "EditorIcons")); + theme->set_icon("space", "TextEdit", theme->get_icon("GuiSpace", "EditorIcons")); theme->set_icon("folded", "TextEdit", theme->get_icon("GuiTreeArrowRight", "EditorIcons")); theme->set_icon("fold", "TextEdit", theme->get_icon("GuiTreeArrowDown", "EditorIcons")); theme->set_color("font_color", "TextEdit", font_color); diff --git a/editor/icons/icon_GUI_space.svg b/editor/icons/icon_GUI_space.svg new file mode 100644 index 0000000000..caa4565f4a --- /dev/null +++ b/editor/icons/icon_GUI_space.svg @@ -0,0 +1,71 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="8" + height="8" + version="1.1" + viewBox="0 0 8 7.9999993" + id="svg98" + sodipodi:docname="icon_GUI_space.svg" + inkscape:version="0.92.4 (unknown)"> + <metadata + id="metadata104"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title></dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <defs + id="defs102"> + <inkscape:perspective + sodipodi:type="inkscape:persp3d" + inkscape:vp_x="0 : 3.9999996 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_z="8 : 3.9999996 : 1" + inkscape:persp3d-origin="4 : 2.6666664 : 1" + id="perspective992" /> + </defs> + <sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:window-width="1853" + inkscape:window-height="1025" + id="namedview100" + showgrid="false" + inkscape:zoom="70.333333" + inkscape:cx="3.4905213" + inkscape:cy="6" + inkscape:window-x="67" + inkscape:window-y="27" + inkscape:window-maximized="1" + inkscape:current-layer="svg98" + inkscape:pagecheckerboard="true" /> + <g + transform="matrix(0.5,0,0,-0.5,1,527.20001)" + id="g96" + style="fill:#ffffff;fill-opacity:0.19607843"> + <circle + cx="6" + cy="1046.4" + r="3" + id="circle94" + style="fill:#ffffff;fill-opacity:0.19607843" /> + </g> +</svg> diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index fbf6550362..6d4a3df4be 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -1252,6 +1252,11 @@ void TextEdit::_notification(int p_what) { cache.tab_icon->draw(ci, Point2(char_ofs + char_margin + ofs_x, ofs_y + yofs), in_selection && override_selected_font_color ? cache.font_selected_color : color); } + if (draw_spaces && str[j] == ' ') { + int yofs = (get_row_height() - cache.space_icon->get_height()) / 2; + cache.space_icon->draw(ci, Point2(char_ofs + char_margin + ofs_x, ofs_y + yofs), in_selection && override_selected_font_color ? cache.font_selected_color : color); + } + char_ofs += char_w; if (line_wrap_index == line_wrap_amount && j == str.length() - 1 && is_folded(line)) { @@ -4468,6 +4473,7 @@ void TextEdit::_update_caches() { #endif cache.row_height = cache.font->get_height() + cache.line_spacing; cache.tab_icon = get_icon("tab"); + cache.space_icon = get_icon("space"); cache.folded_icon = get_icon("folded"); cache.can_fold_icon = get_icon("fold"); cache.folded_eol_icon = get_icon("GuiEllipsis", "EditorIcons"); @@ -5604,6 +5610,16 @@ bool TextEdit::is_drawing_tabs() const { return draw_tabs; } +void TextEdit::set_draw_spaces(bool p_draw) { + + draw_spaces = p_draw; +} + +bool TextEdit::is_drawing_spaces() const { + + return draw_spaces; +} + void TextEdit::set_override_selected_font_color(bool p_override_selected_font_color) { override_selected_font_color = p_override_selected_font_color; } @@ -6429,6 +6445,7 @@ TextEdit::TextEdit() { setting_row = false; draw_tabs = false; + draw_spaces = false; override_selected_font_color = false; draw_caret = true; max_chars = 0; diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index 4badd85e07..eb9fb2cf57 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -163,6 +163,7 @@ private: struct Cache { Ref<Texture> tab_icon; + Ref<Texture> space_icon; Ref<Texture> can_fold_icon; Ref<Texture> folded_icon; Ref<Texture> folded_eol_icon; @@ -290,6 +291,7 @@ private: bool first_draw; bool setting_row; bool draw_tabs; + bool draw_spaces; bool override_selected_font_color; bool cursor_changed_dirty; bool text_changed_dirty; @@ -613,6 +615,8 @@ public: int get_indent_size(); void set_draw_tabs(bool p_draw); bool is_drawing_tabs() const; + void set_draw_spaces(bool p_draw); + bool is_drawing_spaces() const; void set_override_selected_font_color(bool p_override_selected_font_color); bool is_overriding_selected_font_color() const; |