Skip to content

Commit 2bfe9ad

Browse files
committed
Remove atty in favor of is-terminal
The std version of it is only usable in v1.70 unfortunately.
1 parent 3ad8226 commit 2bfe9ad

File tree

3 files changed

+8
-15
lines changed

3 files changed

+8
-15
lines changed

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ render-tui = ["tui",
5959
render-line = ["crosstermion/color", "humantime", "unicode-width"]
6060
render-line-crossterm = ["crosstermion/crossterm"]
6161
render-line-termion = ["crosstermion/termion"]
62-
render-line-autoconfigure = ["atty"]
62+
render-line-autoconfigure = ["is-terminal"]
6363

6464
local-time = ["time"]
6565

@@ -88,7 +88,7 @@ time = { version = "0.3.2", optional = true, features = ["std", "local-offset",
8888
# line renderer
8989
ctrlc = { version = "3.1.4", optional = true, default-features = false, features = ['termination'] }
9090
signal-hook = { version = "0.3.9", optional = true, default-features = false }
91-
atty = { version = "0.2.14", optional = true }
91+
is-terminal = { version = "0.4.9", optional = true }
9292

9393
# units
9494
bytesize = { version = "1.0.1", optional = true }
@@ -105,7 +105,7 @@ criterion = { version = "0.5.1", default-features = false }
105105
futures-util = { version = "0.3.4", default-features = false }
106106
argh = "0.1.3"
107107
futures = "0.3.5"
108-
atty = "0.2.14"
108+
is-terminal = "0.4.9"
109109
blocking = "1.0.0"
110110
once_cell = "1.4.0"
111111
async-executor = "1.1.0"

examples/shared/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub fn launch_ambient_gui(
5454
}
5555
.boxed(),
5656
"tui" => {
57-
if atty::isnt(atty::Stream::Stdout) {
57+
if !is_terminal::is_terminal(std::io::stdout()) {
5858
eprintln!("Need a terminal on stdout to draw progress TUI");
5959
futures_lite::future::ready(()).boxed()
6060
} else {

src/render/line/engine.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,6 @@ pub enum StreamKind {
7474
Stderr,
7575
}
7676

77-
#[cfg(feature = "render-line-autoconfigure")]
78-
impl From<StreamKind> for atty::Stream {
79-
fn from(s: StreamKind) -> Self {
80-
match s {
81-
StreamKind::Stdout => atty::Stream::Stdout,
82-
StreamKind::Stderr => atty::Stream::Stderr,
83-
}
84-
}
85-
}
86-
8777
/// Convenience
8878
impl Options {
8979
/// Automatically configure (and overwrite) the following fields based on terminal configuration.
@@ -94,7 +84,10 @@ impl Options {
9484
/// * hide-cursor (based on presence of 'signal-hook' feature.
9585
#[cfg(feature = "render-line-autoconfigure")]
9686
pub fn auto_configure(mut self, output: StreamKind) -> Self {
97-
self.output_is_terminal = atty::is(output.into());
87+
self.output_is_terminal = match output {
88+
StreamKind::Stdout => is_terminal::is_terminal(std::io::stdout()),
89+
StreamKind::Stderr => is_terminal::is_terminal(std::io::stderr()),
90+
};
9891
self.colored = self.output_is_terminal && crosstermion::color::allowed();
9992
self.terminal_dimensions = crosstermion::terminal::size().unwrap_or((80, 20));
10093
#[cfg(feature = "signal-hook")]

0 commit comments

Comments
 (0)