|
|
@ -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_core::config::{default_syntax_loader, user_syntax_loader};
|
|
|
|
use helix_loader::grammar::load_runtime_file;
|
|
|
|
use helix_loader::grammar::load_runtime_file;
|
|
|
|
use std::io::Write;
|
|
|
|
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 terminal_cols = crossterm::terminal::size().map(|(c, _)| c).unwrap_or(80);
|
|
|
|
let column_width = terminal_cols as usize / headings.len();
|
|
|
|
let column_width = terminal_cols as usize / headings.len();
|
|
|
|
|
|
|
|
let is_terminal = std::io::stdout().is_tty();
|
|
|
|
|
|
|
|
|
|
|
|
let column = |item: &str, color: Color| {
|
|
|
|
let column = |item: &str, color: Color| {
|
|
|
|
let data = format!(
|
|
|
|
let mut data = format!(
|
|
|
|
"{:width$}",
|
|
|
|
"{:width$}",
|
|
|
|
item.get(..column_width - 2)
|
|
|
|
item.get(..column_width - 2)
|
|
|
|
.map(|s| format!("{}…", s))
|
|
|
|
.map(|s| format!("{}…", s))
|
|
|
|
.unwrap_or_else(|| item.to_string()),
|
|
|
|
.unwrap_or_else(|| item.to_string()),
|
|
|
|
width = column_width,
|
|
|
|
width = column_width,
|
|
|
|
)
|
|
|
|
);
|
|
|
|
.stylize()
|
|
|
|
if is_terminal {
|
|
|
|
.with(color);
|
|
|
|
data = data.stylize().with(color).to_string();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// We can't directly use println!() because of
|
|
|
|
// We can't directly use println!() because of
|
|
|
|
// https://github.com/crossterm-rs/crossterm/issues/589
|
|
|
|
// https://github.com/crossterm-rs/crossterm/issues/589
|
|
|
|