Merge pull request #18595 from AlexHoratio/script_pos_columns

Script Editor now displays positional column
This commit is contained in:
Rémi Verschelde 2018-05-04 09:58:35 +02:00 committed by GitHub
commit 6405dcb7db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 1 deletions

View file

@ -677,7 +677,20 @@ void CodeTextEditor::_reset_zoom() {
void CodeTextEditor::_line_col_changed() { void CodeTextEditor::_line_col_changed() {
line_nb->set_text(itos(text_editor->cursor_get_line() + 1)); line_nb->set_text(itos(text_editor->cursor_get_line() + 1));
col_nb->set_text(itos(text_editor->cursor_get_column() + 1));
String line = text_editor->get_line(text_editor->cursor_get_line());
int positional_column = 0;
for (int i = 0; i < text_editor->cursor_get_column(); i++) {
if (line[i] == '\t') {
positional_column += text_editor->get_indent_size(); //tab size
} else {
positional_column += 1;
}
}
col_nb->set_text(itos(positional_column + 1));
} }
void CodeTextEditor::_text_changed() { void CodeTextEditor::_text_changed() {

View file

@ -4978,6 +4978,11 @@ void TextEdit::set_indent_size(const int p_size) {
update(); update();
} }
int TextEdit::get_indent_size() {
return indent_size;
}
void TextEdit::set_draw_tabs(bool p_draw) { void TextEdit::set_draw_tabs(bool p_draw) {
draw_tabs = p_draw; draw_tabs = p_draw;

View file

@ -557,6 +557,7 @@ public:
void set_indent_using_spaces(const bool p_use_spaces); void set_indent_using_spaces(const bool p_use_spaces);
bool is_indent_using_spaces() const; bool is_indent_using_spaces() const;
void set_indent_size(const int p_size); void set_indent_size(const int p_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_override_selected_font_color(bool p_override_selected_font_color); void set_override_selected_font_color(bool p_override_selected_font_color);