Update crossterm version to 0.26 (#8623)

# Description

This pr is a companion to https://github.com/nushell/reedline/pull/560

Fortunally, we don't need to change too much nushell code.

## Additional note about lscolor dependency
https://github.com/sharkdp/lscolors/pull/58~~
lscolor is using 0.26 for now
This commit is contained in:
WindSoilder
2023-04-15 04:14:57 +08:00
committed by GitHub
parent 71611dec4f
commit 9b35d59023
13 changed files with 338 additions and 291 deletions

View File

@ -248,10 +248,10 @@ fn highlight_terms_in_record(
// Get the original LS_COLORS color
let style = ls_colors.style_for_path(val_str.clone());
let ansi_style = style
.map(LsColors_Style::to_crossterm_style)
.map(LsColors_Style::to_nu_ansi_term_style)
.unwrap_or_default();
let ls_colored_val = ansi_style.apply(&val_str).to_string();
let ls_colored_val = ansi_style.paint(&val_str).to_string();
let ansi_term_style = style
.map(to_nu_ansi_term_style)

View File

@ -207,23 +207,27 @@ fn create_grid_output(
let ls_colors_style = ls_colors.style_for_path(path);
let icon_style = match ls_colors_style {
Some(c) => c.to_crossterm_style(),
None => crossterm::style::ContentStyle::default(),
Some(c) => c.to_nu_ansi_term_style(),
None => nu_ansi_term::Style::default(),
};
let ansi_style = ls_colors_style
.map(Style::to_crossterm_style)
.map(Style::to_nu_ansi_term_style)
.unwrap_or_default();
let item = format!("{} {}", icon_style.apply(icon), ansi_style.apply(value));
let item = format!(
"{} {}",
icon_style.paint(String::from(icon)),
ansi_style.paint(value)
);
let mut cell = Cell::from(item);
cell.alignment = Alignment::Left;
grid.add(cell);
} else {
let style = ls_colors.style_for_path(value.clone());
let ansi_style = style.map(Style::to_crossterm_style).unwrap_or_default();
let mut cell = Cell::from(ansi_style.apply(value).to_string());
let ansi_style = style.map(Style::to_nu_ansi_term_style).unwrap_or_default();
let mut cell = Cell::from(ansi_style.paint(value).to_string());
cell.alignment = Alignment::Left;
grid.add(cell);
}

View File

@ -1845,10 +1845,7 @@ fn render_path_name(
let in_ssh_session = std::env::var("SSH_CLIENT").is_ok();
let show_clickable_links = config.show_clickable_links_in_ls && !in_ssh_session && has_metadata;
let ansi_style = style
.map(Style::to_crossterm_style)
// .map(ToNuAnsiStyle::to_nu_ansi_style)
.unwrap_or_default();
let ansi_style = style.map(Style::to_nu_ansi_term_style).unwrap_or_default();
let full_path = PathBuf::from(stripped_path.as_ref())
.canonicalize()
@ -1860,7 +1857,7 @@ fn render_path_name(
show_clickable_links,
);
let val = ansi_style.apply(full_path_link).to_string();
let val = ansi_style.paint(full_path_link).to_string();
Some(Value::String { val, span })
}