mirror of
https://github.com/Llewellynvdm/exa.git
synced 2024-11-26 22:06:26 +00:00
Monday morning Blocks extraction
This commit is contained in:
parent
eec81c4f48
commit
094e660003
44
src/output/render/blocks.rs
Normal file
44
src/output/render/blocks.rs
Normal file
@ -0,0 +1,44 @@
|
||||
use output::cell::TextCell;
|
||||
use output::colours::Colours;
|
||||
use fs::fields as f;
|
||||
|
||||
|
||||
impl f::Blocks {
|
||||
pub fn render(&self, colours: &Colours) -> TextCell {
|
||||
match *self {
|
||||
f::Blocks::Some(ref blk) => TextCell::paint(colours.blocks, blk.to_string()),
|
||||
f::Blocks::None => TextCell::blank(colours.punctuation),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod test {
|
||||
use output::details::Details;
|
||||
use output::cell::TextCell;
|
||||
use fs::fields as f;
|
||||
|
||||
use ansi_term::Colour::*;
|
||||
|
||||
|
||||
#[test]
|
||||
fn blocklessness() {
|
||||
let mut details = Details::default();
|
||||
details.colours.punctuation = Green.italic();
|
||||
|
||||
let blox = f::Blocks::None;
|
||||
let expected = TextCell::blank(Green.italic());
|
||||
assert_eq!(expected, blox.render(&details.colours).into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn blockfulity() {
|
||||
let mut details = Details::default();
|
||||
details.colours.blocks = Red.blink();
|
||||
|
||||
let blox = f::Blocks::Some(3005);
|
||||
let expected = TextCell::paint_str(Red.blink(), "3005");
|
||||
assert_eq!(expected, blox.render(&details.colours).into());
|
||||
}
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
mod blocks;
|
||||
mod git;
|
||||
mod groups;
|
||||
mod links;
|
||||
@ -14,17 +15,6 @@ use datetime::fmt::DateFormat;
|
||||
use locale;
|
||||
|
||||
|
||||
|
||||
impl f::Blocks {
|
||||
pub fn render(&self, colours: &Colours) -> TextCell {
|
||||
match *self {
|
||||
f::Blocks::Some(ref blk) => TextCell::paint(colours.blocks, blk.to_string()),
|
||||
f::Blocks::None => TextCell::blank(colours.punctuation),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl f::Inode {
|
||||
pub fn render(&self, colours: &Colours) -> TextCell {
|
||||
TextCell::paint(colours.inode, self.0.to_string())
|
||||
|
Loading…
Reference in New Issue
Block a user