diff options
Diffstat (limited to 'editor/code_editor.cpp')
-rw-r--r-- | editor/code_editor.cpp | 112 |
1 files changed, 3 insertions, 109 deletions
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index 61df3a977a..b188e1faca 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -902,6 +902,9 @@ void CodeTextEditor::_line_col_changed() { sb.append(" : "); sb.append(itos(positional_column + 1).lpad(3)); + sb.append(" | "); + sb.append(text_editor->is_indent_using_spaces() ? "Spaces" : "Tabs"); + line_and_col_txt->set_text(sb.as_string()); if (find_replace_bar) { @@ -1142,115 +1145,6 @@ void CodeTextEditor::insert_final_newline() { } } -void CodeTextEditor::convert_indent_to_spaces() { - int indent_size = EDITOR_GET("text_editor/behavior/indent/size"); - String indent = ""; - - for (int i = 0; i < indent_size; i++) { - indent += " "; - } - - Vector<int> cursor_columns; - cursor_columns.resize(text_editor->get_caret_count()); - for (int c = 0; c < text_editor->get_caret_count(); c++) { - cursor_columns.write[c] = text_editor->get_caret_column(c); - } - - bool changed_indentation = false; - for (int i = 0; i < text_editor->get_line_count(); i++) { - String line = text_editor->get_line(i); - - if (line.length() <= 0) { - continue; - } - - int j = 0; - while (j < line.length() && (line[j] == ' ' || line[j] == '\t')) { - if (line[j] == '\t') { - if (!changed_indentation) { - text_editor->begin_complex_operation(); - changed_indentation = true; - } - for (int c = 0; c < text_editor->get_caret_count(); c++) { - if (text_editor->get_caret_line(c) == i && text_editor->get_caret_column(c) > j) { - cursor_columns.write[c] += indent_size - 1; - } - } - line = line.left(j) + indent + line.substr(j + 1); - } - j++; - } - if (changed_indentation) { - text_editor->set_line(i, line); - } - } - if (changed_indentation) { - for (int c = 0; c < text_editor->get_caret_count(); c++) { - text_editor->set_caret_column(cursor_columns[c], c == 0, c); - } - text_editor->merge_overlapping_carets(); - text_editor->end_complex_operation(); - text_editor->queue_redraw(); - } -} - -void CodeTextEditor::convert_indent_to_tabs() { - int indent_size = EDITOR_GET("text_editor/behavior/indent/size"); - indent_size -= 1; - - Vector<int> cursor_columns; - cursor_columns.resize(text_editor->get_caret_count()); - for (int c = 0; c < text_editor->get_caret_count(); c++) { - cursor_columns.write[c] = text_editor->get_caret_column(c); - } - - bool changed_indentation = false; - for (int i = 0; i < text_editor->get_line_count(); i++) { - String line = text_editor->get_line(i); - - if (line.length() <= 0) { - continue; - } - - int j = 0; - int space_count = -1; - while (j < line.length() && (line[j] == ' ' || line[j] == '\t')) { - if (line[j] != '\t') { - space_count++; - - if (space_count == indent_size) { - if (!changed_indentation) { - text_editor->begin_complex_operation(); - changed_indentation = true; - } - for (int c = 0; c < text_editor->get_caret_count(); c++) { - if (text_editor->get_caret_line(c) == i && text_editor->get_caret_column(c) > j) { - cursor_columns.write[c] -= indent_size; - } - } - line = line.left(j - indent_size) + "\t" + line.substr(j + 1); - j = 0; - space_count = -1; - } - } else { - space_count = -1; - } - j++; - } - if (changed_indentation) { - text_editor->set_line(i, line); - } - } - if (changed_indentation) { - for (int c = 0; c < text_editor->get_caret_count(); c++) { - text_editor->set_caret_column(cursor_columns[c], c == 0, c); - } - text_editor->merge_overlapping_carets(); - text_editor->end_complex_operation(); - text_editor->queue_redraw(); - } -} - void CodeTextEditor::convert_case(CaseStyle p_case) { if (!text_editor->has_selection()) { return; |