mirror of
https://github.com/nushell/nushell.git
synced 2024-12-22 15:13:01 +01:00
Move to latest stable crossterm, with fix (#4684)
This commit is contained in:
parent
ece5e7dbb7
commit
2a89936bee
95
Cargo.lock
generated
95
Cargo.lock
generated
@ -640,15 +640,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "crossterm"
|
||||
version = "0.22.1"
|
||||
version = "0.23.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c85525306c4291d1b73ce93c8acf9c339f9b213aef6c1d85c3830cbf1c16325c"
|
||||
checksum = "77b75a27dc8d220f1f8521ea69cd55a34d720a200ebb3a624d9aa19193d3b432"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"crossterm_winapi",
|
||||
"libc",
|
||||
"mio",
|
||||
"parking_lot",
|
||||
"parking_lot 0.12.0",
|
||||
"serde",
|
||||
"signal-hook",
|
||||
"signal-hook-mio",
|
||||
@ -1025,7 +1025,7 @@ checksum = "fcef756dea9cf3db5ce73759cf0467330427a786b47711b8d6c97620d718ceb9"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"rustix",
|
||||
"windows-sys",
|
||||
"windows-sys 0.30.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1856,6 +1856,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4e9323b3525d4efad2dead1837a105e313253bfdbad1d470994038eededa4d62"
|
||||
dependencies = [
|
||||
"ansi_term",
|
||||
"crossterm",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2697,7 +2698,17 @@ checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99"
|
||||
dependencies = [
|
||||
"instant",
|
||||
"lock_api",
|
||||
"parking_lot_core",
|
||||
"parking_lot_core 0.8.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot"
|
||||
version = "0.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "87f5ec2493a61ac0506c0f4199f99070cbe83857b0337006a30f3e6719b8ef58"
|
||||
dependencies = [
|
||||
"lock_api",
|
||||
"parking_lot_core 0.9.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2714,6 +2725,19 @@ dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot_core"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "28141e0cc4143da2443301914478dc976a61ffdb3f043058310c70df2fed8954"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"redox_syscall 0.2.10",
|
||||
"smallvec",
|
||||
"windows-sys 0.32.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "parquet-format-async-temp"
|
||||
version = "0.2.0"
|
||||
@ -3006,7 +3030,7 @@ version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "03f6f755d66fedfc506fb1df64aa8adb904cd0ef19fd4fb7f339e7ec3619aa65"
|
||||
dependencies = [
|
||||
"parking_lot",
|
||||
"parking_lot 0.11.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -3368,7 +3392,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "reedline"
|
||||
version = "0.2.0"
|
||||
source = "git+https://github.com/nushell/reedline?branch=main#e314e8491e2e69718af753536deb970884cb2f9b"
|
||||
source = "git+https://github.com/nushell/reedline?branch=main#3d933d52cee44b889b2d92b9688e071a8e4b992d"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"crossterm",
|
||||
@ -3768,7 +3792,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e0bccbcf40c8938196944a3da0e133e031a33f4d6b72db3bda3cc556e361905d"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"parking_lot",
|
||||
"parking_lot 0.11.2",
|
||||
"serial_test_derive",
|
||||
]
|
||||
|
||||
@ -3964,7 +3988,7 @@ checksum = "33994d0838dc2d152d17a62adf608a869b5e846b65b389af7f3dbc1de45c5b26"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"new_debug_unreachable",
|
||||
"parking_lot",
|
||||
"parking_lot 0.11.2",
|
||||
"phf_shared 0.10.0",
|
||||
"precomputed-hash",
|
||||
"serde",
|
||||
@ -4704,11 +4728,24 @@ version = "0.30.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "030b7ff91626e57a05ca64a07c481973cbb2db774e4852c9c7ca342408c6a99a"
|
||||
dependencies = [
|
||||
"windows_aarch64_msvc",
|
||||
"windows_i686_gnu",
|
||||
"windows_i686_msvc",
|
||||
"windows_x86_64_gnu",
|
||||
"windows_x86_64_msvc",
|
||||
"windows_aarch64_msvc 0.30.0",
|
||||
"windows_i686_gnu 0.30.0",
|
||||
"windows_i686_msvc 0.30.0",
|
||||
"windows_x86_64_gnu 0.30.0",
|
||||
"windows_x86_64_msvc 0.30.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.32.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3df6e476185f92a12c072be4a189a0210dcdcf512a1891d6dff9edb874deadc6"
|
||||
dependencies = [
|
||||
"windows_aarch64_msvc 0.32.0",
|
||||
"windows_i686_gnu 0.32.0",
|
||||
"windows_i686_msvc 0.32.0",
|
||||
"windows_x86_64_gnu 0.32.0",
|
||||
"windows_x86_64_msvc 0.32.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -4717,6 +4754,12 @@ version = "0.30.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "29277a4435d642f775f63c7d1faeb927adba532886ce0287bd985bffb16b6bca"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.32.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d8e92753b1c443191654ec532f14c199742964a061be25d77d7a96f09db20bf5"
|
||||
|
||||
[[package]]
|
||||
name = "windows_gen"
|
||||
version = "0.9.1"
|
||||
@ -4732,12 +4775,24 @@ version = "0.30.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1145e1989da93956c68d1864f32fb97c8f561a8f89a5125f6a2b7ea75524e4b8"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.32.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6a711c68811799e017b6038e0922cb27a5e2f43a2ddb609fe0b6f3eeda9de615"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.30.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d4a09e3a0d4753b73019db171c1339cd4362c8c44baf1bcea336235e955954a6"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.32.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "146c11bb1a02615db74680b32a68e2d61f553cc24c4eb5b4ca10311740e44172"
|
||||
|
||||
[[package]]
|
||||
name = "windows_macros"
|
||||
version = "0.9.1"
|
||||
@ -4754,12 +4809,24 @@ version = "0.30.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ca64fcb0220d58db4c119e050e7af03c69e6f4f415ef69ec1773d9aab422d5a"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.32.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c912b12f7454c6620635bbff3450962753834be2a594819bd5e945af18ec64bc"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.30.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "08cabc9f0066848fef4bc6a1c1668e6efce38b661d2aeec75d18d8617eebb5f1"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.32.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "504a2476202769977a040c6364301a3f65d0cc9e3fb08600b2bda150a0488316"
|
||||
|
||||
[[package]]
|
||||
name = "winreg"
|
||||
version = "0.7.0"
|
||||
|
@ -31,7 +31,7 @@ members = [
|
||||
|
||||
[dependencies]
|
||||
chrono = "0.4.19"
|
||||
crossterm = "0.22.1"
|
||||
crossterm = "0.23.0"
|
||||
crossterm_winapi = "0.9.0"
|
||||
ctrlc = "3.2.1"
|
||||
# lazy_static = "1.4.0"
|
||||
|
@ -30,7 +30,7 @@ calamine = "0.18.0"
|
||||
chrono = { version = "0.4.19", features = ["serde"] }
|
||||
chrono-humanize = "0.2.1"
|
||||
chrono-tz = "0.6.0"
|
||||
crossterm = "0.22.1"
|
||||
crossterm = "0.23.0"
|
||||
csv = "1.1.3"
|
||||
dialoguer = "0.9.0"
|
||||
digest = "0.10.0"
|
||||
@ -47,7 +47,7 @@ Inflector = "0.11"
|
||||
itertools = "0.10.0"
|
||||
lazy_static = "1.4.0"
|
||||
log = "0.4.14"
|
||||
lscolors = { version = "0.9.0"}
|
||||
lscolors = { version = "0.9.0", features = ["crossterm"]}
|
||||
md5 = { package = "md-5", version = "0.10.0" }
|
||||
meval = "0.2.0"
|
||||
mime = "0.3.16"
|
||||
|
@ -2,8 +2,8 @@ use std::borrow::Cow;
|
||||
|
||||
// use super::icons::{icon_for_file, iconify_style_ansi_to_nu};
|
||||
use super::icons::icon_for_file;
|
||||
use super::lscolor_ansiterm::ToNuAnsiStyle;
|
||||
use lscolors::LsColors;
|
||||
use lscolors::Style;
|
||||
use nu_engine::env_to_string;
|
||||
use nu_engine::CallExt;
|
||||
use nu_protocol::{
|
||||
@ -241,25 +241,24 @@ fn create_grid_output(
|
||||
let icon = icon_for_file(path, call.head)?;
|
||||
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(),
|
||||
};
|
||||
|
||||
let ansi_style = ls_colors_style
|
||||
.map(ToNuAnsiStyle::to_nu_ansi_style)
|
||||
.map(Style::to_crossterm_style)
|
||||
.unwrap_or_default();
|
||||
|
||||
let item = format!(
|
||||
"{} {}",
|
||||
ansi_style.paint(icon.to_string()),
|
||||
ansi_style.paint(value)
|
||||
);
|
||||
let item = format!("{} {}", icon_style.apply(icon), ansi_style.apply(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(ToNuAnsiStyle::to_nu_ansi_style)
|
||||
.unwrap_or_default();
|
||||
let mut cell = Cell::from(ansi_style.paint(value).to_string());
|
||||
let ansi_style = style.map(Style::to_crossterm_style).unwrap_or_default();
|
||||
let mut cell = Cell::from(ansi_style.apply(value).to_string());
|
||||
cell.alignment = Alignment::Left;
|
||||
grid.add(cell);
|
||||
}
|
||||
|
@ -1,60 +0,0 @@
|
||||
//! Hotpatch to use lscolors without depending on the unmaintained `ansi-term` crate or crossterm
|
||||
|
||||
pub trait ToNuAnsiStyle {
|
||||
fn to_nu_ansi_style(&self) -> nu_ansi_term::Style;
|
||||
}
|
||||
|
||||
pub trait ToNuAnsiColor {
|
||||
fn to_nu_ansi_color(&self) -> nu_ansi_term::Color;
|
||||
}
|
||||
|
||||
impl ToNuAnsiStyle for lscolors::Style {
|
||||
fn to_nu_ansi_style(&self) -> nu_ansi_term::Style {
|
||||
nu_ansi_term::Style {
|
||||
foreground: self
|
||||
.foreground
|
||||
.as_ref()
|
||||
.map(ToNuAnsiColor::to_nu_ansi_color),
|
||||
background: self
|
||||
.background
|
||||
.as_ref()
|
||||
.map(ToNuAnsiColor::to_nu_ansi_color),
|
||||
is_bold: self.font_style.bold,
|
||||
is_dimmed: self.font_style.dimmed,
|
||||
is_italic: self.font_style.italic,
|
||||
is_underline: self.font_style.underline,
|
||||
is_blink: self.font_style.rapid_blink || self.font_style.slow_blink,
|
||||
is_reverse: self.font_style.reverse,
|
||||
is_hidden: self.font_style.hidden,
|
||||
is_strikethrough: self.font_style.strikethrough,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ToNuAnsiColor for lscolors::Color {
|
||||
fn to_nu_ansi_color(&self) -> nu_ansi_term::Color {
|
||||
match self {
|
||||
lscolors::Color::RGB(r, g, b) => nu_ansi_term::Color::Rgb(*r, *g, *b),
|
||||
lscolors::Color::Fixed(n) => nu_ansi_term::Color::Fixed(*n),
|
||||
lscolors::Color::Black => nu_ansi_term::Color::Black,
|
||||
lscolors::Color::Red => nu_ansi_term::Color::Red,
|
||||
lscolors::Color::Green => nu_ansi_term::Color::Green,
|
||||
lscolors::Color::Yellow => nu_ansi_term::Color::Yellow,
|
||||
lscolors::Color::Blue => nu_ansi_term::Color::Blue,
|
||||
lscolors::Color::Magenta => nu_ansi_term::Color::Purple,
|
||||
lscolors::Color::Cyan => nu_ansi_term::Color::Cyan,
|
||||
lscolors::Color::White => nu_ansi_term::Color::White,
|
||||
|
||||
// Below items are a rough translations to 256 colors as
|
||||
// we do not have bright varients available on ansi-term
|
||||
lscolors::Color::BrightBlack => nu_ansi_term::Color::Fixed(8),
|
||||
lscolors::Color::BrightRed => nu_ansi_term::Color::Fixed(9),
|
||||
lscolors::Color::BrightGreen => nu_ansi_term::Color::Fixed(10),
|
||||
lscolors::Color::BrightYellow => nu_ansi_term::Color::Fixed(11),
|
||||
lscolors::Color::BrightBlue => nu_ansi_term::Color::Fixed(12),
|
||||
lscolors::Color::BrightMagenta => nu_ansi_term::Color::Fixed(13),
|
||||
lscolors::Color::BrightCyan => nu_ansi_term::Color::Fixed(14),
|
||||
lscolors::Color::BrightWhite => nu_ansi_term::Color::Fixed(15),
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
mod griddle;
|
||||
mod icons;
|
||||
mod lscolor_ansiterm;
|
||||
mod table;
|
||||
|
||||
pub use griddle::Griddle;
|
||||
|
@ -1,4 +1,4 @@
|
||||
use lscolors::LsColors;
|
||||
use lscolors::{LsColors, Style};
|
||||
use nu_color_config::{get_color_config, style_primitive};
|
||||
use nu_engine::column::get_columns;
|
||||
use nu_engine::{env_to_string, CallExt};
|
||||
@ -14,7 +14,7 @@ use std::sync::Arc;
|
||||
use std::time::Instant;
|
||||
use terminal_size::{Height, Width};
|
||||
|
||||
use super::lscolor_ansiterm::ToNuAnsiStyle;
|
||||
//use super::lscolor_ansiterm::ToNuAnsiStyle;
|
||||
|
||||
const STREAM_PAGE_SIZE: usize = 1000;
|
||||
const STREAM_TIMEOUT_CHECK_INTERVAL: usize = 100;
|
||||
@ -222,13 +222,14 @@ fn handle_row_stream(
|
||||
Some(&metadata),
|
||||
);
|
||||
let ansi_style = style
|
||||
.map(ToNuAnsiStyle::to_nu_ansi_style)
|
||||
.map(Style::to_crossterm_style)
|
||||
// .map(ToNuAnsiStyle::to_nu_ansi_style)
|
||||
.unwrap_or_default();
|
||||
let use_ls_colors = config.use_ls_colors;
|
||||
|
||||
if use_ls_colors {
|
||||
vals[idx] = Value::String {
|
||||
val: ansi_style.paint(path).to_string(),
|
||||
val: ansi_style.apply(path).to_string(),
|
||||
span: *span,
|
||||
};
|
||||
}
|
||||
@ -236,13 +237,14 @@ fn handle_row_stream(
|
||||
Err(_) => {
|
||||
let style = ls_colors.style_for_path(path.clone());
|
||||
let ansi_style = style
|
||||
.map(ToNuAnsiStyle::to_nu_ansi_style)
|
||||
.map(Style::to_crossterm_style)
|
||||
// .map(ToNuAnsiStyle::to_nu_ansi_style)
|
||||
.unwrap_or_default();
|
||||
let use_ls_colors = config.use_ls_colors;
|
||||
|
||||
if use_ls_colors {
|
||||
vals[idx] = Value::String {
|
||||
val: ansi_style.paint(path).to_string(),
|
||||
val: ansi_style.apply(path).to_string(),
|
||||
span: *span,
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user