mirror of
https://github.com/lihop/godot-xterm.git
synced 2025-05-08 21:25:31 +02:00
Enable compiling Pipe and LibuvUtils on Windows
Currently only works when building with debug target. On GitHub actions target release results in linking errors. So disable PTY for release builds. Part of #25.
This commit is contained in:
parent
88e5320a83
commit
84243cd824
8 changed files with 145 additions and 101 deletions
|
@ -2,6 +2,7 @@
|
|||
* Copyright (c) 2013-2015, Christopher Jeffrey, Peter Sunde (MIT License)
|
||||
* Copyright (c) 2016, Daniel Imms (MIT License).
|
||||
* Copyright (c) 2018, Microsoft Corporation (MIT License).
|
||||
* Copyright (c) 2021, Leroy Hopson (MIT License).
|
||||
*
|
||||
* pty.cc:
|
||||
* This file is responsible for starting processes
|
||||
|
@ -379,18 +380,9 @@ static NAN_METHOD(PtyConnect) {
|
|||
info.GetReturnValue().Set(marshal);
|
||||
}
|
||||
|
||||
static NAN_METHOD(PtyResize) {
|
||||
Nan::HandleScope scope;
|
||||
|
||||
if (info.Length() != 3 || !info[0]->IsNumber() || !info[1]->IsNumber() ||
|
||||
!info[2]->IsNumber()) {
|
||||
Nan::ThrowError("Usage: pty.resize(id, cols, rows)");
|
||||
return;
|
||||
}
|
||||
|
||||
int id = info[0]->Int32Value(Nan::GetCurrentContext()).FromJust();
|
||||
SHORT cols = info[1]->Uint32Value(Nan::GetCurrentContext()).FromJust();
|
||||
SHORT rows = info[2]->Uint32Value(Nan::GetCurrentContext()).FromJust();
|
||||
void ConPTY::resize(int id, int cols, int rows) {
|
||||
// SHORT cols = info[1]->Uint32Value(Nan::GetCurrentContext()).FromJust();
|
||||
// SHORT rows = info[2]->Uint32Value(Nan::GetCurrentContext()).FromJust();
|
||||
|
||||
const pty_baton *handle = get_pty_baton(id);
|
||||
|
||||
|
@ -405,20 +397,9 @@ static NAN_METHOD(PtyResize) {
|
|||
pfnResizePseudoConsole(handle->hpc, size);
|
||||
}
|
||||
}
|
||||
|
||||
return info.GetReturnValue().SetUndefined();
|
||||
}
|
||||
|
||||
static NAN_METHOD(PtyKill) {
|
||||
Nan::HandleScope scope;
|
||||
|
||||
if (info.Length() != 1 || !info[0]->IsNumber()) {
|
||||
Nan::ThrowError("Usage: pty.kill(id)");
|
||||
return;
|
||||
}
|
||||
|
||||
int id = info[0]->Int32Value(Nan::GetCurrentContext()).FromJust();
|
||||
|
||||
void ConPTY::kill(int id) {
|
||||
const pty_baton *handle = get_pty_baton(id);
|
||||
|
||||
HANDLE hLibrary = LoadLibraryExW(L"kernel32.dll", 0, 0);
|
||||
|
@ -441,12 +422,12 @@ static NAN_METHOD(PtyKill) {
|
|||
* Init
|
||||
*/
|
||||
|
||||
extern "C" void init(v8::Local<v8::Object> target) {
|
||||
Nan::HandleScope scope;
|
||||
Nan::SetMethod(target, "startProcess", PtyStartProcess);
|
||||
Nan::SetMethod(target, "connect", PtyConnect);
|
||||
Nan::SetMethod(target, "resize", PtyResize);
|
||||
Nan::SetMethod(target, "kill", PtyKill);
|
||||
void ConPTY::_register_methods() {
|
||||
register_method("_init", &ConPTY::_init);
|
||||
register_method("start_process", &ConPTY::start_process);
|
||||
register_method("connect_to_named_pipe", &ConPTY::connect_to_named_pipe);
|
||||
register_method("resize", &ConPTY::resize);
|
||||
register_method("kill", &ConPTY::kill);
|
||||
};
|
||||
|
||||
NODE_MODULE(pty, init);
|
||||
void ConPTY::_init() {}
|
||||
|
|
33
addons/godot_xterm/native/src/node_pty/win/conpty.h
Normal file
33
addons/godot_xterm/native/src/node_pty/win/conpty.h
Normal file
|
@ -0,0 +1,33 @@
|
|||
// Copyright (c) 2021, Leroy Hopson (MIT License).
|
||||
|
||||
#ifndef GODOT_XTERM_CONPTY_H
|
||||
#define GODOT_XTERM_CONPTY_H
|
||||
|
||||
#include <FuncRef.hpp>
|
||||
#include <Godot.hpp>
|
||||
|
||||
namespace godot {
|
||||
|
||||
class ConPTY : public Reference {
|
||||
GODOT_CLASS(ConPTY, Reference)
|
||||
|
||||
public:
|
||||
// Array fork(String file,
|
||||
// int _ignored, /* FIXME: For some reason Pipe throws
|
||||
// ENOTSOCK in read callback if args (or another
|
||||
// non-empty, non-zero) value is in this position. */
|
||||
// PoolStringArray args, PoolStringArray env, String cwd, int
|
||||
// cols, int rows, int uid, int gid, bool utf8, Ref<FuncRef>
|
||||
// on_exit);
|
||||
// Array open(int cols, int rows);
|
||||
void resize(int id, int cols, int rows);
|
||||
void kill(int id);
|
||||
// String process(int fd, String tty);
|
||||
|
||||
void _init();
|
||||
static void _register_methods();
|
||||
};
|
||||
|
||||
} // namespace godot
|
||||
|
||||
#endif // GODOT_XTERM_CONPTY_H
|
Loading…
Add table
Add a link
Reference in a new issue