summaryrefslogtreecommitdiff
path: root/addons/gut/gui/RunAtCursor.gd
diff options
context:
space:
mode:
Diffstat (limited to 'addons/gut/gui/RunAtCursor.gd')
-rw-r--r--addons/gut/gui/RunAtCursor.gd63
1 files changed, 43 insertions, 20 deletions
diff --git a/addons/gut/gui/RunAtCursor.gd b/addons/gut/gui/RunAtCursor.gd
index 960414e..dc83c3e 100644
--- a/addons/gut/gui/RunAtCursor.gd
+++ b/addons/gut/gui/RunAtCursor.gd
@@ -14,7 +14,6 @@ onready var _ctrls = {
}
var _editors = null
-var _script_editor = null
var _cur_editor = null
var _last_line = -1
var _cur_script_path = null
@@ -29,7 +28,9 @@ func _ready():
_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()):
@@ -44,7 +45,6 @@ func _set_editor(which):
_update_buttons(_last_info)
-
func _update_buttons(info):
_ctrls.lbl_none.visible = _cur_script_path == null
_ctrls.btn_script.visible = _cur_script_path != null
@@ -58,16 +58,19 @@ func _update_buttons(info):
_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.
+
+ # 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()
@@ -75,20 +78,6 @@ func _on_cursor_changed(which):
_update_buttons(_last_info)
-func set_script_editor(value):
- _script_editor = value
- _editors = ScriptTextEditors.new(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 _on_BtnRunScript_pressed():
var info = _last_info.duplicate()
info.script = _cur_script_path.get_file()
@@ -110,6 +99,22 @@ func _on_BtnRunMethod_pressed():
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
@@ -121,10 +126,28 @@ func get_inner_button():
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
+
+
+