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,9 @@
#include "terminal.h"
#if defined(__unix__) /* Linux and macOS */ && !defined(__EMSCRIPTEN__)
#include "pseudoterminal.h"
#if !defined(__EMSCRIPTEN__) && !defined(__WIN32)
#include "libuv_utils.h"
#include "node_pty/unix/pty.h"
#include "pipe.h"
#endif
extern "C" void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *o) {
@ -14,9 +17,10 @@ godot_gdnative_terminate(godot_gdnative_terminate_options *o) {
extern "C" void GDN_EXPORT godot_nativescript_init(void *handle) {
godot::Godot::nativescript_init(handle);
godot::register_tool_class<godot::Terminal>();
#if defined(__unix__) && !defined(__EMSCRIPTEN__)
godot::register_class<godot::Pseudoterminal>();
#if !defined(__EMSCRIPTEN__) && !defined(__WIN32)
godot::register_tool_class<godot::Pipe>();
godot::register_tool_class<godot::LibuvUtils>();
godot::register_tool_class<godot::PTYUnix>();
#endif
}