mirror of
https://github.com/Llewellynvdm/exa.git
synced 2024-12-29 02:53:06 +00:00
Finally, do the same for the Git column.
This commit is contained in:
parent
d9319c48b4
commit
c6d8c21e80
@ -2,8 +2,6 @@ use ansi_term::Style;
|
|||||||
use ansi_term::Style::Plain;
|
use ansi_term::Style::Plain;
|
||||||
use ansi_term::Colour::{Red, Green, Yellow, Blue, Cyan, Purple, Fixed};
|
use ansi_term::Colour::{Red, Green, Yellow, Blue, Cyan, Purple, Fixed};
|
||||||
|
|
||||||
use file::GREY;
|
|
||||||
|
|
||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Default, PartialEq)]
|
#[derive(Clone, Copy, Debug, Default, PartialEq)]
|
||||||
@ -112,7 +110,7 @@ impl Colours {
|
|||||||
crypto: Fixed(109).normal(),
|
crypto: Fixed(109).normal(),
|
||||||
document: Fixed(105).normal(),
|
document: Fixed(105).normal(),
|
||||||
compressed: Red.normal(),
|
compressed: Red.normal(),
|
||||||
temp: GREY.normal(),
|
temp: Fixed(244).normal(),
|
||||||
immediate: Yellow.bold().underline(),
|
immediate: Yellow.bold().underline(),
|
||||||
compiled: Fixed(137).normal(),
|
compiled: Fixed(137).normal(),
|
||||||
},
|
},
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use colours::Colours;
|
use colours::Colours;
|
||||||
use feature::Git;
|
use feature::Git;
|
||||||
use file::{File, GREY};
|
use file::File;
|
||||||
|
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
@ -69,7 +69,7 @@ impl Dir {
|
|||||||
match (&self.git, prefix_lookup) {
|
match (&self.git, prefix_lookup) {
|
||||||
(&Some(ref git), false) => git.status(colours, path),
|
(&Some(ref git), false) => git.status(colours, path),
|
||||||
(&Some(ref git), true) => git.dir_status(colours, path),
|
(&Some(ref git), true) => git.dir_status(colours, path),
|
||||||
(&None, _) => GREY.paint("--").to_string(),
|
(&None, _) => colours.punctuation.paint("--").to_string(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ use ansi_term::{ANSIString, ANSIStrings};
|
|||||||
use git2;
|
use git2;
|
||||||
|
|
||||||
use colours::Colours;
|
use colours::Colours;
|
||||||
use file::GREY;
|
|
||||||
|
|
||||||
/// Container of Git statuses for all the files in this folder's Git repository.
|
/// Container of Git statuses for all the files in this folder's Git repository.
|
||||||
pub struct Git {
|
pub struct Git {
|
||||||
@ -35,7 +34,7 @@ impl Git {
|
|||||||
.find(|p| p.0.as_path() == path);
|
.find(|p| p.0.as_path() == path);
|
||||||
match status {
|
match status {
|
||||||
Some(&(_, s)) => ANSIStrings( &[Git::index_status(c, s), Git::working_tree_status(c, s) ]).to_string(),
|
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_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_RENAMED) => colours.git.renamed.paint("R"),
|
||||||
s if s.contains(git2::STATUS_WT_TYPECHANGE) => colours.git.typechange.paint("T"),
|
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_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_RENAMED) => colours.git.renamed.paint("R"),
|
||||||
s if s.contains(git2::STATUS_INDEX_TYPECHANGE) => colours.git.typechange.paint("T"),
|
s if s.contains(git2::STATUS_INDEX_TYPECHANGE) => colours.git.typechange.paint("T"),
|
||||||
_ => GREY.paint("-"),
|
_ => colours.punctuation.paint("-"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
12
src/file.rs
12
src/file.rs
@ -7,7 +7,7 @@ use std::os::unix::raw::mode_t;
|
|||||||
use std::os::unix::fs::{MetadataExt, PermissionsExt};
|
use std::os::unix::fs::{MetadataExt, PermissionsExt};
|
||||||
use std::path::{Component, Path, PathBuf};
|
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::Style::Plain;
|
||||||
use ansi_term::Colour::Fixed;
|
use ansi_term::Colour::Fixed;
|
||||||
|
|
||||||
@ -31,10 +31,6 @@ use options::{SizeFormat, TimeType};
|
|||||||
use output::details::UserLocale;
|
use output::details::UserLocale;
|
||||||
use feature::Attribute;
|
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
|
/// A **File** is a wrapper around one of Rust's Path objects, along with
|
||||||
/// associated data about the file.
|
/// associated data about the file.
|
||||||
///
|
///
|
||||||
@ -316,7 +312,7 @@ impl<'a> File<'a> {
|
|||||||
/// cluttered with numbers.
|
/// cluttered with numbers.
|
||||||
fn file_size(&self, colours: &Colours, size_format: SizeFormat, locale: &locale::Numeric) -> Cell {
|
fn file_size(&self, colours: &Colours, size_format: SizeFormat, locale: &locale::Numeric) -> Cell {
|
||||||
if self.is_directory() {
|
if self.is_directory() {
|
||||||
Cell { text: GREY.paint("-").to_string(), length: 1 }
|
Cell { text: colours.punctuation.paint("-").to_string(), length: 1 }
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
let result = match size_format {
|
let result = match size_format {
|
||||||
@ -425,7 +421,7 @@ impl<'a> File<'a> {
|
|||||||
style.paint(character)
|
style.paint(character)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
GREY.paint("-")
|
Fixed(244).paint("-")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -477,7 +473,7 @@ impl<'a> File<'a> {
|
|||||||
|
|
||||||
fn git_status(&self, colours: &Colours) -> Cell {
|
fn git_status(&self, colours: &Colours) -> Cell {
|
||||||
let status = match self.dir {
|
let status = match self.dir {
|
||||||
None => GREY.paint("--").to_string(),
|
None => colours.punctuation.paint("--").to_string(),
|
||||||
Some(d) => {
|
Some(d) => {
|
||||||
let cwd = match current_dir() {
|
let cwd = match current_dir() {
|
||||||
Err(_) => Path::new(".").join(&self.path),
|
Err(_) => Path::new(".").join(&self.path),
|
||||||
|
@ -2,7 +2,7 @@ use colours::Colours;
|
|||||||
use column::{Alignment, Column, Cell};
|
use column::{Alignment, Column, Cell};
|
||||||
use feature::Attribute;
|
use feature::Attribute;
|
||||||
use dir::Dir;
|
use dir::Dir;
|
||||||
use file::{File, GREY};
|
use file::File;
|
||||||
use options::{Columns, FileFilter, RecurseOptions};
|
use options::{Columns, FileFilter, RecurseOptions};
|
||||||
use users::OSUsers;
|
use users::OSUsers;
|
||||||
|
|
||||||
@ -193,7 +193,7 @@ impl Table {
|
|||||||
stack[row.depth] = if row.last { TreePart::Corner } else { TreePart::Edge };
|
stack[row.depth] = if row.last { TreePart::Corner } else { TreePart::Edge };
|
||||||
|
|
||||||
for i in 1 .. row.depth + 1 {
|
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 {
|
if row.children {
|
||||||
|
Loading…
Reference in New Issue
Block a user