Add new PTY node (replaces Pseudoterminal node)

Uses fork of node-pty native code for forking pseudoterminals.
Uses libuv pipe handle to communicate with the child process.

- Paves the way for cross-platform (Linux, macOS and Windows) support.
- Renames Pseudoterminal to PTY (which is much easier to type and spell :D).
- Better performance than the old Pseudoterminal node. Especially when
  streaming large amounts of data such as running the `yes` command.
- Allows setting custom file, args, initial window size, cwd, env vars
  (including important ones such as TERM and COLORTERM) and uid/gid
  on Linux and macOS.
- Returns process exit code and terminating signal.
This commit is contained in:
Leroy Hopson 2021-07-03 00:27:34 +07:00 committed by Leroy Hopson
parent bfa561357e
commit 0dd2378387
36 changed files with 1268 additions and 442 deletions

View file

@ -1,6 +1,7 @@
tool
extends EditorPlugin
var pty_supported := OS.get_name() in ["X11", "Server", "OSX"]
var asciicast_import_plugin
@ -15,9 +16,13 @@ func _enter_tree():
var terminal_icon = preload("res://addons/godot_xterm/nodes/terminal/terminal_icon.svg")
add_custom_type("Terminal", "Control", terminal_script, terminal_icon)
var pseudoterminal_script = preload("res://addons/godot_xterm/nodes/pseudoterminal/pseudoterminal.gdns")
var pseudoterminal_icon = preload("res://addons/godot_xterm/nodes/pseudoterminal/pseudoterminal_icon.svg")
add_custom_type("Pseudoterminal", "Node", pseudoterminal_script, pseudoterminal_icon)
if pty_supported:
var pty_icon = load("res://addons/godot_xterm/nodes/pty/pty_icon.svg")
var pty_script
match OS.get_name():
"X11", "Server", "OSX":
pty_script = load("res://addons/godot_xterm/nodes/pty/unix/pty_unix.gd")
add_custom_type("PTY", "Node", pty_script, pty_icon)
func _exit_tree():
@ -26,4 +31,6 @@ func _exit_tree():
remove_custom_type("Asciicast")
remove_custom_type("Terminal")
remove_custom_type("Psuedoterminal")
if pty_supported:
remove_custom_type("PTY")