From 6ac5df904b984396d860c0f95d1d80fb18cf7db3 Mon Sep 17 00:00:00 2001 From: David Knaack Date: Sun, 4 Sep 2022 18:44:54 +0200 Subject: refactor: replace `ansi_term` with `nu_ansi_term` (#4339) --- src/segment.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/segment.rs') diff --git a/src/segment.rs b/src/segment.rs index cab7835d5..ff03ff4c8 100644 --- a/src/segment.rs +++ b/src/segment.rs @@ -1,5 +1,5 @@ use crate::print::{Grapheme, UnicodeWidthGraphemes}; -use ansi_term::{ANSIString, Style}; +use nu_ansi_term::{AnsiString, Style}; use std::fmt; use unicode_segmentation::UnicodeSegmentation; @@ -14,11 +14,11 @@ pub struct TextSegment { } impl TextSegment { - // Returns the ANSIString of the segment value - fn ansi_string(&self) -> ANSIString { + // Returns the AnsiString of the segment value + fn ansi_string(&self) -> AnsiString { match self.style { Some(style) => style.paint(&self.value), - None => ANSIString::from(&self.value), + None => AnsiString::from(&self.value), } } } @@ -34,8 +34,8 @@ pub struct FillSegment { } impl FillSegment { - // Returns the ANSIString of the segment value, not including its prefix and suffix - pub fn ansi_string(&self, width: Option) -> ANSIString { + // Returns the AnsiString of the segment value, not including its prefix and suffix + pub fn ansi_string(&self, width: Option) -> AnsiString { let s = match width { Some(w) => self .value @@ -54,7 +54,7 @@ impl FillSegment { }; match self.style { Some(style) => style.paint(s), - None => ANSIString::from(s), + None => AnsiString::from(s), } } } @@ -62,7 +62,7 @@ impl FillSegment { #[cfg(test)] mod fill_seg_tests { use super::FillSegment; - use ansi_term::Color; + use nu_ansi_term::Color; #[test] fn ansi_string_width() { @@ -158,12 +158,12 @@ impl Segment { } } - // Returns the ANSIString of the segment value, not including its prefix and suffix - pub fn ansi_string(&self) -> ANSIString { + // Returns the AnsiString of the segment value, not including its prefix and suffix + pub fn ansi_string(&self) -> AnsiString { match self { Self::Fill(fs) => fs.ansi_string(None), Self::Text(ts) => ts.ansi_string(), - Self::LineTerm => ANSIString::from(LINE_TERMINATOR_STRING), + Self::LineTerm => AnsiString::from(LINE_TERMINATOR_STRING), } } -- cgit v1.2.3