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",
]
[[package]]
name = "ansi_term"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
dependencies = [
"winapi",
]
[[package]]
name = "assert_cmd"
version = "2.0.8"
@ -77,7 +68,6 @@ name = "bat"
version = "0.22.1"
dependencies = [
"ansi_colours",
"ansi_term",
"assert_cmd",
"atty",
"bincode",
@ -95,6 +85,7 @@ dependencies = [
"globset",
"grep-cli",
"nix",
"nu-ansi-term",
"once_cell",
"path_abs",
"plist",
@ -747,6 +738,15 @@ version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
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]]
name = "num-traits"
version = "0.2.15"

View file

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

View file

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

View file

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

View file

@ -1,7 +1,7 @@
#[cfg(feature = "git")]
use crate::diff::LineChange;
use crate::printer::{Colors, InteractivePrinter};
use ansi_term::Style;
use nu_ansi_term::Style;
#[derive(Debug, Clone)]
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 fn default_error_handler(error: &Error, output: &mut dyn Write) {
use ansi_term::Colour::Red;
use nu_ansi_term::Color::Red;
match error {
Error::Io(ref io_error) if io_error.kind() == ::std::io::ErrorKind::BrokenPipe => {

View file

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

View file

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

View file

@ -1,9 +1,9 @@
use ansi_term::Color::{self, Fixed, RGB};
use ansi_term::{self, Style};
use nu_ansi_term::Color::{self, Fixed, Rgb};
use nu_ansi_term::{self, Style};
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 {
// Themes can specify one of the user-configurable terminal colors by
// 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.
None
} else if true_color {
Some(RGB(color.r, color.g, color.b))
Some(Rgb(color.r, color.g, color.b))
} else {
Some(Fixed(ansi_colours::ansi256_from_rgb((
color.r, color.g, color.b,