diff options
author | Chaosus <chaosus89@gmail.com> | 2018-11-21 13:56:02 +0300 |
---|---|---|
committer | Chaosus <chaosus89@gmail.com> | 2018-11-22 11:55:36 +0300 |
commit | 1129d8327285c1d3732532b6c09a3079a4a45b58 (patch) | |
tree | b4152c588ce9282afda279f175ff95f42f461947 /editor/code_editor.cpp | |
parent | da0ec37aa9c6fd80becc9d8ffa8fd064445d8023 (diff) |
Allows user to click on error line to jump into error.
Diffstat (limited to 'editor/code_editor.cpp')
-rw-r--r-- | editor/code_editor.cpp | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index 3136b0f012..2a11f70274 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -1130,6 +1130,19 @@ void CodeTextEditor::set_edit_state(const Variant &p_state) { void CodeTextEditor::set_error(const String &p_error) { error->set_text(p_error); + error->set_tooltip(p_error); + error->set_visible(p_error != ""); +} + +void CodeTextEditor::set_error_pos(int p_line, int p_column) { + error_line = p_line; + error_column = p_column; +} + +void CodeTextEditor::_error_pressed() { + text_editor->cursor_set_line(error_line); + text_editor->cursor_set_column(error_column); + text_editor->center_viewport_to_cursor(); } void CodeTextEditor::_update_font() { @@ -1191,6 +1204,7 @@ void CodeTextEditor::_bind_methods() { 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); + ClassDB::bind_method("_error_pressed", &CodeTextEditor::_error_pressed); ADD_SIGNAL(MethodInfo("validate_script")); ADD_SIGNAL(MethodInfo("load_theme_settings")); @@ -1239,13 +1253,22 @@ CodeTextEditor::CodeTextEditor() { code_complete_timer->set_wait_time(EDITOR_DEF("text_editor/completion/code_complete_delay", .3f)); - error = memnew(Label); - status_bar->add_child(error); - error->set_autowrap(true); - error->set_valign(Label::VALIGN_CENTER); + error_line = 0; + error_column = 0; + + Control *error_box = memnew(Control); + status_bar->add_child(error_box); + error_box->set_v_size_flags(SIZE_EXPAND_FILL); + error_box->set_h_size_flags(SIZE_EXPAND_FILL); + error_box->set_clip_contents(true); + + error = memnew(LinkButton); + error_box->add_child(error); + error->set_anchors_and_margins_preset(Control::PRESET_CENTER_LEFT); + error->set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER); error->add_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_color("error_color", "Editor")); error->add_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_font("status_source", "EditorFonts")); - error->set_h_size_flags(SIZE_EXPAND_FILL); //required for it to display, given now it's clipping contents, do not touch + error->connect("pressed", this, "_error_pressed"); find_replace_bar->connect("error", error, "set_text"); status_bar->add_child(memnew(Label)); //to keep the height if the other labels are not visible |