summaryrefslogtreecommitdiff
path: root/tools/editor/code_editor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/editor/code_editor.cpp')
-rw-r--r--tools/editor/code_editor.cpp128
1 files changed, 65 insertions, 63 deletions
diff --git a/tools/editor/code_editor.cpp b/tools/editor/code_editor.cpp
index 626f86d33d..0a25b43716 100644
--- a/tools/editor/code_editor.cpp
+++ b/tools/editor/code_editor.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -27,6 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "code_editor.h"
+
#include "editor_settings.h"
#include "scene/gui/margin_container.h"
#include "scene/gui/separator.h"
@@ -91,7 +92,7 @@ void FindReplaceBar::_notification(int p_what) {
} else if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
- set_process_unhandled_input(is_visible());
+ set_process_unhandled_input(is_visible_in_tree());
}
}
@@ -377,7 +378,7 @@ void FindReplaceBar::popup_search() {
void FindReplaceBar::popup_replace() {
- if (!replace_hbc->is_visible() || !replace_options_hbc->is_visible()) {
+ if (!replace_hbc->is_visible_in_tree() || !replace_options_hbc->is_visible_in_tree()) {
replace_text->clear();
replace_hbc->show();
replace_options_hbc->show();
@@ -396,7 +397,7 @@ void FindReplaceBar::_search_options_changed(bool p_pressed) {
void FindReplaceBar::_editor_text_changed() {
- if (is_visible()) {
+ if (is_visible_in_tree()) {
preserve_cursor=true;
search_current();
preserve_cursor=false;
@@ -459,19 +460,19 @@ void FindReplaceBar::set_text_edit(TextEdit *p_text_edit) {
void FindReplaceBar::_bind_methods() {
- ObjectTypeDB::bind_method("_unhandled_input",&FindReplaceBar::_unhandled_input);
+ ClassDB::bind_method("_unhandled_input",&FindReplaceBar::_unhandled_input);
- 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);
- ObjectTypeDB::bind_method("_replace_pressed",&FindReplaceBar::_replace);
- ObjectTypeDB::bind_method("_replace_all_pressed",&FindReplaceBar::_replace_all);
- ObjectTypeDB::bind_method("_search_options_changed",&FindReplaceBar::_search_options_changed);
- ObjectTypeDB::bind_method("_hide_pressed",&FindReplaceBar::_hide_bar);
+ ClassDB::bind_method("_editor_text_changed",&FindReplaceBar::_editor_text_changed);
+ ClassDB::bind_method("_search_text_changed",&FindReplaceBar::_search_text_changed);
+ ClassDB::bind_method("_search_text_entered",&FindReplaceBar::_search_text_entered);
+ ClassDB::bind_method("_replace_text_entered",&FindReplaceBar::_replace_text_entered);
+ ClassDB::bind_method("_search_current",&FindReplaceBar::search_current);
+ ClassDB::bind_method("_search_next",&FindReplaceBar::search_next);
+ ClassDB::bind_method("_search_prev",&FindReplaceBar::search_prev);
+ ClassDB::bind_method("_replace_pressed",&FindReplaceBar::_replace);
+ ClassDB::bind_method("_replace_all_pressed",&FindReplaceBar::_replace_all);
+ ClassDB::bind_method("_search_options_changed",&FindReplaceBar::_search_options_changed);
+ ClassDB::bind_method("_hide_pressed",&FindReplaceBar::_hide_bar);
ADD_SIGNAL(MethodInfo("search"));
}
@@ -714,7 +715,7 @@ void FindReplaceDialog::_replace() {
}
text_edit->set_v_scroll(vsval);
-// text_edit->set_h_scroll(hsval);
+ //text_edit->set_h_scroll(hsval);
error_label->set_text(vformat(TTR("Replaced %d ocurrence(s)."),rc));
@@ -801,7 +802,7 @@ void FindReplaceDialog::_skip_pressed() {
bool FindReplaceDialog::is_replace_mode() const {
- return replace_text->is_visible();
+ return replace_text->is_visible_in_tree();
}
bool FindReplaceDialog::is_replace_all_mode() const {
@@ -826,7 +827,7 @@ void FindReplaceDialog::ok_pressed() {
void FindReplaceDialog::_search_text_entered(const String& p_text) {
- if (replace_text->is_visible())
+ if (replace_text->is_visible_in_tree())
return;
emit_signal("search");
_search();
@@ -835,7 +836,7 @@ void FindReplaceDialog::_search_text_entered(const String& p_text) {
void FindReplaceDialog::_replace_text_entered(const String& p_text) {
- if (!replace_text->is_visible())
+ if (!replace_text->is_visible_in_tree())
return;
emit_signal("search");
@@ -884,10 +885,10 @@ void FindReplaceDialog::search_next() {
void FindReplaceDialog::_bind_methods() {
- ObjectTypeDB::bind_method("_search_text_entered",&FindReplaceDialog::_search_text_entered);
- ObjectTypeDB::bind_method("_replace_text_entered",&FindReplaceDialog::_replace_text_entered);
- ObjectTypeDB::bind_method("_prompt_changed",&FindReplaceDialog::_prompt_changed);
- ObjectTypeDB::bind_method("_skip_pressed",&FindReplaceDialog::_skip_pressed);
+ ClassDB::bind_method("_search_text_entered",&FindReplaceDialog::_search_text_entered);
+ ClassDB::bind_method("_replace_text_entered",&FindReplaceDialog::_replace_text_entered);
+ ClassDB::bind_method("_prompt_changed",&FindReplaceDialog::_prompt_changed);
+ ClassDB::bind_method("_skip_pressed",&FindReplaceDialog::_skip_pressed);
ADD_SIGNAL(MethodInfo("search"));
ADD_SIGNAL(MethodInfo("skip"));
@@ -895,11 +896,11 @@ void FindReplaceDialog::_bind_methods() {
FindReplaceDialog::FindReplaceDialog() {
- set_self_opacity(0.8);
+ set_self_modulate(Color(1,1,1,0.8));
VBoxContainer *vb = memnew( VBoxContainer );
add_child(vb);
- set_child_rect(vb);
+
search_text = memnew( LineEdit );
@@ -951,7 +952,7 @@ FindReplaceDialog::FindReplaceDialog() {
VBoxContainer *rvb = memnew( VBoxContainer);
opt_mg->add_child(rvb);
replace_vb=rvb;
-// rvb ->add_child(memnew(HSeparator));
+ //rvb ->add_child(memnew(HSeparator));
rvb ->add_child(memnew(Label));
prompt = memnew( CheckButton );
@@ -995,7 +996,7 @@ FindReplaceDialog::FindReplaceDialog() {
/*** CODE EDITOR ****/
-void CodeTextEditor::_text_editor_input_event(const InputEvent& p_event) {
+void CodeTextEditor::_text_editor_gui_input(const InputEvent& p_event) {
if (p_event.type==InputEvent::MOUSE_BUTTON) {
@@ -1043,7 +1044,7 @@ void CodeTextEditor::_reset_zoom() {
Ref<DynamicFont> font = text_editor->get_font("font"); // reset source font size to default
if (font.is_valid()) {
- EditorSettings::get_singleton()->set("global/source_font_size",14);
+ EditorSettings::get_singleton()->set("interface/source_font_size",14);
font->set_size(14);
}
}
@@ -1061,7 +1062,7 @@ void CodeTextEditor::_text_changed() {
}
void CodeTextEditor::_code_complete_timer_timeout() {
- if (!is_visible())
+ if (!is_visible_in_tree())
return;
if (enable_complete_timer)
text_editor->query_code_comple();
@@ -1097,7 +1098,7 @@ void CodeTextEditor::_font_resize_timeout() {
int size=font->get_size()+font_resize_val;
if (size>=8 && size<=96) {
- EditorSettings::get_singleton()->set("global/source_font_size",size);
+ EditorSettings::get_singleton()->set("interface/source_font_size",size);
font->set_size(size);
}
@@ -1107,20 +1108,20 @@ 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"));
+ text_editor->set_auto_brace_completion(EditorSettings::get_singleton()->get("text_editor/completion/auto_brace_complete"));
+ text_editor->set_scroll_pass_end_of_file(EditorSettings::get_singleton()->get("text_editor/cursor/scroll_past_end_of_file"));
+ text_editor->set_tab_size(EditorSettings::get_singleton()->get("text_editor/indent/tab_size"));
+ text_editor->set_draw_tabs(EditorSettings::get_singleton()->get("text_editor/indent/draw_tabs"));
+ text_editor->set_show_line_numbers(EditorSettings::get_singleton()->get("text_editor/line_numbers/show_line_numbers"));
+ text_editor->set_line_numbers_zero_padded(EditorSettings::get_singleton()->get("text_editor/line_numbers/line_numbers_zero_padded"));
+ text_editor->set_show_line_length_guideline(EditorSettings::get_singleton()->get("text_editor/line_numbers/show_line_length_guideline"));
+ text_editor->set_line_length_guideline_column(EditorSettings::get_singleton()->get("text_editor/line_numbers/line_length_guideline_column"));
+ 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->cursor_set_blink_enabled(EditorSettings::get_singleton()->get("text_editor/cursor/caret_blink"));
+ text_editor->cursor_set_blink_speed(EditorSettings::get_singleton()->get("text_editor/cursor/caret_blink_speed"));
+ text_editor->set_draw_breakpoint_gutter(EditorSettings::get_singleton()->get("text_editor/line_numbers/show_breakpoint_gutter"));
+ text_editor->cursor_set_block_mode(EditorSettings::get_singleton()->get("text_editor/cursor/block_caret"));
}
void CodeTextEditor::set_error(const String& p_error) {
@@ -1137,7 +1138,7 @@ void CodeTextEditor::set_error(const String& p_error) {
void CodeTextEditor::_update_font() {
// FONTS
- String editor_font = EDITOR_DEF("text_editor/font", "");
+ String editor_font = EDITOR_DEF("text_editor/theme/font", "");
bool font_overridden = false;
if (editor_font!="") {
Ref<Font> fnt = ResourceLoader::load(editor_font);
@@ -1158,19 +1159,19 @@ void CodeTextEditor::_on_settings_change() {
// AUTO BRACE COMPLETION
text_editor->set_auto_brace_completion(
- EDITOR_DEF("text_editor/auto_brace_complete", true)
+ EDITOR_DEF("text_editor/completion/auto_brace_complete", true)
);
code_complete_timer->set_wait_time(
- EDITOR_DEF("text_editor/code_complete_delay",.3f)
+ EDITOR_DEF("text_editor/completion/code_complete_delay",.3f)
);
- enable_complete_timer = EDITOR_DEF("text_editor/enable_code_completion_delay",true);
+ enable_complete_timer = EDITOR_DEF("text_editor/completion/enable_code_completion_delay",true);
// call hint settings
text_editor->set_callhint_settings(
- EDITOR_DEF("text_editor/put_callhint_tooltip_below_current_line", true),
- EDITOR_DEF("text_editor/callhint_tooltip_offset", Vector2())
+ EDITOR_DEF("text_editor/completion/put_callhint_tooltip_below_current_line", true),
+ EDITOR_DEF("text_editor/completion/callhint_tooltip_offset", Vector2())
);
}
@@ -1195,14 +1196,14 @@ void CodeTextEditor::_notification(int p_what) {
void CodeTextEditor::_bind_methods() {
- ObjectTypeDB::bind_method("_text_editor_input_event",&CodeTextEditor::_text_editor_input_event);
- ObjectTypeDB::bind_method("_line_col_changed",&CodeTextEditor::_line_col_changed);
- ObjectTypeDB::bind_method("_text_changed",&CodeTextEditor::_text_changed);
- ObjectTypeDB::bind_method("_on_settings_change",&CodeTextEditor::_on_settings_change);
- ObjectTypeDB::bind_method("_text_changed_idle_timeout",&CodeTextEditor::_text_changed_idle_timeout);
- ObjectTypeDB::bind_method("_code_complete_timer_timeout",&CodeTextEditor::_code_complete_timer_timeout);
- ObjectTypeDB::bind_method("_complete_request",&CodeTextEditor::_complete_request);
- ObjectTypeDB::bind_method("_font_resize_timeout",&CodeTextEditor::_font_resize_timeout);
+ ClassDB::bind_method("_text_editor_gui_input",&CodeTextEditor::_text_editor_gui_input);
+ ClassDB::bind_method("_line_col_changed",&CodeTextEditor::_line_col_changed);
+ ClassDB::bind_method("_text_changed",&CodeTextEditor::_text_changed);
+ ClassDB::bind_method("_on_settings_change",&CodeTextEditor::_on_settings_change);
+ ClassDB::bind_method("_text_changed_idle_timeout",&CodeTextEditor::_text_changed_idle_timeout);
+ ClassDB::bind_method("_code_complete_timer_timeout",&CodeTextEditor::_code_complete_timer_timeout);
+ ClassDB::bind_method("_complete_request",&CodeTextEditor::_complete_request);
+ ClassDB::bind_method("_font_resize_timeout",&CodeTextEditor::_font_resize_timeout);
ADD_SIGNAL(MethodInfo("validate_script"));
ADD_SIGNAL(MethodInfo("load_theme_settings"));
@@ -1252,14 +1253,14 @@ CodeTextEditor::CodeTextEditor() {
idle = memnew( Timer );
add_child(idle);
idle->set_one_shot(true);
- idle->set_wait_time(EDITOR_DEF("text_editor/idle_parse_delay",2));
+ idle->set_wait_time(EDITOR_DEF("text_editor/completion/idle_parse_delay",2));
code_complete_timer = memnew(Timer);
add_child(code_complete_timer);
code_complete_timer->set_one_shot(true);
- enable_complete_timer = EDITOR_DEF("text_editor/enable_code_completion_delay",true);
+ enable_complete_timer = EDITOR_DEF("text_editor/completion/enable_code_completion_delay",true);
- code_complete_timer->set_wait_time(EDITOR_DEF("text_editor/code_complete_delay",.3f));
+ code_complete_timer->set_wait_time(EDITOR_DEF("text_editor/completion/code_complete_delay",.3f));
error = memnew( Label );
status_bar->add_child(error);
@@ -1297,7 +1298,7 @@ CodeTextEditor::CodeTextEditor() {
col_nb->set_autowrap(true); // workaround to prevent resizing the label on each change
col_nb->set_custom_minimum_size(Size2(40,1)*EDSCALE);
- text_editor->connect("input_event", this,"_text_editor_input_event");
+ text_editor->connect("gui_input", this,"_text_editor_gui_input");
text_editor->connect("cursor_changed", this,"_line_col_changed");
text_editor->connect("text_changed", this,"_text_changed");
text_editor->connect("request_completion", this,"_complete_request");
@@ -1305,6 +1306,7 @@ CodeTextEditor::CodeTextEditor() {
cs.push_back(".");
cs.push_back(",");
cs.push_back("(");
+ cs.push_back("$");
text_editor->set_completion(true,cs);
idle->connect("timeout", this,"_text_changed_idle_timeout");