Issue-28355 - show spaces in editor
This commit is contained in:
parent
c991379b81
commit
fda3a568ef
|
@ -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_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_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_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_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_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"));
|
text_editor->set_show_line_length_guideline(EditorSettings::get_singleton()->get("text_editor/line_numbers/show_line_length_guideline"));
|
||||||
|
|
|
@ -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/auto_indent", true);
|
||||||
_initial_set("text_editor/indent/convert_indent_on_save", false);
|
_initial_set("text_editor/indent/convert_indent_on_save", false);
|
||||||
_initial_set("text_editor/indent/draw_tabs", true);
|
_initial_set("text_editor/indent/draw_tabs", true);
|
||||||
|
_initial_set("text_editor/indent/draw_spaces", false);
|
||||||
|
|
||||||
// Line numbers
|
// Line numbers
|
||||||
_initial_set("text_editor/line_numbers/show_line_numbers", true);
|
_initial_set("text_editor/line_numbers/show_line_numbers", true);
|
||||||
|
|
|
@ -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_stylebox("read_only", "TextEdit", style_widget_disabled);
|
||||||
theme->set_constant("side_margin", "TabContainer", 0);
|
theme->set_constant("side_margin", "TabContainer", 0);
|
||||||
theme->set_icon("tab", "TextEdit", theme->get_icon("GuiTab", "EditorIcons"));
|
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("folded", "TextEdit", theme->get_icon("GuiTreeArrowRight", "EditorIcons"));
|
||||||
theme->set_icon("fold", "TextEdit", theme->get_icon("GuiTreeArrowDown", "EditorIcons"));
|
theme->set_icon("fold", "TextEdit", theme->get_icon("GuiTreeArrowDown", "EditorIcons"));
|
||||||
theme->set_color("font_color", "TextEdit", font_color);
|
theme->set_color("font_color", "TextEdit", font_color);
|
||||||
|
|
|
@ -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>
|
After Width: | Height: | Size: 2.0 KiB |
|
@ -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);
|
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;
|
char_ofs += char_w;
|
||||||
|
|
||||||
if (line_wrap_index == line_wrap_amount && j == str.length() - 1 && is_folded(line)) {
|
if (line_wrap_index == line_wrap_amount && j == str.length() - 1 && is_folded(line)) {
|
||||||
|
@ -4468,6 +4473,7 @@ void TextEdit::_update_caches() {
|
||||||
#endif
|
#endif
|
||||||
cache.row_height = cache.font->get_height() + cache.line_spacing;
|
cache.row_height = cache.font->get_height() + cache.line_spacing;
|
||||||
cache.tab_icon = get_icon("tab");
|
cache.tab_icon = get_icon("tab");
|
||||||
|
cache.space_icon = get_icon("space");
|
||||||
cache.folded_icon = get_icon("folded");
|
cache.folded_icon = get_icon("folded");
|
||||||
cache.can_fold_icon = get_icon("fold");
|
cache.can_fold_icon = get_icon("fold");
|
||||||
cache.folded_eol_icon = get_icon("GuiEllipsis", "EditorIcons");
|
cache.folded_eol_icon = get_icon("GuiEllipsis", "EditorIcons");
|
||||||
|
@ -5604,6 +5610,16 @@ bool TextEdit::is_drawing_tabs() const {
|
||||||
return draw_tabs;
|
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) {
|
void TextEdit::set_override_selected_font_color(bool p_override_selected_font_color) {
|
||||||
override_selected_font_color = p_override_selected_font_color;
|
override_selected_font_color = p_override_selected_font_color;
|
||||||
}
|
}
|
||||||
|
@ -6429,6 +6445,7 @@ TextEdit::TextEdit() {
|
||||||
|
|
||||||
setting_row = false;
|
setting_row = false;
|
||||||
draw_tabs = false;
|
draw_tabs = false;
|
||||||
|
draw_spaces = false;
|
||||||
override_selected_font_color = false;
|
override_selected_font_color = false;
|
||||||
draw_caret = true;
|
draw_caret = true;
|
||||||
max_chars = 0;
|
max_chars = 0;
|
||||||
|
|
|
@ -163,6 +163,7 @@ private:
|
||||||
struct Cache {
|
struct Cache {
|
||||||
|
|
||||||
Ref<Texture> tab_icon;
|
Ref<Texture> tab_icon;
|
||||||
|
Ref<Texture> space_icon;
|
||||||
Ref<Texture> can_fold_icon;
|
Ref<Texture> can_fold_icon;
|
||||||
Ref<Texture> folded_icon;
|
Ref<Texture> folded_icon;
|
||||||
Ref<Texture> folded_eol_icon;
|
Ref<Texture> folded_eol_icon;
|
||||||
|
@ -290,6 +291,7 @@ private:
|
||||||
bool first_draw;
|
bool first_draw;
|
||||||
bool setting_row;
|
bool setting_row;
|
||||||
bool draw_tabs;
|
bool draw_tabs;
|
||||||
|
bool draw_spaces;
|
||||||
bool override_selected_font_color;
|
bool override_selected_font_color;
|
||||||
bool cursor_changed_dirty;
|
bool cursor_changed_dirty;
|
||||||
bool text_changed_dirty;
|
bool text_changed_dirty;
|
||||||
|
@ -613,6 +615,8 @@ public:
|
||||||
int get_indent_size();
|
int get_indent_size();
|
||||||
void set_draw_tabs(bool p_draw);
|
void set_draw_tabs(bool p_draw);
|
||||||
bool is_drawing_tabs() const;
|
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);
|
void set_override_selected_font_color(bool p_override_selected_font_color);
|
||||||
bool is_overriding_selected_font_color() const;
|
bool is_overriding_selected_font_color() const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue