mirror of
https://github.com/Llewellynvdm/exa.git
synced 2024-11-10 23:00:56 +00:00
A Git status character should render itself, too
This commit is contained in:
parent
5f497da85d
commit
f0cf5b4538
@ -1,3 +1,5 @@
|
||||
use ansi_term::ANSIString;
|
||||
|
||||
use output::cell::{TextCell, DisplayWidth};
|
||||
use output::colours::Colours;
|
||||
use fs::fields as f;
|
||||
@ -5,25 +7,29 @@ use fs::fields as f;
|
||||
|
||||
impl f::Git {
|
||||
pub fn render(&self, colours: &Colours) -> TextCell {
|
||||
let git_char = |status| match status {
|
||||
&f::GitStatus::NotModified => colours.punctuation.paint("-"),
|
||||
&f::GitStatus::New => colours.git.new.paint("N"),
|
||||
&f::GitStatus::Modified => colours.git.modified.paint("M"),
|
||||
&f::GitStatus::Deleted => colours.git.deleted.paint("D"),
|
||||
&f::GitStatus::Renamed => colours.git.renamed.paint("R"),
|
||||
&f::GitStatus::TypeChange => colours.git.typechange.paint("T"),
|
||||
};
|
||||
|
||||
TextCell {
|
||||
width: DisplayWidth::from(2),
|
||||
contents: vec![
|
||||
git_char(&self.staged),
|
||||
git_char(&self.unstaged)
|
||||
self.staged.render(colours),
|
||||
self.unstaged.render(colours),
|
||||
].into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl f::GitStatus {
|
||||
fn render(&self, colours: &Colours) -> ANSIString<'static> {
|
||||
match *self {
|
||||
f::GitStatus::NotModified => colours.punctuation.paint("-"),
|
||||
f::GitStatus::New => colours.git.new.paint("N"),
|
||||
f::GitStatus::Modified => colours.git.modified.paint("M"),
|
||||
f::GitStatus::Deleted => colours.git.deleted.paint("D"),
|
||||
f::GitStatus::Renamed => colours.git.renamed.paint("R"),
|
||||
f::GitStatus::TypeChange => colours.git.typechange.paint("T"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod test {
|
||||
|
Loading…
Reference in New Issue
Block a user