Finally, do the same for the Git column.

This commit is contained in:
Ben S 2015-05-10 18:03:15 +01:00
parent d9319c48b4
commit c6d8c21e80
5 changed files with 12 additions and 19 deletions

View File

@ -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(),
},

View File

@ -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(),
}
}
}

View File

@ -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("-"),
}
}
}

View File

@ -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),

View File

@ -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 {