From c6d8c21e805adee457d0fdce3e8b04e184f7a3f8 Mon Sep 17 00:00:00 2001 From: Ben S Date: Sun, 10 May 2015 18:03:15 +0100 Subject: [PATCH] Finally, do the same for the Git column. --- src/colours.rs | 4 +--- src/dir.rs | 4 ++-- src/feature/git.rs | 7 +++---- src/file.rs | 12 ++++-------- src/output/details.rs | 4 ++-- 5 files changed, 12 insertions(+), 19 deletions(-) diff --git a/src/colours.rs b/src/colours.rs index 60465f7..352b13c 100644 --- a/src/colours.rs +++ b/src/colours.rs @@ -2,8 +2,6 @@ use ansi_term::Style; use ansi_term::Style::Plain; use ansi_term::Colour::{Red, Green, Yellow, Blue, Cyan, Purple, Fixed}; -use file::GREY; - use std::default::Default; #[derive(Clone, Copy, Debug, Default, PartialEq)] @@ -112,7 +110,7 @@ impl Colours { crypto: Fixed(109).normal(), document: Fixed(105).normal(), compressed: Red.normal(), - temp: GREY.normal(), + temp: Fixed(244).normal(), immediate: Yellow.bold().underline(), compiled: Fixed(137).normal(), }, diff --git a/src/dir.rs b/src/dir.rs index 3685329..9433829 100644 --- a/src/dir.rs +++ b/src/dir.rs @@ -1,6 +1,6 @@ use colours::Colours; use feature::Git; -use file::{File, GREY}; +use file::File; use std::io; use std::fs; @@ -69,7 +69,7 @@ impl Dir { match (&self.git, prefix_lookup) { (&Some(ref git), false) => git.status(colours, path), (&Some(ref git), true) => git.dir_status(colours, path), - (&None, _) => GREY.paint("--").to_string(), + (&None, _) => colours.punctuation.paint("--").to_string(), } } } diff --git a/src/feature/git.rs b/src/feature/git.rs index 03e6a5d..db9cc0e 100644 --- a/src/feature/git.rs +++ b/src/feature/git.rs @@ -4,7 +4,6 @@ use ansi_term::{ANSIString, ANSIStrings}; use git2; use colours::Colours; -use file::GREY; /// Container of Git statuses for all the files in this folder's Git repository. pub struct Git { @@ -35,7 +34,7 @@ impl Git { .find(|p| p.0.as_path() == path); match status { Some(&(_, s)) => ANSIStrings( &[Git::index_status(c, s), Git::working_tree_status(c, s) ]).to_string(), - None => GREY.paint("--").to_string(), + None => c.punctuation.paint("--").to_string(), } } @@ -58,7 +57,7 @@ impl Git { s if s.contains(git2::STATUS_WT_DELETED) => colours.git.deleted.paint("D"), s if s.contains(git2::STATUS_WT_RENAMED) => colours.git.renamed.paint("R"), s if s.contains(git2::STATUS_WT_TYPECHANGE) => colours.git.typechange.paint("T"), - _ => GREY.paint("-"), + _ => colours.punctuation.paint("-"), } } @@ -71,7 +70,7 @@ impl Git { s if s.contains(git2::STATUS_INDEX_DELETED) => colours.git.deleted.paint("D"), s if s.contains(git2::STATUS_INDEX_RENAMED) => colours.git.renamed.paint("R"), s if s.contains(git2::STATUS_INDEX_TYPECHANGE) => colours.git.typechange.paint("T"), - _ => GREY.paint("-"), + _ => colours.punctuation.paint("-"), } } } diff --git a/src/file.rs b/src/file.rs index 07fd30a..b179e76 100644 --- a/src/file.rs +++ b/src/file.rs @@ -7,7 +7,7 @@ use std::os::unix::raw::mode_t; use std::os::unix::fs::{MetadataExt, PermissionsExt}; use std::path::{Component, Path, PathBuf}; -use ansi_term::{ANSIString, ANSIStrings, Colour, Style}; +use ansi_term::{ANSIString, ANSIStrings, Style}; use ansi_term::Style::Plain; use ansi_term::Colour::Fixed; @@ -31,10 +31,6 @@ use options::{SizeFormat, TimeType}; use output::details::UserLocale; use feature::Attribute; -/// This grey value is directly in between white and black, so it's guaranteed -/// to show up on either backgrounded terminal. -pub static GREY: Colour = Fixed(244); - /// A **File** is a wrapper around one of Rust's Path objects, along with /// associated data about the file. /// @@ -316,7 +312,7 @@ impl<'a> File<'a> { /// cluttered with numbers. fn file_size(&self, colours: &Colours, size_format: SizeFormat, locale: &locale::Numeric) -> Cell { if self.is_directory() { - Cell { text: GREY.paint("-").to_string(), length: 1 } + Cell { text: colours.punctuation.paint("-").to_string(), length: 1 } } else { let result = match size_format { @@ -425,7 +421,7 @@ impl<'a> File<'a> { style.paint(character) } else { - GREY.paint("-") + Fixed(244).paint("-") } } @@ -477,7 +473,7 @@ impl<'a> File<'a> { fn git_status(&self, colours: &Colours) -> Cell { let status = match self.dir { - None => GREY.paint("--").to_string(), + None => colours.punctuation.paint("--").to_string(), Some(d) => { let cwd = match current_dir() { Err(_) => Path::new(".").join(&self.path), diff --git a/src/output/details.rs b/src/output/details.rs index 6c0bbb1..ebe43ae 100644 --- a/src/output/details.rs +++ b/src/output/details.rs @@ -2,7 +2,7 @@ use colours::Colours; use column::{Alignment, Column, Cell}; use feature::Attribute; use dir::Dir; -use file::{File, GREY}; +use file::File; use options::{Columns, FileFilter, RecurseOptions}; use users::OSUsers; @@ -193,7 +193,7 @@ impl Table { stack[row.depth] = if row.last { TreePart::Corner } else { TreePart::Edge }; for i in 1 .. row.depth + 1 { - print!("{}", GREY.paint(stack[i].ascii_art())); + print!("{}", self.colours.punctuation.paint(stack[i].ascii_art())); } if row.children {