aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRui Abreu Ferreira <equalsraf@users.noreply.github.com>2016-06-05 01:02:56 +0100
committerJustin M. Keyes <justinkz@gmail.com>2016-06-04 20:02:56 -0400
commit6ed9d47a6e0a28d163e1cf78e521e1282b725a87 (patch)
tree0f36da37e1673184ef672edf869978f6d557daea
parent02e6914a938fcca98f9062d502accb4d68a65d6e (diff)
downloadrneovim-6ed9d47a6e0a28d163e1cf78e521e1282b725a87.tar.gz
rneovim-6ed9d47a6e0a28d163e1cf78e521e1282b725a87.tar.bz2
rneovim-6ed9d47a6e0a28d163e1cf78e521e1282b725a87.zip
pty_process: split into plat-specific files (#3976)
-rw-r--r--src/nvim/CMakeLists.txt3
-rw-r--r--src/nvim/eval.c2
-rw-r--r--src/nvim/event/process.c2
-rw-r--r--src/nvim/os/pty_process.h9
-rw-r--r--src/nvim/os/pty_process_unix.c (renamed from src/nvim/event/pty_process.c)11
-rw-r--r--src/nvim/os/pty_process_unix.h (renamed from src/nvim/event/pty_process.h)9
-rw-r--r--src/nvim/os/pty_process_win.h28
7 files changed, 52 insertions, 12 deletions
diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt
index 5a3db74903..4aaae5172f 100644
--- a/src/nvim/CMakeLists.txt
+++ b/src/nvim/CMakeLists.txt
@@ -78,6 +78,9 @@ foreach(sfile ${NEOVIM_SOURCES})
if(${f} MATCHES "^(regexp_nfa.c)$")
list(APPEND to_remove ${sfile})
endif()
+ if(WIN32 AND ${f} MATCHES "^(pty_process_unix.c)$")
+ list(APPEND to_remove ${sfile})
+ endif()
endforeach()
list(REMOVE_ITEM NEOVIM_SOURCES ${to_remove})
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 84c96752c7..3cd53b841d 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -77,7 +77,7 @@
#include "nvim/eval/decode.h"
#include "nvim/os/os.h"
#include "nvim/event/libuv_process.h"
-#include "nvim/event/pty_process.h"
+#include "nvim/os/pty_process.h"
#include "nvim/event/rstream.h"
#include "nvim/event/wstream.h"
#include "nvim/event/time.h"
diff --git a/src/nvim/event/process.c b/src/nvim/event/process.c
index 9bb62891c7..0a4cbe724e 100644
--- a/src/nvim/event/process.c
+++ b/src/nvim/event/process.c
@@ -9,7 +9,7 @@
#include "nvim/event/wstream.h"
#include "nvim/event/process.h"
#include "nvim/event/libuv_process.h"
-#include "nvim/event/pty_process.h"
+#include "nvim/os/pty_process.h"
#include "nvim/globals.h"
#include "nvim/log.h"
diff --git a/src/nvim/os/pty_process.h b/src/nvim/os/pty_process.h
new file mode 100644
index 0000000000..94923499ca
--- /dev/null
+++ b/src/nvim/os/pty_process.h
@@ -0,0 +1,9 @@
+#ifndef NVIM_OS_PTY_PROCESS_H
+#define NVIM_OS_PTY_PROCESS_H
+
+#ifdef WIN32
+# include "nvim/os/pty_process_win.h"
+#else
+# include "nvim/os/pty_process_unix.h"
+#endif
+#endif // NVIM_OS_PTY_PROCESS_H
diff --git a/src/nvim/event/pty_process.c b/src/nvim/os/pty_process_unix.c
index 8eef72f12f..d0a38e663b 100644
--- a/src/nvim/event/pty_process.c
+++ b/src/nvim/os/pty_process_unix.c
@@ -26,11 +26,11 @@
#include "nvim/event/rstream.h"
#include "nvim/event/wstream.h"
#include "nvim/event/process.h"
-#include "nvim/event/pty_process.h"
+#include "nvim/os/pty_process_unix.h"
#include "nvim/log.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
-# include "event/pty_process.c.generated.h"
+# include "os/pty_process_unix.c.generated.h"
#endif
bool pty_process_spawn(PtyProcess *ptyproc)
@@ -44,7 +44,7 @@ bool pty_process_spawn(PtyProcess *ptyproc)
Process *proc = (Process *)ptyproc;
assert(!proc->err);
uv_signal_start(&proc->loop->children_watcher, chld_handler, SIGCHLD);
- ptyproc->winsize = (struct winsize){ptyproc->height, ptyproc->width, 0, 0};
+ ptyproc->winsize = (struct winsize){ ptyproc->height, ptyproc->width, 0, 0 };
uv_disable_stdio_inheritance();
int master;
int pid = forkpty(&master, NULL, &termios, &ptyproc->winsize);
@@ -86,11 +86,10 @@ error:
return false;
}
-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
{
- ptyproc->winsize = (struct winsize){height, width, 0, 0};
+ ptyproc->winsize = (struct winsize){ height, width, 0, 0 };
ioctl(ptyproc->tty_fd, TIOCSWINSZ, &ptyproc->winsize);
}
diff --git a/src/nvim/event/pty_process.h b/src/nvim/os/pty_process_unix.h
index 446d7fd3c8..f7c57b3839 100644
--- a/src/nvim/event/pty_process.h
+++ b/src/nvim/os/pty_process_unix.h
@@ -1,5 +1,5 @@
-#ifndef NVIM_EVENT_PTY_PROCESS_H
-#define NVIM_EVENT_PTY_PROCESS_H
+#ifndef NVIM_OS_PTY_PROCESS_UNIX_H
+#define NVIM_OS_PTY_PROCESS_UNIX_H
#include <sys/ioctl.h>
@@ -25,6 +25,7 @@ static inline PtyProcess pty_process_init(Loop *loop, void *data)
}
#ifdef INCLUDE_GENERATED_DECLARATIONS
-# include "event/pty_process.h.generated.h"
+# include "os/pty_process_unix.h.generated.h"
#endif
-#endif // NVIM_EVENT_PTY_PROCESS_H
+
+#endif // NVIM_OS_PTY_PROCESS_UNIX_H
diff --git a/src/nvim/os/pty_process_win.h b/src/nvim/os/pty_process_win.h
new file mode 100644
index 0000000000..20cc589925
--- /dev/null
+++ b/src/nvim/os/pty_process_win.h
@@ -0,0 +1,28 @@
+#ifndef NVIM_OS_PTY_PROCESS_WIN_H
+#define NVIM_OS_PTY_PROCESS_WIN_H
+
+#include "nvim/event/libuv_process.h"
+
+typedef struct pty_process {
+ Process process;
+ char *term_name;
+ uint16_t width, height;
+} PtyProcess;
+
+#define pty_process_spawn(job) libuv_process_spawn((LibuvProcess *)job)
+#define pty_process_close(job) libuv_process_close((LibuvProcess *)job)
+#define pty_process_close_master(job) libuv_process_close((LibuvProcess *)job)
+#define pty_process_resize(job, width, height)
+#define pty_process_teardown(loop)
+
+static inline PtyProcess pty_process_init(Loop *loop, void *data)
+{
+ PtyProcess rv;
+ rv.process = process_init(loop, kProcessTypePty, data);
+ rv.term_name = NULL;
+ rv.width = 80;
+ rv.height = 24;
+ return rv;
+}
+
+#endif // NVIM_OS_PTY_PROCESS_WIN_H