summaryrefslogtreecommitdiff
path: root/addons/gut/UserFileViewer.gd
diff options
context:
space:
mode:
authorSophia Pearson <codergal89@gmail.com>2022-10-03 22:22:50 +0200
committerSophia Pearson <codergal89@gmail.com>2022-10-04 22:18:18 +0200
commite127ad39e742396030352240d829bc903b1d4464 (patch)
tree10cc21d70bf13181aef7c8ad0344077ff63579a3 /addons/gut/UserFileViewer.gd
parentddbb045f6387a8ba23b1210b27a745516a387a52 (diff)
downloadtexty-e127ad39e742396030352240d829bc903b1d4464.tar.xz
texty-e127ad39e742396030352240d829bc903b1d4464.zip
godot: inital Godot 4 migration
Diffstat (limited to 'addons/gut/UserFileViewer.gd')
-rw-r--r--addons/gut/UserFileViewer.gd55
1 files changed, 0 insertions, 55 deletions
diff --git a/addons/gut/UserFileViewer.gd b/addons/gut/UserFileViewer.gd
deleted file mode 100644
index 9713a94..0000000
--- a/addons/gut/UserFileViewer.gd
+++ /dev/null
@@ -1,55 +0,0 @@
-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