diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2016-10-14 18:09:28 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-14 18:09:27 +0200 |
commit | 44e0071d0f57a8206fe2e79ef549af187912284a (patch) | |
tree | a72c7ba7df37df98e4174b7b9034a2c257ed99ba /scene | |
parent | 6c0be2c017e605c2106823e80e5aaa78fc68aba5 (diff) | |
parent | 00b3af246b03bc789a7edc45c11b000d7d63ad27 (diff) |
Merge pull request #6780 from RandomShaper/space-padded-line-numbers
Allow turning off zero-padding for line numbers
Diffstat (limited to 'scene')
-rw-r--r-- | scene/gui/text_edit.cpp | 11 | ||||
-rw-r--r-- | scene/gui/text_edit.h | 3 |
2 files changed, 13 insertions, 1 deletions
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index a68d3c13a7..f1a2823e8f 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -693,6 +693,8 @@ void TextEdit::_notification(int p_what) { // get the highlighted words String highlighted_text = get_selection_text(); + String line_num_padding = line_numbers_zero_padded ? "0" : " "; + for (int i=0;i<visible_rows;i++) { int line=i+cursor.line_ofs; @@ -758,7 +760,7 @@ void TextEdit::_notification(int p_what) { if (cache.line_number_w) { String fc = String::num(line+1); while (fc.length() < line_number_char_count) { - fc="0"+fc; + fc=line_num_padding+fc; } 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); @@ -4520,6 +4522,12 @@ void TextEdit::set_show_line_numbers(bool p_show) { update(); } +void TextEdit::set_line_numbers_zero_padded(bool p_zero_padded) { + + line_numbers_zero_padded=p_zero_padded; + update(); +} + bool TextEdit::is_show_line_numbers_enabled() const { return line_numbers; } @@ -4811,6 +4819,7 @@ TextEdit::TextEdit() { completion_line_ofs=0; tooltip_obj=NULL; line_numbers=false; + line_numbers_zero_padded=false; line_length_guideline=false; line_length_guideline_col=80; draw_breakpoint_gutter=false; diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index e6401e2b92..7820fefdd2 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -232,6 +232,7 @@ class TextEdit : public Control { bool text_changed_dirty; bool undo_enabled; bool line_numbers; + bool line_numbers_zero_padded; bool line_length_guideline; int line_length_guideline_col; bool draw_breakpoint_gutter; @@ -489,6 +490,8 @@ public: void set_show_line_numbers(bool p_show); bool is_show_line_numbers_enabled() const; + void set_line_numbers_zero_padded(bool p_zero_padded); + void set_show_line_length_guideline(bool p_show); void set_line_length_guideline_column(int p_column); |