Merge pull request #2511 from nickelc/nu-ansi-term

Use `nu-ansi-term` instead of `ansi_term`
This commit is contained in:
David Peter 2023-03-24 22:05:41 +01:00 committed by GitHub
commit 4d9aaece09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 23 additions and 23 deletions

20
Cargo.lock generated
View File

@ -26,15 +26,6 @@ dependencies = [
"rgb", "rgb",
] ]
[[package]]
name = "ansi_term"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
dependencies = [
"winapi",
]
[[package]] [[package]]
name = "assert_cmd" name = "assert_cmd"
version = "2.0.8" version = "2.0.8"
@ -77,7 +68,6 @@ name = "bat"
version = "0.22.1" version = "0.22.1"
dependencies = [ dependencies = [
"ansi_colours", "ansi_colours",
"ansi_term",
"assert_cmd", "assert_cmd",
"atty", "atty",
"bincode", "bincode",
@ -95,6 +85,7 @@ dependencies = [
"globset", "globset",
"grep-cli", "grep-cli",
"nix", "nix",
"nu-ansi-term",
"once_cell", "once_cell",
"path_abs", "path_abs",
"plist", "plist",
@ -747,6 +738,15 @@ version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be"
[[package]]
name = "nu-ansi-term"
version = "0.47.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1df031e117bca634c262e9bd3173776844b6c17a90b3741c9163663b4385af76"
dependencies = [
"windows-sys 0.45.0",
]
[[package]] [[package]]
name = "num-traits" name = "num-traits"
version = "0.2.15" version = "0.2.15"

View File

@ -42,7 +42,7 @@ regex-fancy = ["syntect/regex-fancy"] # Use the rust-only "fancy-regex" engine
[dependencies] [dependencies]
atty = { version = "0.2.14", optional = true } atty = { version = "0.2.14", optional = true }
ansi_term = "^0.12.1" nu-ansi-term = "0.47.0"
ansi_colours = "^1.2" ansi_colours = "^1.2"
bincode = "1.0" bincode = "1.0"
console = "0.15.5" console = "0.15.5"

View File

@ -38,7 +38,7 @@ pub struct App {
impl App { impl App {
pub fn new() -> Result<Self> { pub fn new() -> Result<Self> {
#[cfg(windows)] #[cfg(windows)]
let _ = ansi_term::enable_ansi_support(); let _ = nu_ansi_term::enable_ansi_support();
let interactive_output = atty::is(Stream::Stdout); let interactive_output = atty::is(Stream::Stdout);

View File

@ -14,8 +14,8 @@ use std::io::{BufReader, Write};
use std::path::Path; use std::path::Path;
use std::process; use std::process;
use ansi_term::Colour::Green; use nu_ansi_term::Color::Green;
use ansi_term::Style; use nu_ansi_term::Style;
use crate::{ use crate::{
app::App, app::App,

View File

@ -1,7 +1,7 @@
#[cfg(feature = "git")] #[cfg(feature = "git")]
use crate::diff::LineChange; use crate::diff::LineChange;
use crate::printer::{Colors, InteractivePrinter}; use crate::printer::{Colors, InteractivePrinter};
use ansi_term::Style; use nu_ansi_term::Style;
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub(crate) struct DecorationText { pub(crate) struct DecorationText {

View File

@ -43,7 +43,7 @@ impl From<String> for Error {
pub type Result<T> = std::result::Result<T, Error>; pub type Result<T> = std::result::Result<T, Error>;
pub fn default_error_handler(error: &Error, output: &mut dyn Write) { pub fn default_error_handler(error: &Error, output: &mut dyn Write) {
use ansi_term::Colour::Red; use nu_ansi_term::Color::Red;
match error { match error {
Error::Io(ref io_error) if io_error.kind() == ::std::io::ErrorKind::BrokenPipe => { Error::Io(ref io_error) if io_error.kind() == ::std::io::ErrorKind::BrokenPipe => {

View File

@ -1,7 +1,7 @@
#[macro_export] #[macro_export]
macro_rules! bat_warning { macro_rules! bat_warning {
($($arg:tt)*) => ({ ($($arg:tt)*) => ({
use ansi_term::Colour::Yellow; use nu_ansi_term::Color::Yellow;
eprintln!("{}: {}", Yellow.paint("[bat warning]"), format!($($arg)*)); eprintln!("{}: {}", Yellow.paint("[bat warning]"), format!($($arg)*));
}) })
} }

View File

@ -1,8 +1,8 @@
use std::io::Write; use std::io::Write;
use std::vec::Vec; use std::vec::Vec;
use ansi_term::Colour::{Fixed, Green, Red, Yellow}; use nu_ansi_term::Color::{Fixed, Green, Red, Yellow};
use ansi_term::Style; use nu_ansi_term::Style;
use bytesize::ByteSize; use bytesize::ByteSize;

View File

@ -1,9 +1,9 @@
use ansi_term::Color::{self, Fixed, RGB}; use nu_ansi_term::Color::{self, Fixed, Rgb};
use ansi_term::{self, Style}; use nu_ansi_term::{self, Style};
use syntect::highlighting::{self, FontStyle}; use syntect::highlighting::{self, FontStyle};
pub fn to_ansi_color(color: highlighting::Color, true_color: bool) -> Option<ansi_term::Color> { pub fn to_ansi_color(color: highlighting::Color, true_color: bool) -> Option<nu_ansi_term::Color> {
if color.a == 0 { if color.a == 0 {
// Themes can specify one of the user-configurable terminal colors by // Themes can specify one of the user-configurable terminal colors by
// encoding them as #RRGGBBAA with AA set to 00 (transparent) and RR set // encoding them as #RRGGBBAA with AA set to 00 (transparent) and RR set
@ -38,7 +38,7 @@ pub fn to_ansi_color(color: highlighting::Color, true_color: bool) -> Option<ans
// 01. The built-in theme ansi uses this. // 01. The built-in theme ansi uses this.
None None
} else if true_color { } else if true_color {
Some(RGB(color.r, color.g, color.b)) Some(Rgb(color.r, color.g, color.b))
} else { } else {
Some(Fixed(ansi_colours::ansi256_from_rgb(( Some(Fixed(ansi_colours::ansi256_from_rgb((
color.r, color.g, color.b, color.r, color.g, color.b,