diff options
Diffstat (limited to 'src/nvim/os/pty_conpty_win.c')
-rw-r--r-- | src/nvim/os/pty_conpty_win.c | 108 |
1 files changed, 50 insertions, 58 deletions
diff --git a/src/nvim/os/pty_conpty_win.c b/src/nvim/os/pty_conpty_win.c index 775e303f84..0625d6994e 100644 --- a/src/nvim/os/pty_conpty_win.c +++ b/src/nvim/os/pty_conpty_win.c @@ -3,9 +3,9 @@ #include <uv.h> -#include "nvim/vim.h" #include "nvim/os/os.h" #include "nvim/os/pty_conpty_win.h" +#include "nvim/vim.h" #ifndef EXTENDED_STARTUPINFO_PRESENT # define EXTENDED_STARTUPINFO_PRESENT 0x00080000 @@ -54,8 +54,7 @@ TriState os_dyn_conpty_init(void) return kTrue; } -conpty_t *os_conpty_init(char **in_name, char **out_name, - uint16_t width, uint16_t height) +conpty_t *os_conpty_init(char **in_name, char **out_name, uint16_t width, uint16_t height) { static int count = 0; conpty_t *conpty_object = xcalloc(1, sizeof(*conpty_object)); @@ -65,36 +64,34 @@ conpty_t *os_conpty_init(char **in_name, char **out_name, char buf[MAXPATHL]; SECURITY_ATTRIBUTES sa = { 0 }; const DWORD mode = PIPE_ACCESS_INBOUND - | PIPE_ACCESS_OUTBOUND | FILE_FLAG_FIRST_PIPE_INSTANCE; + | PIPE_ACCESS_OUTBOUND | FILE_FLAG_FIRST_PIPE_INSTANCE; sa.nLength = sizeof(sa); snprintf(buf, sizeof(buf), "\\\\.\\pipe\\nvim-term-in-%d-%d", os_get_pid(), count); *in_name = xstrdup(buf); - if ((in_read = CreateNamedPipeA( - *in_name, - mode, - PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, - 1, - 0, - 0, - 30000, - &sa)) == INVALID_HANDLE_VALUE) { + if ((in_read = CreateNamedPipeA(*in_name, + mode, + PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, + 1, + 0, + 0, + 30000, + &sa)) == INVALID_HANDLE_VALUE) { emsg = "create input pipe failed"; goto failed; } snprintf(buf, sizeof(buf), "\\\\.\\pipe\\nvim-term-out-%d-%d", os_get_pid(), count); *out_name = xstrdup(buf); - if ((out_write = CreateNamedPipeA( - *out_name, - mode, - PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, - 1, - 0, - 0, - 30000, - &sa)) == INVALID_HANDLE_VALUE) { + if ((out_write = CreateNamedPipeA(*out_name, + mode, + PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, + 1, + 0, + 0, + 30000, + &sa)) == INVALID_HANDLE_VALUE) { emsg = "create output pipe failed"; goto failed; } @@ -113,22 +110,20 @@ conpty_t *os_conpty_init(char **in_name, char **out_name, InitializeProcThreadAttributeList(NULL, 1, 0, & bytes_required); conpty_object->si_ex.lpAttributeList = (PPROC_THREAD_ATTRIBUTE_LIST)xmalloc(bytes_required); - if (!InitializeProcThreadAttributeList( - conpty_object->si_ex.lpAttributeList, - 1, - 0, - &bytes_required)) { + if (!InitializeProcThreadAttributeList(conpty_object->si_ex.lpAttributeList, + 1, + 0, + &bytes_required)) { emsg = "InitializeProcThreadAttributeList failed"; goto failed; } - if (!UpdateProcThreadAttribute( - conpty_object->si_ex.lpAttributeList, - 0, - PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE, - conpty_object->pty, - sizeof(conpty_object->pty), - NULL, - NULL)) { + if (!UpdateProcThreadAttribute(conpty_object->si_ex.lpAttributeList, + 0, + PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE, + conpty_object->pty, + sizeof(conpty_object->pty), + NULL, + NULL)) { emsg = "UpdateProcThreadAttribute failed"; goto failed; } @@ -150,38 +145,35 @@ finished: return conpty_object; } -bool os_conpty_spawn(conpty_t *conpty_object, HANDLE *process_handle, - wchar_t *name, wchar_t *cmd_line, wchar_t *cwd, - wchar_t *env) +bool os_conpty_spawn(conpty_t *conpty_object, HANDLE *process_handle, wchar_t *name, + wchar_t *cmd_line, wchar_t *cwd, wchar_t *env) { PROCESS_INFORMATION pi = { 0 }; - if (!CreateProcessW( - name, - cmd_line, - NULL, - NULL, - false, - EXTENDED_STARTUPINFO_PRESENT | CREATE_UNICODE_ENVIRONMENT, - env, - cwd, - &conpty_object->si_ex.StartupInfo, - &pi)) { + if (!CreateProcessW(name, + cmd_line, + NULL, + NULL, + false, + EXTENDED_STARTUPINFO_PRESENT | CREATE_UNICODE_ENVIRONMENT, + env, + cwd, + &conpty_object->si_ex.StartupInfo, + &pi)) { return false; } *process_handle = pi.hProcess; return true; } -void os_conpty_set_size(conpty_t *conpty_object, - uint16_t width, uint16_t height) +void os_conpty_set_size(conpty_t *conpty_object, uint16_t width, uint16_t height) { - assert(width <= SHRT_MAX); - assert(height <= SHRT_MAX); - COORD size = { (int16_t)width, (int16_t)height }; - if (pResizePseudoConsole(conpty_object->pty, size) != S_OK) { - ELOG("ResizePseudoConsoel failed: error code: %d", - os_translate_sys_error((int)GetLastError())); - } + assert(width <= SHRT_MAX); + assert(height <= SHRT_MAX); + COORD size = { (int16_t)width, (int16_t)height }; + if (pResizePseudoConsole(conpty_object->pty, size) != S_OK) { + ELOG("ResizePseudoConsoel failed: error code: %d", + os_translate_sys_error((int)GetLastError())); + } } void os_conpty_free(conpty_t *conpty_object) |