diff --git a/Cargo.lock b/Cargo.lock index ce8e5f716..037c076be 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -41,15 +41,6 @@ dependencies = [ "rgb", ] -[[package]] -name = "ansi_term" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" -dependencies = [ - "winapi", -] - [[package]] name = "anstream" version = "0.6.5" @@ -144,7 +135,7 @@ dependencies = [ "globset", "grep-cli", "home", - "nu-ansi-term", + "nu-ansi-term 0.49.0", "once_cell", "path_abs", "plist", @@ -608,7 +599,6 @@ name = "git-delta" version = "0.18.2" dependencies = [ "ansi_colours", - "ansi_term", "anstyle-parse", "anyhow", "bat", @@ -627,6 +617,7 @@ dependencies = [ "insta", "itertools", "lazy_static", + "nu-ansi-term 0.50.3", "palette", "pathdiff", "pretty_assertions", @@ -919,6 +910,15 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "nu-ansi-term" +version = "0.50.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" +dependencies = [ + "windows-sys 0.59.0", +] + [[package]] name = "num-conv" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 59a1fc8eb..f9f44a807 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ path = "src/main.rs" [dependencies] ansi_colours = "1.2.1" -ansi_term = "0.12.1" +ansi_term = { package = "nu-ansi-term", version = "0.50"} anstyle-parse = "0.2.3" anyhow = "1.0.70" bat = { version = "0.24.0", default-features = false, features = [ diff --git a/src/ansi/iterator.rs b/src/ansi/iterator.rs index c688adb30..d0397d25e 100644 --- a/src/ansi/iterator.rs +++ b/src/ansi/iterator.rs @@ -270,7 +270,7 @@ fn parse_sgr_color(params: &mut dyn Iterator) -> Option Some(ansi_term::Color::Fixed(u8::try_from(params.next()?).ok()?)), _ => None, diff --git a/src/color.rs b/src/color.rs index fb368f987..e4fa189d7 100644 --- a/src/color.rs +++ b/src/color.rs @@ -41,17 +41,28 @@ pub fn parse_color(s: &str, true_color: bool, git_config: Option<&GitConfig>) -> pub fn color_to_string(color: Color) -> String { match color { + Color::Default => todo!(), Color::Fixed(n) if n < 16 => ansi_16_color_number_to_name(n).unwrap().to_string(), Color::Fixed(n) => format!("{n}"), - Color::RGB(r, g, b) => format!("\"#{r:02x?}{g:02x?}{b:02x?}\""), + Color::Rgb(r, g, b) => format!("\"#{r:02x?}{g:02x?}{b:02x?}\""), Color::Black => "black".to_string(), + Color::DarkGray => "bright-black".to_string(), Color::Red => "red".to_string(), + Color::LightRed => "bright-red".to_string(), Color::Green => "green".to_string(), + Color::LightGreen => "bright-green".to_string(), Color::Yellow => "yellow".to_string(), + Color::LightYellow => "bright-yellow".to_string(), Color::Blue => "blue".to_string(), + Color::LightBlue => "bright-blue".to_string(), Color::Purple => "purple".to_string(), + Color::LightPurple => "bright-purple".to_string(), + Color::Magenta => "magenta".to_string(), + Color::LightMagenta => "bright-magenta".to_string(), Color::Cyan => "cyan".to_string(), + Color::LightCyan => "bright-cyan".to_string(), Color::White => "white".to_string(), + Color::LightGray => "bright-white".to_string(), } } @@ -153,35 +164,35 @@ pub fn get_plus_emph_background_color_default(mode: ColorMode, is_true_color: bo } } -const LIGHT_THEME_MINUS_COLOR: Color = Color::RGB(0xff, 0xe0, 0xe0); +const LIGHT_THEME_MINUS_COLOR: Color = Color::Rgb(0xff, 0xe0, 0xe0); const LIGHT_THEME_MINUS_COLOR_256: Color = Color::Fixed(224); -const LIGHT_THEME_MINUS_EMPH_COLOR: Color = Color::RGB(0xff, 0xc0, 0xc0); +const LIGHT_THEME_MINUS_EMPH_COLOR: Color = Color::Rgb(0xff, 0xc0, 0xc0); const LIGHT_THEME_MINUS_EMPH_COLOR_256: Color = Color::Fixed(217); -const LIGHT_THEME_PLUS_COLOR: Color = Color::RGB(0xd0, 0xff, 0xd0); +const LIGHT_THEME_PLUS_COLOR: Color = Color::Rgb(0xd0, 0xff, 0xd0); const LIGHT_THEME_PLUS_COLOR_256: Color = Color::Fixed(194); -const LIGHT_THEME_PLUS_EMPH_COLOR: Color = Color::RGB(0xa0, 0xef, 0xa0); +const LIGHT_THEME_PLUS_EMPH_COLOR: Color = Color::Rgb(0xa0, 0xef, 0xa0); const LIGHT_THEME_PLUS_EMPH_COLOR_256: Color = Color::Fixed(157); -const DARK_THEME_MINUS_COLOR: Color = Color::RGB(0x3f, 0x00, 0x01); +const DARK_THEME_MINUS_COLOR: Color = Color::Rgb(0x3f, 0x00, 0x01); const DARK_THEME_MINUS_COLOR_256: Color = Color::Fixed(52); -const DARK_THEME_MINUS_EMPH_COLOR: Color = Color::RGB(0x90, 0x10, 0x11); +const DARK_THEME_MINUS_EMPH_COLOR: Color = Color::Rgb(0x90, 0x10, 0x11); const DARK_THEME_MINUS_EMPH_COLOR_256: Color = Color::Fixed(124); -const DARK_THEME_PLUS_COLOR: Color = Color::RGB(0x00, 0x28, 0x00); +const DARK_THEME_PLUS_COLOR: Color = Color::Rgb(0x00, 0x28, 0x00); const DARK_THEME_PLUS_COLOR_256: Color = Color::Fixed(22); -const DARK_THEME_PLUS_EMPH_COLOR: Color = Color::RGB(0x00, 0x60, 0x00); +const DARK_THEME_PLUS_EMPH_COLOR: Color = Color::Rgb(0x00, 0x60, 0x00); const DARK_THEME_PLUS_EMPH_COLOR_256: Color = Color::Fixed(28); diff --git a/src/features/line_numbers.rs b/src/features/line_numbers.rs index 3b2fcff08..fe01aad21 100644 --- a/src/features/line_numbers.rs +++ b/src/features/line_numbers.rs @@ -103,7 +103,7 @@ pub fn linenumbers_and_styles<'a>( )) } -/// Return a vec of `ansi_term::ANSIGenericString`s representing the left and right fields of the +/// Return a vec of `ansi_term::AnsiGenericString`s representing the left and right fields of the /// two-column line number display. pub fn format_and_paint_line_numbers<'a>( line_numbers_data: &'a LineNumbersData, @@ -111,7 +111,7 @@ pub fn format_and_paint_line_numbers<'a>( styles: MinusPlus