aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/nvim/CMakeLists.txt3
-rw-r--r--src/nvim/api/vim.c2
-rw-r--r--src/nvim/os/pty_process_win.c157
-rw-r--r--src/nvim/os/pty_process_win.h15
4 files changed, 21 insertions, 156 deletions
diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt
index e65119ea1b..9f5cf70134 100755
--- a/src/nvim/CMakeLists.txt
+++ b/src/nvim/CMakeLists.txt
@@ -465,7 +465,6 @@ endif()
if(WIN32)
list(APPEND NVIM_LINK_LIBRARIES netapi32)
- list(APPEND NVIM_LINK_LIBRARIES ${WINPTY_LIBRARIES})
endif()
# Use "luv" as imported library, to work around CMake using "-lluv" for
@@ -552,8 +551,6 @@ if(WIN32)
diff.exe
tee.exe
win32yank.exe
- winpty-agent.exe
- winpty.dll
xxd.exe
# Dependencies for neovim-qt
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index 7a966777af..0f9a4a0e0d 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -1740,7 +1740,7 @@ void nvim_set_client_info(uint64_t channel_id, String name, Dictionary version,
/// - "pty" (optional) Name of pseudoterminal. On a POSIX system this
/// is a device path like "/dev/pts/1". If the name is unknown,
/// the key will still be present if a pty is used (e.g. for
-/// winpty on Windows).
+/// conpty on Windows).
/// - "buffer" (optional) Buffer with connected |terminal| instance.
/// - "client" (optional) Info about the peer (client on the other end of
/// the RPC channel), if provided by it via
diff --git a/src/nvim/os/pty_process_win.c b/src/nvim/os/pty_process_win.c
index 4fb9e30a96..5bbd22c610 100644
--- a/src/nvim/os/pty_process_win.c
+++ b/src/nvim/os/pty_process_win.c
@@ -4,7 +4,6 @@
#include <assert.h>
#include <stdbool.h>
#include <stdlib.h>
-#include <winpty_constants.h>
#include "nvim/ascii.h"
#include "nvim/mbyte.h" // for utf8_to_utf16, utf16_to_utf8
@@ -23,11 +22,7 @@ static void CALLBACK pty_process_finish1(void *context, BOOLEAN unused)
PtyProcess *ptyproc = (PtyProcess *)context;
Process *proc = (Process *)ptyproc;
- if (ptyproc->type == kConpty
- && ptyproc->object.conpty != NULL) {
- os_conpty_free(ptyproc->object.conpty);
- ptyproc->object.conpty = NULL;
- }
+ os_conpty_free(ptyproc->conpty);
uv_timer_init(&proc->loop->uv, &ptyproc->wait_eof_timer);
ptyproc->wait_eof_timer.data = (void *)ptyproc;
uv_timer_start(&ptyproc->wait_eof_timer, wait_eof_timer_cb, 200, 200);
@@ -39,10 +34,6 @@ int pty_process_spawn(PtyProcess *ptyproc)
{
Process *proc = (Process *)ptyproc;
int status = 0;
- winpty_error_ptr_t err = NULL;
- winpty_config_t *cfg = NULL;
- winpty_spawn_config_t *spawncfg = NULL;
- winpty_t *winpty_object = NULL;
conpty_t *conpty_object = NULL;
char *in_name = NULL;
char *out_name = NULL;
@@ -56,38 +47,11 @@ int pty_process_spawn(PtyProcess *ptyproc)
assert(proc->err.closed);
- if (os_has_conpty_working()) {
- if ((conpty_object =
- os_conpty_init(&in_name, &out_name, ptyproc->width, ptyproc->height)) != NULL) {
- ptyproc->type = kConpty;
- }
- }
-
- if (ptyproc->type == kWinpty) {
- cfg = winpty_config_new(WINPTY_FLAG_ALLOW_CURPROC_DESKTOP_CREATION, &err);
- if (cfg == NULL) {
- emsg = "winpty_config_new failed";
- goto cleanup;
- }
-
- winpty_config_set_initial_size(cfg, ptyproc->width, ptyproc->height);
- winpty_object = winpty_open(cfg, &err);
- if (winpty_object == NULL) {
- emsg = "winpty_open failed";
- goto cleanup;
- }
-
- status = utf16_to_utf8(winpty_conin_name(winpty_object), -1, &in_name);
- if (status != 0) {
- emsg = "utf16_to_utf8(winpty_conin_name) failed";
- goto cleanup;
- }
-
- status = utf16_to_utf8(winpty_conout_name(winpty_object), -1, &out_name);
- if (status != 0) {
- emsg = "utf16_to_utf8(winpty_conout_name) failed";
- goto cleanup;
- }
+ if (!os_has_conpty_working()
+ || (conpty_object =
+ os_conpty_init(&in_name, &out_name, ptyproc->width, ptyproc->height)) == NULL) {
+ status = UV_ENOSYS;
+ goto cleanup;
}
if (!proc->in.closed) {
@@ -130,44 +94,15 @@ int pty_process_spawn(PtyProcess *ptyproc)
goto cleanup;
}
- if (ptyproc->type == kConpty) {
- if (!os_conpty_spawn(conpty_object,
- &process_handle,
- NULL,
- cmd_line,
- cwd,
- env)) {
- emsg = "os_conpty_spawn failed";
- status = (int)GetLastError();
- goto cleanup;
- }
- } else {
- spawncfg = winpty_spawn_config_new(WINPTY_SPAWN_FLAG_AUTO_SHUTDOWN,
- NULL, // Optional application name
- cmd_line,
- cwd,
- env,
- &err);
- if (spawncfg == NULL) {
- emsg = "winpty_spawn_config_new failed";
- goto cleanup;
- }
-
- DWORD win_err = 0;
- if (!winpty_spawn(winpty_object,
- spawncfg,
- &process_handle,
- NULL, // Optional thread handle
- &win_err,
- &err)) {
- if (win_err) {
- status = (int)win_err;
- emsg = "failed to spawn process";
- } else {
- emsg = "winpty_spawn failed";
- }
- goto cleanup;
- }
+ if (!os_conpty_spawn(conpty_object,
+ &process_handle,
+ NULL,
+ cmd_line,
+ cwd,
+ env)) {
+ emsg = "os_conpty_spawn failed";
+ status = (int)GetLastError();
+ goto cleanup;
}
proc->pid = (int)GetProcessId(process_handle);
@@ -186,11 +121,8 @@ int pty_process_spawn(PtyProcess *ptyproc)
uv_run(&proc->loop->uv, UV_RUN_ONCE);
}
- (ptyproc->type == kConpty) ?
- (void *)(ptyproc->object.conpty = conpty_object) :
- (void *)(ptyproc->object.winpty = winpty_object);
+ ptyproc->conpty = conpty_object;
ptyproc->process_handle = process_handle;
- winpty_object = NULL;
conpty_object = NULL;
process_handle = NULL;
@@ -200,16 +132,7 @@ cleanup:
ELOG("pty_process_spawn(%s): %s: error code: %d",
proc->argv[0], emsg, status);
status = os_translate_sys_error(status);
- } else if (err != NULL) {
- status = (int)winpty_error_code(err);
- ELOG("pty_process_spawn(%s): %s: error code: %d",
- proc->argv[0], emsg, status);
- status = translate_winpty_error(status);
}
- winpty_error_free(err);
- winpty_config_free(cfg);
- winpty_spawn_config_free(spawncfg);
- winpty_free(winpty_object);
os_conpty_free(conpty_object);
xfree(in_name);
xfree(out_name);
@@ -232,12 +155,7 @@ const char *pty_process_tty_name(PtyProcess *ptyproc)
void pty_process_resize(PtyProcess *ptyproc, uint16_t width, uint16_t height)
FUNC_ATTR_NONNULL_ALL
{
- if (ptyproc->type == kConpty
- && ptyproc->object.conpty != NULL) {
- os_conpty_set_size(ptyproc->object.conpty, width, height);
- } else if (ptyproc->object.winpty != NULL) {
- winpty_set_size(ptyproc->object.winpty, width, height, NULL);
- }
+ os_conpty_set_size(ptyproc->conpty, width, height);
}
void pty_process_close(PtyProcess *ptyproc)
@@ -255,11 +173,6 @@ void pty_process_close(PtyProcess *ptyproc)
void pty_process_close_master(PtyProcess *ptyproc)
FUNC_ATTR_NONNULL_ALL
{
- if (ptyproc->type == kWinpty
- && ptyproc->object.winpty != NULL) {
- winpty_free(ptyproc->object.winpty);
- ptyproc->object.winpty = NULL;
- }
}
void pty_process_teardown(Loop *loop)
@@ -434,40 +347,6 @@ static void quote_cmd_arg(char *dest, size_t dest_remaining, const char *src)
}
}
-/// Translate winpty error code to libuv error.
-///
-/// @param[in] winpty_errno Winpty error code returned by winpty_error_code
-/// function.
-///
-/// @returns Error code of libuv error.
-int translate_winpty_error(int winpty_errno)
-{
- if (winpty_errno <= 0) {
- return winpty_errno; // If < 0 then it's already a libuv error.
- }
-
- switch (winpty_errno) {
- case WINPTY_ERROR_OUT_OF_MEMORY:
- return UV_ENOMEM;
- case WINPTY_ERROR_SPAWN_CREATE_PROCESS_FAILED:
- return UV_EAI_FAIL;
- case WINPTY_ERROR_LOST_CONNECTION:
- return UV_ENOTCONN;
- case WINPTY_ERROR_AGENT_EXE_MISSING:
- return UV_ENOENT;
- case WINPTY_ERROR_UNSPECIFIED:
- return UV_UNKNOWN;
- case WINPTY_ERROR_AGENT_DIED:
- return UV_ESRCH;
- case WINPTY_ERROR_AGENT_TIMEOUT:
- return UV_ETIMEDOUT;
- case WINPTY_ERROR_AGENT_CREATION_FAILED:
- return UV_EAI_FAIL;
- default:
- return UV_UNKNOWN;
- }
-}
-
typedef struct EnvNode {
wchar_t *str;
size_t len;
@@ -484,7 +363,7 @@ static int build_env_block(dict_T *denv, wchar_t **env_block)
{
const size_t denv_size = (size_t)tv_dict_len(denv);
size_t env_block_len = 0;
- int rc;
+ int rc = 0;
char **env = tv_dict_to_env(denv);
QUEUE *q;
diff --git a/src/nvim/os/pty_process_win.h b/src/nvim/os/pty_process_win.h
index d1737fd63a..ed7d765ac7 100644
--- a/src/nvim/os/pty_process_win.h
+++ b/src/nvim/os/pty_process_win.h
@@ -2,25 +2,15 @@
#define NVIM_OS_PTY_PROCESS_WIN_H
#include <uv.h>
-#include <winpty.h>
#include "nvim/event/process.h"
#include "nvim/lib/queue.h"
#include "nvim/os/pty_conpty_win.h"
-typedef enum {
- kWinpty,
- kConpty,
-} PtyType;
-
typedef struct pty_process {
Process process;
uint16_t width, height;
- union {
- winpty_t *winpty;
- conpty_t *conpty;
- } object;
- PtyType type;
+ conpty_t *conpty;
HANDLE finish_wait;
HANDLE process_handle;
uv_timer_t wait_eof_timer;
@@ -38,8 +28,7 @@ static inline PtyProcess pty_process_init(Loop *loop, void *data)
rv.process = process_init(loop, kProcessTypePty, data);
rv.width = 80;
rv.height = 24;
- rv.object.winpty = NULL;
- rv.type = kWinpty;
+ rv.conpty = NULL;
rv.finish_wait = NULL;
rv.process_handle = NULL;
return rv;