1
0
mirror of https://github.com/sharkdp/bat.git synced 2025-09-02 03:12:25 +01:00

Use nu-ansi-term instead of ansi_term

The `nu-ansi-term` crate is a fork of `ansi_term` which is maintained by
the Nushell project.
This commit is contained in:
Constantin Nickel
2023-03-23 10:47:38 +01:00
parent d20405b975
commit da3aa4e2fd
9 changed files with 23 additions and 23 deletions

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,