[pty] switch vim to use PTY FIDL
Change-Id: I7eac4128e8fdf44826da592c2364f5565250c5df
diff --git a/BUILD.gn b/BUILD.gn
index dbcb091..fc1dbcc 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -120,6 +120,9 @@
deps = [
"//zircon/public/lib/fdio",
]
+ public_deps = [
+ "//zircon/public/fidl/fuchsia-hardware-pty:fuchsia-hardware-pty_c",
+ ]
}
package("vim") {
diff --git a/src/os_fuchsia.c b/src/os_fuchsia.c
index 5a39020..07d73b0 100644
--- a/src/os_fuchsia.c
+++ b/src/os_fuchsia.c
@@ -10,7 +10,8 @@
#include "vim.h"
-#include <zircon/device/pty.h>
+#include <fuchsia/hardware/pty/c/fidl.h>
+#include <lib/fdio/unsafe.h>
/*
* Get the current window size in Rows and Columns.
@@ -18,13 +19,21 @@
int
mch_get_shellsize(void)
{
- pty_window_size_t wsz;
- ssize_t r = ioctl_pty_get_window_size(0, &wsz);
- if (r != sizeof(wsz)) {
+ if (!isatty(STDIN_FILENO)) {
return -1;
}
- Columns = wsz.width;
- Rows = wsz.height;
+
+ fdio_t* io = fdio_unsafe_fd_to_io(STDIN_FILENO);
+ fuchsia_hardware_pty_WindowSize wsz;
+ zx_status_t status;
+ zx_status_t call_status = fuchsia_hardware_pty_DeviceGetWindowSize(
+ fdio_unsafe_borrow_channel(io), &status, &wsz);
+ fdio_unsafe_release(io);
+ if (call_status != ZX_OK || status != ZX_OK) {
+ return -1;
+ }
+ Columns = wsz.height;
+ Rows = wsz.width;
return OK;
}