diff options
Diffstat (limited to 'addons/gut/gui/RunAtCursor.gd')
| -rw-r--r-- | addons/gut/gui/RunAtCursor.gd | 153 |
1 files changed, 0 insertions, 153 deletions
diff --git a/addons/gut/gui/RunAtCursor.gd b/addons/gut/gui/RunAtCursor.gd deleted file mode 100644 index dc83c3e..0000000 --- a/addons/gut/gui/RunAtCursor.gd +++ /dev/null @@ -1,153 +0,0 @@ -tool -extends Control - - -var ScriptTextEditors = load('res://addons/gut/gui/script_text_editor_controls.gd') - -onready var _ctrls = { - btn_script = $HBox/BtnRunScript, - btn_inner = $HBox/BtnRunInnerClass, - btn_method = $HBox/BtnRunMethod, - lbl_none = $HBox/LblNoneSelected, - arrow_1 = $HBox/Arrow1, - arrow_2 = $HBox/Arrow2 -} - -var _editors = null -var _cur_editor = null -var _last_line = -1 -var _cur_script_path = null -var _last_info = null - -signal run_tests(what) - - -func _ready(): - _ctrls.lbl_none.visible = true - _ctrls.btn_script.visible = false - _ctrls.btn_inner.visible = false - _ctrls.btn_method.visible = false - -# ---------------- -# Private -# ---------------- -func _set_editor(which): - _last_line = -1 - if(_cur_editor != null and _cur_editor.get_ref()): - _cur_editor.get_ref().disconnect('cursor_changed', self, '_on_cursor_changed') - - if(which != null): - _cur_editor = weakref(which) - which.connect('cursor_changed', self, '_on_cursor_changed', [which]) - - _last_line = which.cursor_get_line() - _last_info = _editors.get_line_info() - _update_buttons(_last_info) - - -func _update_buttons(info): - _ctrls.lbl_none.visible = _cur_script_path == null - _ctrls.btn_script.visible = _cur_script_path != null - - _ctrls.btn_inner.visible = info.inner_class != null - _ctrls.arrow_1.visible = info.inner_class != null - _ctrls.btn_inner.text = str(info.inner_class) - _ctrls.btn_inner.hint_tooltip = str("Run all tests in Inner-Test-Class ", info.inner_class) - - _ctrls.btn_method.visible = info.test_method != null - _ctrls.arrow_2.visible = info.test_method != null - _ctrls.btn_method.text = str(info.test_method) - _ctrls.btn_method.hint_tooltip = str("Run test ", info.test_method) - - # The button's new size won't take effect until the next frame. - # This appears to be what was causing the button to not be clickable the - # first time. - call_deferred("_update_rect_size") - - -func _update_rect_size(): - rect_min_size.x = _ctrls.btn_method.rect_size.x + _ctrls.btn_method.rect_position.x - -# ---------------- -# Events -# ---------------- -func _on_cursor_changed(which): - if(which.cursor_get_line() != _last_line): - _last_line = which.cursor_get_line() - _last_info = _editors.get_line_info() - _update_buttons(_last_info) - - -func _on_BtnRunScript_pressed(): - var info = _last_info.duplicate() - info.script = _cur_script_path.get_file() - info.inner_class = null - info.test_method = null - emit_signal("run_tests", info) - - -func _on_BtnRunInnerClass_pressed(): - var info = _last_info.duplicate() - info.script = _cur_script_path.get_file() - info.test_method = null - emit_signal("run_tests", info) - - -func _on_BtnRunMethod_pressed(): - var info = _last_info.duplicate() - info.script = _cur_script_path.get_file() - emit_signal("run_tests", info) - - -# ---------------- -# Public -# ---------------- -func set_script_text_editors(value): - _editors = value - - -func activate_for_script(path): - _ctrls.btn_script.visible = true - _ctrls.btn_script.text = path.get_file() - _ctrls.btn_script.hint_tooltip = str("Run all tests in script ", path) - _cur_script_path = path - _editors.refresh() - _set_editor(_editors.get_current_text_edit()) - - -func get_script_button(): - return _ctrls.btn_script - - -func get_inner_button(): - return _ctrls.btn_inner - - -func get_test_button(): - return _ctrls.btn_method - - -# not used, thought was configurable but it's just the script prefix -func set_method_prefix(value): - _editors.set_method_prefix(value) - - -# not used, thought was configurable but it's just the script prefix -func set_inner_class_prefix(value): - _editors.set_inner_class_prefix(value) - - -# Mashed this function in here b/c it has _editors. Probably should be -# somewhere else (possibly in script_text_editor_controls). -func search_current_editor_for_text(txt): - var te = _editors.get_current_text_edit() - var result = te.search(txt, 0, 0, 0) - var to_return = -1 - - if result.size() > 0: - to_return = result[TextEdit.SEARCH_RESULT_LINE] - - return to_return - - - |
