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

@ -42,7 +42,7 @@ calamine = "0.19.1"
chrono = { version = "0.4.23", features = ["std", "unstable-locales"], default-features = false }
chrono-humanize = "0.2.1"
chrono-tz = "0.8.1"
crossterm = "0.24.0"
crossterm = "0.26"
csv = "1.2.0"
dialoguer = { default-features = false, version = "0.10.3" }
digest = { default-features = false, version = "0.10.0" }
@ -58,7 +58,7 @@ indicatif = "0.17.2"
is-root = "0.1.2"
itertools = "0.10.0"
log = "0.4.14"
lscolors = { version = "0.12.0", features = ["crossterm"], default-features = false }
lscolors = { version = "0.14", default-features = false, features = ["nu-ansi-term"] }
md5 = { package = "md-5", version = "0.10.0" }
miette = { version = "5.7.0", features = ["fancy-no-backtrace"] }
mime = "0.3.16"

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 })
}

View File

@ -539,16 +539,16 @@ fn test_expand_big_0() {
repository = "https://github.com/nushell/nushell"
rust-version = "1.60"
version = "0.74.1"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[package.metadata.binstall]
pkg-url = "{ repo }/releases/download/{ version }/{ name }-{ version }-{ target }.{ archive-format }"
pkg-fmt = "tgz"
[package.metadata.binstall.overrides.x86_64-pc-windows-msvc]
pkg-fmt = "zip"
[workspace]
members = [
"crates/nu-cli",
@ -565,7 +565,7 @@ fn test_expand_big_0() {
"crates/nu_plugin_custom_values",
"crates/nu-utils",
]
[dependencies]
chrono = { version = "0.4.23", features = ["serde"] }
crossterm = "0.24.0"
@ -576,25 +576,25 @@ fn test_expand_big_0() {
nu-cli = { path = "./crates/nu-cli", version = "0.74.1" }
nu-engine = { path = "./crates/nu-engine", version = "0.74.1" }
reedline = { version = "0.14.0", features = ["bashisms", "sqlite"] }
rayon = "1.6.1"
is_executable = "1.0.1"
simplelog = "0.12.0"
time = "0.3.12"
[target.'cfg(not(target_os = "windows"))'.dependencies]
# Our dependencies don't use OpenSSL on Windows
openssl = { version = "0.10.38", features = ["vendored"], optional = true }
signal-hook = { version = "0.3.14", default-features = false }
[target.'cfg(windows)'.build-dependencies]
winres = "0.1"
[target.'cfg(target_family = "unix")'.dependencies]
nix = { version = "0.25", default-features = false, features = ["signal", "process", "fs", "term"] }
atty = "0.2"
[dev-dependencies]
nu-test-support = { path = "./crates/nu-test-support", version = "0.74.1" }
tempfile = "3.2.0"
@ -605,7 +605,7 @@ fn test_expand_big_0() {
hamcrest2 = "0.3.0"
rstest = { version = "0.15.0", default-features = false }
itertools = "0.10.3"
[features]
plugin = [
"nu-plugin",
@ -620,10 +620,10 @@ fn test_expand_big_0() {
default = ["plugin", "which-support", "trash-support", "sqlite"]
stable = ["default"]
wasi = []
# Enable to statically link OpenSSL; otherwise the system version will be used. Not enabled by default because it takes a while to build
static-link-openssl = ["dep:openssl"]
# Stable (Default)
which-support = ["nu-command/which-support"]
trash-support = ["nu-command/trash-support"]
@ -632,12 +632,12 @@ fn test_expand_big_0() {
[[bin]]
name = "nu"
path = "src/main.rs"
# To use a development version of a dependency please use a global override here
# changing versions in each sub-crate of the workspace is tedious
[patch.crates-io]
reedline = { git = "https://github.com/nushell/reedline.git", branch = "main" }
# Criterion benchmarking setup
# Run all benchmarks with `cargo bench`
# Run individual benchmarks like `cargo bench -- <regex>` e.g. `cargo bench -- parse`