Merge pull request #9360 from GodotExplorer/pr-external-editor-language-check

Better user experience with external text editors.
This commit is contained in:
Rémi Verschelde 2017-06-27 08:15:54 +02:00 committed by GitHub
commit 72bf46649e
8 changed files with 49 additions and 10 deletions

View file

@ -313,6 +313,13 @@ void ScriptEditor::_goto_script_line(REF p_script, int p_line) {
editor->push_item(p_script.ptr());
if (bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor"))) {
Ref<Script> script = p_script->cast_to<Script>();
if (!script.is_null() && script->get_path().is_resource_file())
edit(p_script, p_line, 0);
}
int selected = tab_container->get_current_tab();
if (selected < 0 || selected >= tab_container->get_child_count())
return;
@ -866,6 +873,11 @@ void ScriptEditor::_menu_option(int p_option) {
debugger->set_hide_on_stop(visible);
debug_menu->get_popup()->set_item_checked(debug_menu->get_popup()->get_item_index(DEBUG_SHOW_KEEP_OPEN), !visible);
} break;
case DEBUG_WITH_EXTERNAL_EDITOR: {
bool debug_with_external_editor = !debug_menu->get_popup()->is_item_checked(debug_menu->get_popup()->get_item_index(DEBUG_WITH_EXTERNAL_EDITOR));
debugger->set_debug_with_external_editor(debug_with_external_editor);
debug_menu->get_popup()->set_item_checked(debug_menu->get_popup()->get_item_index(DEBUG_WITH_EXTERNAL_EDITOR), debug_with_external_editor);
}
}
int selected = tab_container->get_current_tab();
@ -1545,13 +1557,10 @@ bool ScriptEditor::edit(const Ref<Script> &p_script, int p_line, int p_col, bool
bool open_dominant = EditorSettings::get_singleton()->get("text_editor/files/open_dominant_script_on_scene_change");
Error err = p_script->get_language()->open_in_external_editor(p_script, p_line >= 0 ? p_line : 0, p_col);
if (err == OK)
return false;
if (err != ERR_UNAVAILABLE)
WARN_PRINT("Couldn't open in custom external text editor");
if (p_script->get_path().is_resource_file() && bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor"))) {
if ((debugger->get_dump_stack_script() != p_script || debugger->get_debug_with_external_editor()) &&
p_script->get_language()->open_in_external_editor(p_script, p_line >= 0 ? p_line : 0, p_col) == OK &&
p_script->get_path().is_resource_file() &&
bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor"))) {
String path = EditorSettings::get_singleton()->get("text_editor/external/exec_path");
String flags = EditorSettings::get_singleton()->get("text_editor/external/exec_flags");
@ -2244,6 +2253,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
debug_menu->get_popup()->add_separator();
//debug_menu->get_popup()->add_check_item("Show Debugger",DEBUG_SHOW);
debug_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("debugger/keep_debugger_open", TTR("Keep Debugger Open")), DEBUG_SHOW_KEEP_OPEN);
debug_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("debugger/debug_with_exteral_editor", TTR("Debug with external editor")), DEBUG_WITH_EXTERNAL_EDITOR);
debug_menu->get_popup()->connect("id_pressed", this, "_menu_option");
debug_menu->get_popup()->set_item_disabled(debug_menu->get_popup()->get_item_index(DEBUG_NEXT), true);

View file

@ -141,6 +141,7 @@ class ScriptEditor : public VBoxContainer {
DEBUG_CONTINUE,
DEBUG_SHOW,
DEBUG_SHOW_KEEP_OPEN,
DEBUG_WITH_EXTERNAL_EDITOR,
SEARCH_HELP,
SEARCH_CLASSES,
SEARCH_WEBSITE,

View file

@ -557,6 +557,8 @@ void ScriptEditor::_update_modified_scripts_for_external_editor(Ref<Script> p_fo
if (!bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor")))
return;
ERR_FAIL_COND(!get_tree());
Set<Ref<Script> > scripts;
Node *base = get_tree()->get_edited_scene_root();

View file

@ -1137,8 +1137,9 @@ void ScriptEditorDebugger::_stack_dump_frame_selected() {
Dictionary d = ti->get_metadata(0);
Ref<Script> s = ResourceLoader::load(d["file"]);
emit_signal("goto_script_line", s, int(d["line"]) - 1);
stack_script = ResourceLoader::load(d["file"]);
emit_signal("goto_script_line", stack_script, int(d["line"]) - 1);
stack_script.unref();
ERR_FAIL_COND(connection.is_null());
ERR_FAIL_COND(!connection->is_connected_to_host());
@ -1522,6 +1523,21 @@ void ScriptEditorDebugger::set_hide_on_stop(bool p_hide) {
hide_on_stop = p_hide;
}
bool ScriptEditorDebugger::get_debug_with_external_editor() const {
return enable_external_editor;
}
void ScriptEditorDebugger::set_debug_with_external_editor(bool p_enabled) {
enable_external_editor = p_enabled;
}
Ref<Script> ScriptEditorDebugger::get_dump_stack_script() const {
return stack_script;
}
void ScriptEditorDebugger::_paused() {
ERR_FAIL_COND(connection.is_null());
@ -1871,6 +1887,7 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
last_path_id = false;
error_count = 0;
hide_on_stop = true;
enable_external_editor = false;
last_error_count = 0;
EditorNode::get_singleton()->get_pause_button()->connect("pressed", this, "_paused");

View file

@ -84,6 +84,8 @@ class ScriptEditorDebugger : public Control {
int last_error_count;
bool hide_on_stop;
bool enable_external_editor;
Ref<Script> stack_script;
TabContainer *tabs;
@ -201,6 +203,11 @@ public:
void set_hide_on_stop(bool p_hide);
bool get_debug_with_external_editor() const;
void set_debug_with_external_editor(bool p_enabled);
Ref<Script> get_dump_stack_script() const;
void set_tool_button(Button *p_tb) { debugger_button = p_tb; }
void reload_scripts();

View file

@ -335,7 +335,7 @@ public:
virtual bool has_named_classes() const;
virtual int find_function(const String &p_function, const String &p_code) const;
virtual String make_function(const String &p_class, const String &p_name, const PoolStringArray &p_args) const;
virtual Error open_in_external_editor(const Ref<Script> &p_script, int p_line, int p_col) { return ERR_UNAVAILABLE; }
virtual Error complete_code(const String &p_code, const String &p_base_path, Object *p_owner, List<String> *r_options, String &r_call_hint) { return ERR_UNAVAILABLE; }
virtual Error lookup_code(const String &p_code, const String &p_symbol, const String &p_base_path, Object *p_owner, LookupResult &r_result) { return ERR_UNAVAILABLE; }

View file

@ -389,6 +389,7 @@ public:
virtual bool can_inherit_from_file() { return true; }
virtual int find_function(const String &p_function, const String &p_code) const;
virtual String make_function(const String &p_class, const String &p_name, const PoolStringArray &p_args) const;
virtual Error open_in_external_editor(const Ref<Script> &p_script, int p_line, int p_col) { return OK; }
virtual Error complete_code(const String &p_code, const String &p_base_path, Object *p_owner, List<String> *r_options, String &r_call_hint);
#ifdef TOOLS_ENABLED
virtual Error lookup_code(const String &p_code, const String &p_symbol, const String &p_base_path, Object *p_owner, LookupResult &r_result);

View file

@ -571,6 +571,7 @@ public:
virtual bool has_named_classes() const;
virtual int find_function(const String &p_function, const String &p_code) const;
virtual String make_function(const String &p_class, const String &p_name, const PoolStringArray &p_args) const;
virtual Error open_in_external_editor(const Ref<Script> &p_script, int p_line, int p_col) { return ERR_UNAVAILABLE; }
virtual void auto_indent_code(String &p_code, int p_from_line, int p_to_line) const;
virtual void add_global_constant(const StringName &p_variable, const Variant &p_value);