2020-05-10 00:07:31 +07:00
|
|
|
tool
|
|
|
|
extends EditorPlugin
|
|
|
|
|
2021-07-03 00:27:34 +07:00
|
|
|
var pty_supported := OS.get_name() in ["X11", "Server", "OSX"]
|
2020-09-22 15:31:46 +07:00
|
|
|
var asciicast_import_plugin
|
2021-07-18 23:11:31 +07:00
|
|
|
var xrdb_import_plugin
|
2021-07-11 22:32:13 +07:00
|
|
|
var terminal_panel: Control
|
2020-09-22 15:31:46 +07:00
|
|
|
|
|
|
|
|
2020-05-10 00:07:31 +07:00
|
|
|
func _enter_tree():
|
2021-07-15 21:30:09 +07:00
|
|
|
asciicast_import_plugin = preload("./import_plugins/asciicast_import_plugin.gd").new()
|
2020-09-22 15:31:46 +07:00
|
|
|
add_import_plugin(asciicast_import_plugin)
|
2021-05-26 10:39:48 +07:00
|
|
|
|
2021-07-18 23:11:31 +07:00
|
|
|
xrdb_import_plugin = preload("./import_plugins/xrdb_import_plugin.gd").new()
|
|
|
|
add_import_plugin(xrdb_import_plugin)
|
|
|
|
|
2021-07-15 21:30:09 +07:00
|
|
|
var asciicast_script = preload("./resources/asciicast.gd")
|
2020-09-22 15:31:46 +07:00
|
|
|
add_custom_type("Asciicast", "Animation", asciicast_script, null)
|
2021-05-26 10:39:48 +07:00
|
|
|
|
2021-07-26 00:31:23 +07:00
|
|
|
var terminal_script = preload("./terminal.gd")
|
2022-08-27 10:31:25 +12:00
|
|
|
var terminal_icon = load(
|
|
|
|
"%s/nodes/terminal/terminal_icon.svg" % get_script().resource_path.get_base_dir()
|
|
|
|
)
|
2020-09-17 15:14:04 +07:00
|
|
|
add_custom_type("Terminal", "Control", terminal_script, terminal_icon)
|
2021-05-26 10:39:48 +07:00
|
|
|
|
2021-07-03 00:27:34 +07:00
|
|
|
if pty_supported:
|
2021-07-15 21:30:09 +07:00
|
|
|
var base_dir = get_script().resource_path.get_base_dir()
|
|
|
|
var pty_icon = load("%s/nodes/pty/pty_icon.svg" % base_dir)
|
2021-07-03 00:27:34 +07:00
|
|
|
var pty_script
|
|
|
|
match OS.get_name():
|
|
|
|
"X11", "Server", "OSX":
|
2022-06-29 22:58:48 +07:00
|
|
|
pty_script = load("%s/pty.gd" % base_dir)
|
2021-07-03 00:27:34 +07:00
|
|
|
add_custom_type("PTY", "Node", pty_script, pty_icon)
|
2021-07-11 22:32:13 +07:00
|
|
|
terminal_panel = preload("./editor_plugins/terminal/terminal_panel.tscn").instance()
|
2021-07-12 23:11:28 +07:00
|
|
|
terminal_panel.editor_plugin = self
|
2021-07-11 22:32:13 +07:00
|
|
|
terminal_panel.editor_interface = get_editor_interface()
|
|
|
|
add_control_to_bottom_panel(terminal_panel, "Terminal")
|
2020-05-10 00:07:31 +07:00
|
|
|
|
|
|
|
|
|
|
|
func _exit_tree():
|
2020-09-22 15:31:46 +07:00
|
|
|
remove_import_plugin(asciicast_import_plugin)
|
|
|
|
asciicast_import_plugin = null
|
2021-05-26 10:39:48 +07:00
|
|
|
|
2021-07-18 23:11:31 +07:00
|
|
|
remove_import_plugin(xrdb_import_plugin)
|
|
|
|
xrdb_import_plugin = null
|
|
|
|
|
2020-09-22 15:31:46 +07:00
|
|
|
remove_custom_type("Asciicast")
|
2020-05-10 00:07:31 +07:00
|
|
|
remove_custom_type("Terminal")
|
2021-07-03 00:27:34 +07:00
|
|
|
|
|
|
|
if pty_supported:
|
|
|
|
remove_custom_type("PTY")
|
2021-07-11 22:32:13 +07:00
|
|
|
remove_control_from_bottom_panel(terminal_panel)
|
|
|
|
terminal_panel.free()
|