Skip to content
This repository has been archived by the owner on Mar 10, 2021. It is now read-only.

Commit

Permalink
fix: uses libc::winsize instead of homegrown
Browse files Browse the repository at this point in the history
Closes #6
  • Loading branch information
kbknapp committed Sep 5, 2016
1 parent fd70b99 commit 216986e
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,7 @@ use winapi::{CONSOLE_SCREEN_BUFFER_INFO, COORD, SMALL_RECT, STD_OUTPUT_HANDLE};
#[cfg(not(target_os = "windows"))]
use std::mem::zeroed;
#[cfg(not(target_os = "windows"))]
use libc::{STDOUT_FILENO, c_int, c_ulong, c_ushort};

/// The number of rows and columns of a terminal.
#[cfg(not(target_os = "windows"))]
#[repr(C)]
struct Winsize {
ws_row: c_ushort,
ws_col: c_ushort,
}
use libc::{STDOUT_FILENO, c_int, c_ulong, winsize};

// Unfortunately the actual command is not standardised...
#[cfg(any(target_os = "linux", target_os = "android"))]
Expand All @@ -62,8 +54,8 @@ extern "C" {
/// there is an error. (0, 0) is an invalid size to have anyway, which is why
/// it can be used as a nil value.
#[cfg(not(target_os = "windows"))]
unsafe fn get_dimensions() -> Winsize {
let mut window: Winsize = zeroed();
unsafe fn get_dimensions() -> winsize {
let mut window: winsize = zeroed();
let result = ioctl(STDOUT_FILENO, TIOCGWINSZ, &mut window);

if result == -1 {
Expand Down

0 comments on commit 216986e

Please sign in to comment.