diff options
Diffstat (limited to 'tools/editor/code_editor.cpp')
| -rw-r--r-- | tools/editor/code_editor.cpp | 54 | 
1 files changed, 45 insertions, 9 deletions
diff --git a/tools/editor/code_editor.cpp b/tools/editor/code_editor.cpp index 2779275ea8..626f86d33d 100644 --- a/tools/editor/code_editor.cpp +++ b/tools/editor/code_editor.cpp @@ -356,7 +356,7 @@ void FindReplaceBar::_show_search() {  	show();  	search_text->grab_focus(); -	if (text_edit->is_selection_active()) { +	if (text_edit->is_selection_active() && !selection_only->is_pressed()) {  		search_text->set_text(text_edit->get_selection_text());  	} @@ -376,12 +376,16 @@ void FindReplaceBar::popup_search() {  void FindReplaceBar::popup_replace() { +  	if (!replace_hbc->is_visible() || !replace_options_hbc->is_visible()) {  		replace_text->clear();  		replace_hbc->show();  		replace_options_hbc->show(); +  	} +	selection_only->set_pressed( (text_edit->is_selection_active() && text_edit->get_selection_from_line() < text_edit->get_selection_to_line()) ); +  	_show_search();  } @@ -409,6 +413,14 @@ void FindReplaceBar::_search_text_entered(const String& p_text) {  	search_next();  } +void FindReplaceBar::_replace_text_entered(const String& p_text) { + +	if (selection_only->is_pressed() && text_edit->is_selection_active()) { +		_replace_all(); +		_hide_bar(); +	} +} +  String FindReplaceBar::get_search_text() const {  	return search_text->get_text(); @@ -452,6 +464,7 @@ void FindReplaceBar::_bind_methods() {  	ObjectTypeDB::bind_method("_editor_text_changed",&FindReplaceBar::_editor_text_changed);  	ObjectTypeDB::bind_method("_search_text_changed",&FindReplaceBar::_search_text_changed);  	ObjectTypeDB::bind_method("_search_text_entered",&FindReplaceBar::_search_text_entered); +	ObjectTypeDB::bind_method("_replace_text_entered",&FindReplaceBar::_replace_text_entered);  	ObjectTypeDB::bind_method("_search_current",&FindReplaceBar::search_current);  	ObjectTypeDB::bind_method("_search_next",&FindReplaceBar::search_next);  	ObjectTypeDB::bind_method("_search_prev",&FindReplaceBar::search_prev); @@ -497,18 +510,19 @@ FindReplaceBar::FindReplaceBar() {  	replace_text = memnew(LineEdit);  	replace_hbc->add_child(replace_text);  	replace_text->set_custom_minimum_size(Size2(200, 0)); -	replace_text->connect("text_entered",this,"_search_text_entered"); +	replace_text->connect("text_entered",this,"_replace_text_entered"); + -	replace = memnew(ToolButton); +	replace = memnew(Button);  	replace_hbc->add_child(replace);  	replace->set_text(TTR("Replace")); -	replace->set_focus_mode(FOCUS_NONE); +	//replace->set_focus_mode(FOCUS_NONE);  	replace->connect("pressed",this,"_replace_pressed"); -	replace_all = memnew(ToolButton); +	replace_all = memnew(Button);  	replace_hbc->add_child(replace_all);  	replace_all->set_text(TTR("Replace All")); -	replace_all->set_focus_mode(FOCUS_NONE); +	//replace_all->set_focus_mode(FOCUS_NONE);  	replace_all->connect("pressed",this,"_replace_all_pressed");  	Control *spacer_split = memnew( Control ); @@ -581,8 +595,10 @@ void FindReplaceDialog::popup_search() {  void FindReplaceDialog::popup_replace() { +  	set_title(TTR("Replace"));  	bool do_selection=(text_edit->is_selection_active() && text_edit->get_selection_from_line() < text_edit->get_selection_to_line()); +  	set_replace_selection_only(do_selection);  	if (!do_selection && text_edit->is_selection_active()) { @@ -1035,7 +1051,7 @@ void CodeTextEditor::_reset_zoom() {  void CodeTextEditor::_line_col_changed() {  	line_nb->set_text(itos(text_editor->cursor_get_line() + 1)); -	col_nb->set_text(itos(text_editor->cursor_get_column())); +	col_nb->set_text(itos(text_editor->cursor_get_column() + 1));  }  void CodeTextEditor::_text_changed() { @@ -1089,6 +1105,24 @@ void CodeTextEditor::_font_resize_timeout() {  	}  } +void CodeTextEditor::update_editor_settings() { + +	text_editor->set_auto_brace_completion(EditorSettings::get_singleton()->get("text_editor/auto_brace_complete")); +	text_editor->set_scroll_pass_end_of_file(EditorSettings::get_singleton()->get("text_editor/scroll_past_end_of_file")); +	text_editor->set_tab_size(EditorSettings::get_singleton()->get("text_editor/tab_size")); +	text_editor->set_draw_tabs(EditorSettings::get_singleton()->get("text_editor/draw_tabs")); +	text_editor->set_show_line_numbers(EditorSettings::get_singleton()->get("text_editor/show_line_numbers")); +	text_editor->set_line_numbers_zero_padded(EditorSettings::get_singleton()->get("text_editor/line_numbers_zero_padded")); +	text_editor->set_show_line_length_guideline(EditorSettings::get_singleton()->get("text_editor/show_line_length_guideline")); +	text_editor->set_line_length_guideline_column(EditorSettings::get_singleton()->get("text_editor/line_length_guideline_column")); +	text_editor->set_syntax_coloring(EditorSettings::get_singleton()->get("text_editor/syntax_highlighting")); +	text_editor->set_highlight_all_occurrences(EditorSettings::get_singleton()->get("text_editor/highlight_all_occurrences")); +	text_editor->cursor_set_blink_enabled(EditorSettings::get_singleton()->get("text_editor/caret_blink")); +	text_editor->cursor_set_blink_speed(EditorSettings::get_singleton()->get("text_editor/caret_blink_speed")); +	text_editor->set_draw_breakpoint_gutter(EditorSettings::get_singleton()->get("text_editor/show_breakpoint_gutter")); +	text_editor->cursor_set_block_mode(EditorSettings::get_singleton()->get("text_editor/block_caret")); +} +  void CodeTextEditor::set_error(const String& p_error) {  	if (p_error!="") { @@ -1112,8 +1146,10 @@ void CodeTextEditor::_update_font() {  			font_overridden = true;  		}  	} -	if(!font_overridden) +	if(!font_overridden) { +  		text_editor->add_font_override("font",get_font("source","EditorFonts")); +	}  }  void CodeTextEditor::_on_settings_change() { @@ -1152,7 +1188,7 @@ void CodeTextEditor::_notification(int p_what) {  		_load_theme_settings();  		emit_signal("load_theme_settings");  	} -	if (p_what==NOTIFICATION_ENTER_TREE) { +	if (p_what==NOTIFICATION_THEME_CHANGED) {  		_update_font();  	}  }  |