mirror of
https://github.com/lihop/godot-xterm.git
synced 2025-05-03 12:04:24 +02:00
Add GUT (CLI only) and remove gd-plug
Commit GUT directly to the git repo and remove gd-plug as it is no longer required to install GUT. Modify GUT to be used by command-line only. For example: ``` cp test/.gutconfig.ci.json .gutconfig.json godot --no-window -s addons/gut/gut_cmdln.gd ```
This commit is contained in:
parent
b14ea64492
commit
d784b53e25
52 changed files with 11394 additions and 1174 deletions
66
addons/gut/UserFileViewer.gd
Normal file
66
addons/gut/UserFileViewer.gd
Normal file
|
@ -0,0 +1,66 @@
|
|||
extends WindowDialog
|
||||
|
||||
onready var rtl = $TextDisplay/RichTextLabel
|
||||
var _has_opened_file = false
|
||||
|
||||
|
||||
func _get_file_as_text(path):
|
||||
var to_return = null
|
||||
var f = File.new()
|
||||
var result = f.open(path, f.READ)
|
||||
if result == OK:
|
||||
to_return = f.get_as_text()
|
||||
f.close()
|
||||
else:
|
||||
to_return = str("ERROR: Could not open file. Error code ", result)
|
||||
return to_return
|
||||
|
||||
|
||||
func _ready():
|
||||
rtl.clear()
|
||||
|
||||
|
||||
func _on_OpenFile_pressed():
|
||||
$FileDialog.popup_centered()
|
||||
|
||||
|
||||
func _on_FileDialog_file_selected(path):
|
||||
show_file(path)
|
||||
|
||||
|
||||
func _on_Close_pressed():
|
||||
self.hide()
|
||||
|
||||
|
||||
func show_file(path):
|
||||
var text = _get_file_as_text(path)
|
||||
if text == "":
|
||||
text = "<Empty File>"
|
||||
rtl.set_text(text)
|
||||
self.window_title = path
|
||||
|
||||
|
||||
func show_open():
|
||||
self.popup_centered()
|
||||
$FileDialog.popup_centered()
|
||||
|
||||
|
||||
func _on_FileDialog_popup_hide():
|
||||
if rtl.text.length() == 0:
|
||||
self.hide()
|
||||
|
||||
|
||||
func get_rich_text_label():
|
||||
return $TextDisplay/RichTextLabel
|
||||
|
||||
|
||||
func _on_Home_pressed():
|
||||
rtl.scroll_to_line(0)
|
||||
|
||||
|
||||
func _on_End_pressed():
|
||||
rtl.scroll_to_line(rtl.get_line_count() - 1)
|
||||
|
||||
|
||||
func _on_Copy_pressed():
|
||||
OS.clipboard = rtl.text
|
Loading…
Add table
Add a link
Reference in a new issue