aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/os/pty_process_win.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/os/pty_process_win.c')
-rw-r--r--src/nvim/os/pty_process_win.c89
1 files changed, 46 insertions, 43 deletions
diff --git a/src/nvim/os/pty_process_win.c b/src/nvim/os/pty_process_win.c
index 2bf73d08e6..f78f3e66f5 100644
--- a/src/nvim/os/pty_process_win.c
+++ b/src/nvim/os/pty_process_win.c
@@ -4,15 +4,14 @@
#include <assert.h>
#include <stdbool.h>
#include <stdlib.h>
-
#include <winpty_constants.h>
-#include "nvim/os/os.h"
#include "nvim/ascii.h"
-#include "nvim/memory.h"
#include "nvim/mbyte.h" // for utf8_to_utf16, utf16_to_utf8
-#include "nvim/os/pty_process_win.h"
+#include "nvim/memory.h"
+#include "nvim/os/os.h"
#include "nvim/os/pty_conpty_win.h"
+#include "nvim/os/pty_process_win.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "os/pty_process_win.c.generated.h"
@@ -59,8 +58,8 @@ int pty_process_spawn(PtyProcess *ptyproc)
if (os_has_conpty_working()) {
if ((conpty_object =
- os_conpty_init(&in_name, &out_name,
- ptyproc->width, ptyproc->height)) != NULL) {
+ os_conpty_init(&in_name, &out_name,
+ ptyproc->width, ptyproc->height)) != NULL) {
ptyproc->type = kConpty;
}
}
@@ -94,20 +93,18 @@ int pty_process_spawn(PtyProcess *ptyproc)
if (!proc->in.closed) {
in_req = xmalloc(sizeof(uv_connect_t));
- uv_pipe_connect(
- in_req,
- &proc->in.uv.pipe,
- in_name,
- pty_process_connect_cb);
+ uv_pipe_connect(in_req,
+ &proc->in.uv.pipe,
+ in_name,
+ pty_process_connect_cb);
}
if (!proc->out.closed) {
out_req = xmalloc(sizeof(uv_connect_t));
- uv_pipe_connect(
- out_req,
- &proc->out.uv.pipe,
- out_name,
- pty_process_connect_cb);
+ uv_pipe_connect(out_req,
+ &proc->out.uv.pipe,
+ out_name,
+ pty_process_connect_cb);
}
if (proc->cwd != NULL) {
@@ -146,13 +143,12 @@ int pty_process_spawn(PtyProcess *ptyproc)
goto cleanup;
}
} else {
- spawncfg = winpty_spawn_config_new(
- WINPTY_SPAWN_FLAG_AUTO_SHUTDOWN,
- NULL, // Optional application name
- cmd_line,
- cwd,
- env,
- &err);
+ 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;
@@ -176,13 +172,12 @@ int pty_process_spawn(PtyProcess *ptyproc)
}
proc->pid = (int)GetProcessId(process_handle);
- if (!RegisterWaitForSingleObject(
- &ptyproc->finish_wait,
- process_handle,
- pty_process_finish1,
- ptyproc,
- INFINITE,
- WT_EXECUTEDEFAULT | WT_EXECUTEONLYONCE)) {
+ if (!RegisterWaitForSingleObject(&ptyproc->finish_wait,
+ process_handle,
+ pty_process_finish1,
+ ptyproc,
+ INFINITE,
+ WT_EXECUTEDEFAULT | WT_EXECUTEONLYONCE)) {
abort();
}
@@ -193,8 +188,8 @@ int pty_process_spawn(PtyProcess *ptyproc)
}
(ptyproc->type == kConpty) ?
- (void *)(ptyproc->object.conpty = conpty_object) :
- (void *)(ptyproc->object.winpty = winpty_object);
+ (void *)(ptyproc->object.conpty = conpty_object) :
+ (void *)(ptyproc->object.winpty = winpty_object);
ptyproc->process_handle = process_handle;
winpty_object = NULL;
conpty_object = NULL;
@@ -235,8 +230,7 @@ const char *pty_process_tty_name(PtyProcess *ptyproc)
return "?";
}
-void pty_process_resize(PtyProcess *ptyproc, uint16_t width,
- uint16_t height)
+void pty_process_resize(PtyProcess *ptyproc, uint16_t width, uint16_t height)
FUNC_ATTR_NONNULL_ALL
{
if (ptyproc->type == kConpty
@@ -454,15 +448,24 @@ int translate_winpty_error(int winpty_errno)
}
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;
+ 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;
}
}