[fuchsia] Migrate to ioctl for window size

Previously, we used the underly FIDL protocol. Now that we support the
standard POSIX ioctl, we can use that API and break the dependency on
the C bindings for fuchsia.hardware.pty.

Test: Ran "vim" from the Fuchsia virtcon
Bug: 63710
Change-Id: I62884dc2298681eeac69a22fc6fef6fcc0c561cf
Reviewed-on: https://fuchsia-review.googlesource.com/c/third_party/vim/+/447441
Commit-Queue: Adam Barth <abarth@google.com>
Reviewed-by: Steve Austin <steveaustin@google.com>
diff --git a/BUILD.gn b/BUILD.gn
index 5ae6488..160f624 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -120,7 +120,6 @@
   configs += [ ":vim_config" ]
 
   deps = [ "//sdk/lib/fdio" ]
-  public_deps = [ "//sdk/fidl/fuchsia.hardware.pty:fuchsia.hardware.pty_c" ]
 }
 
 package("vim") {
diff --git a/src/os_fuchsia.c b/src/os_fuchsia.c
index 07d73b0..a5a0c6d 100644
--- a/src/os_fuchsia.c
+++ b/src/os_fuchsia.c
@@ -10,8 +10,7 @@
 
 #include "vim.h"
 
-#include <fuchsia/hardware/pty/c/fidl.h>
-#include <lib/fdio/unsafe.h>
+#include <sys/ioctl.h>
 
 /*
  * Get the current window size in Rows and Columns.
@@ -23,17 +22,13 @@
         return -1;
     }
 
-    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) {
+    struct winsize sz;
+    memset(&sz, 0, sizeof(sz));
+    if (ioctl(STDIN_FILENO, TIOCGWINSZ, &sz) != 0) {
         return -1;
     }
-    Columns = wsz.height;
-    Rows = wsz.width;
+    Columns = sz.ws_col;
+    Rows = sz.ws_row;
     return OK;
 }