summaryrefslogtreecommitdiffstats
path: root/vendor/nu-ansi-term/src/difference.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--vendor/nu-ansi-term/src/difference.rs (renamed from vendor/ansi_term/src/difference.rs)25
1 files changed, 10 insertions, 15 deletions
diff --git a/vendor/ansi_term/src/difference.rs b/vendor/nu-ansi-term/src/difference.rs
index b0de07f7e..beee8ea25 100644
--- a/vendor/ansi_term/src/difference.rs
+++ b/vendor/nu-ansi-term/src/difference.rs
@@ -1,11 +1,9 @@
use super::Style;
-
-/// When printing out one coloured string followed by another, use one of
+/// When printing out one colored string followed by another, use one of
/// these rules to figure out which *extra* control codes need to be sent.
#[derive(PartialEq, Clone, Copy, Debug)]
pub enum Difference {
-
/// Print out the control codes specified by this style to end up looking
/// like the second string's styles.
ExtraStyles(Style),
@@ -16,19 +14,17 @@ pub enum Difference {
/// The before style is exactly the same as the after style, so no further
/// control codes need to be printed.
- NoDifference,
+ Empty,
}
-
impl Difference {
-
/// Compute the 'style difference' required to turn an existing style into
/// the given, second style.
///
/// For example, to turn green text into green bold text, it's redundant
/// to write a reset command then a second green+bold command, instead of
/// just writing one bold command. This method should see that both styles
- /// use the foreground colour green, and reduce it to a single command.
+ /// use the foreground color green, and reduce it to a single command.
///
/// This method returns an enum value because it's not actually always
/// possible to turn one style into another: for example, text could be
@@ -44,7 +40,7 @@ impl Difference {
// it commented out for now, and defaulting to Reset.
if first == next {
- return NoDifference;
+ return Empty;
}
// Cannot un-bold, so must Reset.
@@ -137,13 +133,12 @@ impl Difference {
}
}
-
#[cfg(test)]
mod test {
- use super::*;
use super::Difference::*;
- use style::Colour::*;
- use style::Style;
+ use super::*;
+ use crate::style::Color::*;
+ use crate::style::Style;
fn style() -> Style {
Style::new()
@@ -158,12 +153,12 @@ mod test {
};
}
- test!(nothing: Green.normal(); Green.normal() => NoDifference);
+ test!(nothing: Green.normal(); Green.normal() => Empty);
test!(uppercase: Green.normal(); Green.bold() => ExtraStyles(style().bold()));
test!(lowercase: Green.bold(); Green.normal() => Reset);
- test!(nothing2: Green.bold(); Green.bold() => NoDifference);
+ test!(nothing2: Green.bold(); Green.bold() => Empty);
- test!(colour_change: Red.normal(); Blue.normal() => ExtraStyles(Blue.normal()));
+ test!(color_change: Red.normal(); Blue.normal() => ExtraStyles(Blue.normal()));
test!(addition_of_blink: style(); style().blink() => ExtraStyles(style().blink()));
test!(addition_of_dimmed: style(); style().dimmed() => ExtraStyles(style().dimmed()));