1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-05 12:10:55 +00:00

Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks

Which means that reduz' beloved style which we all became used to
will now be changed automatically to remove the first empty line.

This makes us lean closer to 1TBS (the one true brace style) instead
of hybridating it with some Allman-inspired spacing.

There's still the case of braces around single-statement blocks that
needs to be addressed (but clang-format can't help with that, but
clang-tidy may if we agree about it).

Part of #33027.
This commit is contained in:
Rémi Verschelde
2020-05-14 13:23:58 +02:00
parent 710b34b702
commit 0be6d925dc
1552 changed files with 1 additions and 33876 deletions

View File

@@ -41,7 +41,6 @@
#include "scene/resources/dynamic_font.h"
void GotoLineDialog::popup_find_line(TextEdit *p_edit) {
text_editor = p_edit;
line->set_text(itos(text_editor->cursor_get_line()));
@@ -51,12 +50,10 @@ void GotoLineDialog::popup_find_line(TextEdit *p_edit) {
}
int GotoLineDialog::get_line() const {
return line->get_text().to_int();
}
void GotoLineDialog::ok_pressed() {
if (get_line() < 1 || get_line() > text_editor->get_line_count())
return;
text_editor->unfold_line(get_line() - 1);
@@ -65,7 +62,6 @@ void GotoLineDialog::ok_pressed() {
}
GotoLineDialog::GotoLineDialog() {
set_title(TTR("Go to Line"));
VBoxContainer *vbc = memnew(VBoxContainer);
@@ -88,9 +84,7 @@ GotoLineDialog::GotoLineDialog() {
}
void FindReplaceBar::_notification(int p_what) {
if (p_what == NOTIFICATION_READY) {
find_prev->set_icon(get_theme_icon("MoveUp", "EditorIcons"));
find_next->set_icon(get_theme_icon("MoveDown", "EditorIcons"));
hide_button->set_normal_texture(get_theme_icon("Close", "EditorIcons"));
@@ -98,10 +92,8 @@ void FindReplaceBar::_notification(int p_what) {
hide_button->set_pressed_texture(get_theme_icon("Close", "EditorIcons"));
hide_button->set_custom_minimum_size(hide_button->get_normal_texture()->get_size());
} else if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
set_process_unhandled_input(is_visible_in_tree());
} else if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
find_prev->set_icon(get_theme_icon("MoveUp", "EditorIcons"));
find_next->set_icon(get_theme_icon("MoveDown", "EditorIcons"));
hide_button->set_normal_texture(get_theme_icon("Close", "EditorIcons"));
@@ -114,22 +106,16 @@ void FindReplaceBar::_notification(int p_what) {
}
void FindReplaceBar::_unhandled_input(const Ref<InputEvent> &p_event) {
Ref<InputEventKey> k = p_event;
if (k.is_valid()) {
if (k->is_pressed() && (text_edit->has_focus() || vbc_lineedit->is_a_parent_of(get_focus_owner()))) {
bool accepted = true;
switch (k->get_keycode()) {
case KEY_ESCAPE: {
_hide_bar();
} break;
default: {
accepted = false;
} break;
}
@@ -142,7 +128,6 @@ void FindReplaceBar::_unhandled_input(const Ref<InputEvent> &p_event) {
}
bool FindReplaceBar::_search(uint32_t p_flags, int p_from_line, int p_from_col) {
int line, col;
String text = get_search_text();
@@ -180,7 +165,6 @@ bool FindReplaceBar::_search(uint32_t p_flags, int p_from_line, int p_from_col)
}
void FindReplaceBar::_replace() {
if (result_line != -1 && result_col != -1) {
text_edit->begin_complex_operation();
@@ -199,7 +183,6 @@ void FindReplaceBar::_replace() {
}
void FindReplaceBar::_replace_all() {
text_edit->disconnect("text_changed", callable_mp(this, &FindReplaceBar::_editor_text_changed));
// Line as x so it gets priority in comparison, column as y.
Point2i orig_cursor(text_edit->cursor_get_line(), text_edit->cursor_get_column());
@@ -289,7 +272,6 @@ void FindReplaceBar::_replace_all() {
}
void FindReplaceBar::_get_search_from(int &r_line, int &r_col) {
r_line = text_edit->cursor_get_line();
r_col = text_edit->cursor_get_column();
@@ -335,7 +317,6 @@ void FindReplaceBar::_update_results_count() {
}
void FindReplaceBar::_update_matches_label() {
if (search_text->get_text().empty() || results_count == -1) {
matches_label->hide();
} else {
@@ -347,7 +328,6 @@ void FindReplaceBar::_update_matches_label() {
}
bool FindReplaceBar::search_current() {
uint32_t flags = 0;
if (is_whole_words())
@@ -362,7 +342,6 @@ bool FindReplaceBar::search_current() {
}
bool FindReplaceBar::search_prev() {
if (!is_visible())
popup_search(true);
@@ -393,7 +372,6 @@ bool FindReplaceBar::search_prev() {
}
bool FindReplaceBar::search_next() {
if (!is_visible())
popup_search(true);
@@ -426,7 +404,6 @@ bool FindReplaceBar::search_next() {
}
void FindReplaceBar::_hide_bar() {
if (replace_text->has_focus() || search_text->has_focus())
text_edit->grab_focus();
@@ -437,7 +414,6 @@ void FindReplaceBar::_hide_bar() {
}
void FindReplaceBar::_show_search(bool p_focus_replace, bool p_show_only) {
show();
if (p_show_only)
return;
@@ -470,7 +446,6 @@ void FindReplaceBar::_show_search(bool p_focus_replace, bool p_show_only) {
}
void FindReplaceBar::popup_search(bool p_show_only) {
replace_text->hide();
hbc_button_replace->hide();
hbc_option_replace->hide();
@@ -479,7 +454,6 @@ void FindReplaceBar::popup_search(bool p_show_only) {
}
void FindReplaceBar::popup_replace() {
if (!replace_text->is_visible_in_tree()) {
replace_text->show();
hbc_button_replace->show();
@@ -492,13 +466,11 @@ void FindReplaceBar::popup_replace() {
}
void FindReplaceBar::_search_options_changed(bool p_pressed) {
results_count = -1;
search_current();
}
void FindReplaceBar::_editor_text_changed() {
results_count = -1;
if (is_visible_in_tree()) {
preserve_cursor = true;
@@ -508,13 +480,11 @@ void FindReplaceBar::_editor_text_changed() {
}
void FindReplaceBar::_search_text_changed(const String &p_text) {
results_count = -1;
search_current();
}
void FindReplaceBar::_search_text_entered(const String &p_text) {
if (Input::get_singleton()->is_key_pressed(KEY_SHIFT)) {
search_prev();
} else {
@@ -523,7 +493,6 @@ void FindReplaceBar::_search_text_entered(const String &p_text) {
}
void FindReplaceBar::_replace_text_entered(const String &p_text) {
if (selection_only->is_pressed() && text_edit->is_selection_active()) {
_replace_all();
_hide_bar();
@@ -536,44 +505,36 @@ void FindReplaceBar::_replace_text_entered(const String &p_text) {
}
String FindReplaceBar::get_search_text() const {
return search_text->get_text();
}
String FindReplaceBar::get_replace_text() const {
return replace_text->get_text();
}
bool FindReplaceBar::is_case_sensitive() const {
return case_sensitive->is_pressed();
}
bool FindReplaceBar::is_whole_words() const {
return whole_words->is_pressed();
}
bool FindReplaceBar::is_selection_only() const {
return selection_only->is_pressed();
}
void FindReplaceBar::set_error(const String &p_label) {
emit_signal("error", p_label);
}
void FindReplaceBar::set_text_edit(TextEdit *p_text_edit) {
results_count = -1;
text_edit = p_text_edit;
text_edit->connect("text_changed", callable_mp(this, &FindReplaceBar::_editor_text_changed));
}
void FindReplaceBar::_bind_methods() {
ClassDB::bind_method("_unhandled_input", &FindReplaceBar::_unhandled_input);
ClassDB::bind_method("_search_current", &FindReplaceBar::search_current);
@@ -583,7 +544,6 @@ void FindReplaceBar::_bind_methods() {
}
FindReplaceBar::FindReplaceBar() {
results_count = -1;
replace_all_mode = false;
preserve_cursor = false;
@@ -676,7 +636,6 @@ FindReplaceBar::FindReplaceBar() {
// This function should be used to handle shortcuts that could otherwise
// be handled too late if they weren't handled here.
void CodeTextEditor::_input(const Ref<InputEvent> &event) {
const Ref<InputEventKey> key_event = event;
if (!key_event.is_valid() || !key_event->is_pressed())
return;
@@ -704,13 +663,10 @@ void CodeTextEditor::_input(const Ref<InputEvent> &event) {
}
void CodeTextEditor::_text_editor_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseButton> mb = p_event;
if (mb.is_valid()) {
if (mb->is_pressed() && mb->get_command()) {
if (mb->get_button_index() == BUTTON_WHEEL_UP) {
_zoom_in();
} else if (mb->get_button_index() == BUTTON_WHEEL_DOWN) {
@@ -721,7 +677,6 @@ void CodeTextEditor::_text_editor_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMagnifyGesture> magnify_gesture = p_event;
if (magnify_gesture.is_valid()) {
Ref<DynamicFont> font = text_editor->get_theme_font("font");
if (font.is_valid()) {
@@ -739,7 +694,6 @@ void CodeTextEditor::_text_editor_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventKey> k = p_event;
if (k.is_valid()) {
if (k->is_pressed()) {
if (ED_IS_SHORTCUT("script_editor/zoom_in", p_event)) {
_zoom_in();
@@ -779,7 +733,6 @@ void CodeTextEditor::_reset_zoom() {
}
void CodeTextEditor::_line_col_changed() {
String line = text_editor->get_line(text_editor->cursor_get_line());
int positional_column = 0;
@@ -802,7 +755,6 @@ void CodeTextEditor::_line_col_changed() {
}
void CodeTextEditor::_text_changed() {
if (text_editor->is_insert_text_operation()) {
code_complete_timer->start();
}
@@ -817,7 +769,6 @@ void CodeTextEditor::_code_complete_timer_timeout() {
}
void CodeTextEditor::_complete_request() {
List<ScriptCodeCompletionOption> entries;
String ctext = text_editor->get_text_for_completion();
_code_complete_script(ctext, &entries);
@@ -879,14 +830,12 @@ Ref<Texture2D> CodeTextEditor::_get_completion_icon(const ScriptCodeCompletionOp
}
void CodeTextEditor::_font_resize_timeout() {
if (_add_font_size(font_resize_val)) {
font_resize_val = 0;
}
}
bool CodeTextEditor::_add_font_size(int p_delta) {
Ref<DynamicFont> font = text_editor->get_theme_font("font");
if (font.is_valid()) {
@@ -904,7 +853,6 @@ bool CodeTextEditor::_add_font_size(int p_delta) {
}
void CodeTextEditor::update_editor_settings() {
text_editor->set_syntax_coloring(EditorSettings::get_singleton()->get("text_editor/highlighting/syntax_highlighting"));
text_editor->set_highlight_all_occurrences(EditorSettings::get_singleton()->get("text_editor/highlighting/highlight_all_occurrences"));
text_editor->set_highlight_current_line(EditorSettings::get_singleton()->get("text_editor/highlighting/highlight_current_line"));
@@ -940,7 +888,6 @@ void CodeTextEditor::trim_trailing_whitespace() {
for (int i = 0; i < text_editor->get_line_count(); i++) {
String line = text_editor->get_line(i);
if (line.ends_with(" ") || line.ends_with("\t")) {
if (!trimed_whitespace) {
text_editor->begin_complex_operation();
trimed_whitespace = true;
@@ -1440,7 +1387,6 @@ void CodeTextEditor::set_edit_state(const Variant &p_state) {
}
void CodeTextEditor::set_error(const String &p_error) {
error->set_text(p_error);
if (p_error != "") {
error->set_default_cursor_shape(CURSOR_POINTING_HAND);
@@ -1463,7 +1409,6 @@ void CodeTextEditor::goto_error() {
}
void CodeTextEditor::_update_font() {
text_editor->add_theme_font_override("font", get_theme_font("source", "EditorFonts"));
error->add_theme_font_override("font", get_theme_font("status_source", "EditorFonts"));
@@ -1480,7 +1425,6 @@ void CodeTextEditor::_update_font() {
}
void CodeTextEditor::_on_settings_change() {
_update_font();
font_size = EditorSettings::get_singleton()->get("interface/editor/code_font_size");
@@ -1537,7 +1481,6 @@ void CodeTextEditor::_error_pressed(const Ref<InputEvent> &p_event) {
}
void CodeTextEditor::_notification(int p_what) {
switch (p_what) {
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
_load_theme_settings();
@@ -1573,13 +1516,11 @@ void CodeTextEditor::set_warning_nb(int p_warning_nb) {
}
void CodeTextEditor::toggle_bookmark() {
int line = text_editor->cursor_get_line();
text_editor->set_line_as_bookmark(line, !text_editor->is_line_set_as_bookmark(line));
}
void CodeTextEditor::goto_next_bookmark() {
List<int> bmarks;
text_editor->get_bookmarks(&bmarks);
if (bmarks.size() <= 0) {
@@ -1605,7 +1546,6 @@ void CodeTextEditor::goto_next_bookmark() {
}
void CodeTextEditor::goto_prev_bookmark() {
List<int> bmarks;
text_editor->get_bookmarks(&bmarks);
if (bmarks.size() <= 0) {
@@ -1631,7 +1571,6 @@ void CodeTextEditor::goto_prev_bookmark() {
}
void CodeTextEditor::remove_all_bookmarks() {
List<int> bmarks;
text_editor->get_bookmarks(&bmarks);
@@ -1641,7 +1580,6 @@ void CodeTextEditor::remove_all_bookmarks() {
}
void CodeTextEditor::_bind_methods() {
ClassDB::bind_method(D_METHOD("_input"), &CodeTextEditor::_input);
ADD_SIGNAL(MethodInfo("validate_script"));
@@ -1665,7 +1603,6 @@ void CodeTextEditor::update_toggle_scripts_button() {
}
CodeTextEditor::CodeTextEditor() {
code_complete_func = nullptr;
ED_SHORTCUT("script_editor/zoom_in", TTR("Zoom In"), KEY_MASK_CMD | KEY_EQUAL);
ED_SHORTCUT("script_editor/zoom_out", TTR("Zoom Out"), KEY_MASK_CMD | KEY_MINUS);