mirror of
https://github.com/lihop/godot-xterm.git
synced 2024-11-10 04:40:25 +01:00
0dd2378387
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.
29 lines
1.1 KiB
GDScript
29 lines
1.1 KiB
GDScript
# Copyright (c) 2021, Leroy Hopson (MIT License)
|
|
|
|
tool
|
|
extends Object
|
|
# Wrapper around libuv utility functions.
|
|
# GDNative does not currently support registering static functions so we fake it.
|
|
# Only the static functions of this class should be called.
|
|
|
|
const LibuvUtils := preload("./libuv_utils.gdns")
|
|
|
|
static func get_os_environ() -> Dictionary:
|
|
# While Godot has OS.get_environment(), I could see a way to get all environent
|
|
# variables, other than by OS.execute() which would require to much platform
|
|
# specific code. Easier to use libuv's utility function.
|
|
return LibuvUtils.new().get_os_environ()
|
|
|
|
static func get_cwd() -> String:
|
|
# Use uv_cwd() rather than Directory.get_current_dir() because the latter
|
|
# defaults to res:// even if starting godot from a different directory.
|
|
return LibuvUtils.new().get_cwd()
|
|
|
|
static func get_windows_build_number() -> int:
|
|
assert(OS.get_name() == "Windows", "This function is only supported on Windows.")
|
|
var release: String = LibuvUtils.new().get_os_release()
|
|
assert(false, "Not implemented.")
|
|
return 0
|
|
|
|
static func new():
|
|
assert(false, "Abstract sealed (i.e. static) class should not be instantiated.")
|