mirror of
https://github.com/lihop/godot-xterm.git
synced 2025-07-01 03:25:31 +02:00
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:
parent
bfa561357e
commit
0dd2378387
36 changed files with 1268 additions and 442 deletions
64
addons/godot_xterm/native/src/pipe.h
Normal file
64
addons/godot_xterm/native/src/pipe.h
Normal file
|
@ -0,0 +1,64 @@
|
|||
// Copyright (c) 2021, Leroy Hopson (MIT License).
|
||||
|
||||
#ifndef GODOT_XTERM_PIPE_H
|
||||
#define GODOT_XTERM_PIPE_H
|
||||
|
||||
#include <Array.hpp>
|
||||
#include <FuncRef.hpp>
|
||||
#include <Godot.hpp>
|
||||
#include <Reference.hpp>
|
||||
#include <StreamPeer.hpp>
|
||||
#include <StreamPeerBuffer.hpp>
|
||||
#include <StreamPeerGDNative.hpp>
|
||||
#include <uv.h>
|
||||
|
||||
namespace godot {
|
||||
|
||||
class Pipe : public Reference {
|
||||
GODOT_CLASS(Pipe, Reference)
|
||||
|
||||
public:
|
||||
uv_pipe_t handle;
|
||||
|
||||
static void _register_methods();
|
||||
|
||||
enum Status {
|
||||
NONE,
|
||||
CONNECTING,
|
||||
CONNECTED,
|
||||
ERROR,
|
||||
};
|
||||
|
||||
int STATUS_NONE = Status::NONE;
|
||||
int STATUS_CONNECTING = Status::CONNECTING;
|
||||
int STATUS_CONNECTED = Status::CONNECTING;
|
||||
int STATUS_ERROR = Status::ERROR;
|
||||
|
||||
Pipe();
|
||||
~Pipe();
|
||||
|
||||
void _init();
|
||||
|
||||
godot_error open(int fd, bool ipc);
|
||||
int get_status();
|
||||
|
||||
godot_error write(String p_data);
|
||||
|
||||
void pause();
|
||||
void resume();
|
||||
|
||||
protected:
|
||||
const godot_net_stream_peer *interface;
|
||||
|
||||
public:
|
||||
Status status;
|
||||
|
||||
private:
|
||||
void _poll_connection();
|
||||
|
||||
static godot_error _translate_error(int err);
|
||||
};
|
||||
|
||||
} // namespace godot
|
||||
|
||||
#endif // GODOT_XTERM_PIPE_H
|
Loading…
Add table
Add a link
Reference in a new issue