Skip to content

Commit

Permalink
refactor(term.rs): moved term.rs into it's own crate so others can pu…
Browse files Browse the repository at this point in the history
…ll in just that portion

The functionality can now be found in https://crates.io/crates/term_size

Closes #549
  • Loading branch information
kbknapp committed Jun 30, 2016
1 parent 98a7e8a commit ceddee9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 85 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ strsim = { version = "~0.4.0", optional = true }
yaml-rust = { version = "~0.3.2", optional = true }
clippy = { version = "~0.0.74", optional = true }
unicode-width = { version = "~0.1.3", optional = true }
term_size = { version = "~0.1.0", optional = true }

[dev-dependencies]
regex = "~0.1.69"
Expand All @@ -29,7 +30,7 @@ default = ["suggestions", "color", "wrap_help"]
suggestions = ["strsim"]
color = ["ansi_term", "libc"]
yaml = ["yaml-rust"]
wrap_help = ["libc", "unicode-width"]
wrap_help = ["libc", "unicode-width", "term_size"]
lints = ["clippy", "nightly"]
nightly = [] # for building with nightly and unstable features
unstable = [] # for building with unstable features on stable Rust
Expand Down
11 changes: 9 additions & 2 deletions src/app/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@ use app::{App, AppSettings};
use app::parser::Parser;
use fmt::{Format, Colorizer};

use term;
#[cfg(all(feature = "wrap_help", not(target_os = "windows")))]
use term_size;
#[cfg(any(not(feature = "wrap_help"), target_os = "windows"))]
mod term_size {
pub fn dimensions() -> Option<(usize, usize)> {
None
}
}

#[cfg(all(feature = "wrap_help", not(target_os = "windows")))]
use unicode_width::UnicodeWidthStr;
Expand Down Expand Up @@ -96,7 +103,7 @@ impl<'a> Help<'a> {
hide_pv: hide_pv,
term_w: match term_w {
Some(width) => width,
None => term::dimensions().map(|(w, _)| w).unwrap_or(120),
None => term_size::dimensions().map(|(w, _)| w).unwrap_or(120),
},
color: color,
cizer: cizer,
Expand Down
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,8 @@ extern crate unicode_width;
#[macro_use]
extern crate bitflags;
extern crate vec_map;
#[cfg(feature = "wrap_help")]
extern crate term_size;

#[cfg(feature = "yaml")]
pub use yaml_rust::YamlLoader;
Expand All @@ -431,7 +433,6 @@ mod fmt;
mod suggestions;
mod errors;
mod osstringext;
mod term;
mod strext;

const INTERNAL_ERROR_MSG: &'static str = "Fatal internal error. Please consider filing a bug \
Expand Down
81 changes: 0 additions & 81 deletions src/term.rs

This file was deleted.

0 comments on commit ceddee9

Please sign in to comment.