mirror of
https://github.com/lihop/godot-xterm.git
synced 2025-07-04 04:55:30 +02:00
feat(pty): further pty development
This commit is contained in:
parent
52a259b019
commit
c36500615d
4 changed files with 332 additions and 110 deletions
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include <godot_cpp/classes/node.hpp>
|
||||
#include <godot_cpp/classes/os.hpp>
|
||||
#include <uv.h>
|
||||
|
||||
namespace godot
|
||||
{
|
||||
|
@ -31,9 +32,19 @@ namespace godot
|
|||
SIGNAL_SIGTERM = 15,
|
||||
};
|
||||
|
||||
enum Status {
|
||||
STATUS_NONE,
|
||||
STATUS_CONNECTING,
|
||||
STATUS_CONNECTED,
|
||||
STATUS_PAUSED,
|
||||
STATUS_ERROR,
|
||||
};
|
||||
|
||||
PTY();
|
||||
~PTY();
|
||||
|
||||
Status status = STATUS_NONE;
|
||||
|
||||
int get_cols() const;
|
||||
int get_rows() const;
|
||||
|
||||
|
@ -43,19 +54,21 @@ namespace godot
|
|||
bool get_use_os_env() const;
|
||||
void set_use_os_env(const bool value);
|
||||
|
||||
String get_pts() const;
|
||||
|
||||
Error fork(const String &file = "", const PackedStringArray &args = PackedStringArray(), const String &cwd = ".", const int cols = 80, const int rows = 24);
|
||||
void kill(const int signum = Signal::SIGNAL_SIGHUP);
|
||||
Error open(const int cols = 80, const int rows = 24) const;
|
||||
Error open(const int cols = 80, const int rows = 24);
|
||||
void resize(const int cols, const int rows) const;
|
||||
void resizev(const Vector2i &size) const { resize(size.x, size.y); };
|
||||
void write(const Variant &data) const;
|
||||
|
||||
void _process(double delta) override;
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
OS *os;
|
||||
|
||||
int pid = -1;
|
||||
int fd = -1;
|
||||
|
||||
|
@ -65,9 +78,19 @@ namespace godot
|
|||
Dictionary env = Dictionary();
|
||||
bool use_os_env = true;
|
||||
|
||||
String pts = "";
|
||||
|
||||
String _get_fork_file(const String &file) const;
|
||||
Dictionary _get_fork_env() const;
|
||||
void _on_exit(int exit_code, int exit_signal);
|
||||
void _close();
|
||||
|
||||
#if defined(__linux__) || defined(__APPLE__)
|
||||
uv_pipe_t pipe;
|
||||
Error _pipe_open(const int fd);
|
||||
#endif
|
||||
|
||||
static Error uv_err_to_godot_err(const int uv_err);
|
||||
};
|
||||
} // namespace godot
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue