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

Commit

Permalink
Merge pull request #7 from kbknapp/issue-6
Browse files Browse the repository at this point in the history
Issue 6
  • Loading branch information
kbknapp committed Sep 5, 2016
2 parents fd70b99 + c52f989 commit 1fc68d3
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 18 deletions.
7 changes: 2 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ sudo: false
language: rust
rust:
- nightly
- nightly-2016-06-05
- nightly-2016-09-04
- beta
- stable
# Only while clippy is failing
matrix:
allow_failures:
- rust: nightly
Expand All @@ -18,8 +17,7 @@ script:
cargo build --verbose &&
cargo test --verbose &&
travis-cargo --only nightly build &&
travis-cargo --only nightly bench &&
travis-cargo --only stable doc
travis-cargo --only nightly bench
addons:
apt:
packages:
Expand All @@ -28,7 +26,6 @@ addons:
- libdw-dev
after_success:
- |
travis-cargo --only stable doc-upload &&
travis-cargo --only stable coveralls --no-sudo
env:
global:
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
<a name="v0.2.1"></a>
### v0.2.1 (2016-09-05)


#### Bug Fixes

* uses libc::winsize instead of homegrown ([216986ec](https://github.com/kbknapp/term_size-rs/commit/216986ecdbe528523953a1cde4cf6c329a0f4fbc), closes [#6](https://github.com/kbknapp/term_size-rs/issues/6))




<a name="v0.2.0">v0.2.0</a>
## v0.2.0 (2016-09-05)
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "term_size"
version = "0.2.0"
version = "0.2.1"
authors = ["Kevin K. <kbknapp@gmail.com>", "Benjamin Sago <ogham@bsago.me>"]
exclude = []
description = "functions for determining terminal sizes and dimensions"
Expand All @@ -11,7 +11,7 @@ license = "MIT/Apache-2.0"
keywords = ["term", "terminal", "size", "width", "dimension"]

[dependencies]
clippy = { version = "~0.0.74", optional = true }
clippy = { version = "~0.0.88", optional = true }

[target.'cfg(not(target_os = "windows"))'.dependencies]
libc = "~0.2.9"
Expand Down
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 1fc68d3

Please sign in to comment.