diff options
author | Blaž Hrastnik | 2022-06-21 16:38:21 +0000 |
---|---|---|
committer | GitHub | 2022-06-21 16:38:21 +0000 |
commit | 458b89e21dcf76bbf9ca6ba237bd334f4922722d (patch) | |
tree | f859642d007db7274d3cd657ecaa59b1ec014cd8 /helix-term/src/health.rs | |
parent | 5f7c247430998fabceb55d4689118dd75e2bdfb1 (diff) | |
parent | 6a3f7f2c399f0b92cef97b0c85ebe976fd7cfcac (diff) |
Merge branch 'master' into test-harness
Diffstat (limited to 'helix-term/src/health.rs')
-rw-r--r-- | helix-term/src/health.rs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/helix-term/src/health.rs b/helix-term/src/health.rs index bd74f478..f64e121d 100644 --- a/helix-term/src/health.rs +++ b/helix-term/src/health.rs @@ -1,4 +1,7 @@ -use crossterm::style::{Color, Print, Stylize}; +use crossterm::{ + style::{Color, Print, Stylize}, + tty::IsTty, +}; use helix_core::config::{default_syntax_loader, user_syntax_loader}; use helix_loader::grammar::load_runtime_file; use std::io::Write; @@ -106,17 +109,19 @@ pub fn languages_all() -> std::io::Result<()> { let terminal_cols = crossterm::terminal::size().map(|(c, _)| c).unwrap_or(80); let column_width = terminal_cols as usize / headings.len(); + let is_terminal = std::io::stdout().is_tty(); let column = |item: &str, color: Color| { - let data = format!( + let mut data = format!( "{:width$}", item.get(..column_width - 2) .map(|s| format!("{}…", s)) .unwrap_or_else(|| item.to_string()), width = column_width, - ) - .stylize() - .with(color); + ); + if is_terminal { + data = data.stylize().with(color).to_string(); + } // We can't directly use println!() because of // https://github.com/crossterm-rs/crossterm/issues/589 |