diff options
Diffstat (limited to 'src/output/mod.rs')
-rw-r--r-- | src/output/mod.rs | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/src/output/mod.rs b/src/output/mod.rs index d1c7e14..f095a79 100644 --- a/src/output/mod.rs +++ b/src/output/mod.rs @@ -1,14 +1,13 @@ use ansi_term::Style; -use colours::Colours; use file::File; -use filetype::file_colour; pub use self::cell::{TextCell, TextCellContents, DisplayWidth}; +pub use self::colours::Colours; pub use self::details::Details; +pub use self::grid_details::GridDetails; pub use self::grid::Grid; pub use self::lines::Lines; -pub use self::grid_details::GridDetails; mod grid; pub mod details; @@ -16,7 +15,7 @@ mod lines; mod grid_details; pub mod column; mod cell; - +mod colours; pub fn filename(file: File, colours: &Colours, links: bool) -> TextCellContents { if links && file.is_link() { @@ -49,3 +48,25 @@ fn symlink_filename(file: File, colours: &Colours) -> TextCellContents { ].into(), } } + +pub fn file_colour(colours: &Colours, file: &File) -> Style { + use filetype::FileTypes; + + match file { + f if f.is_directory() => colours.filetypes.directory, + f if f.is_executable_file() => colours.filetypes.executable, + f if f.is_link() => colours.filetypes.symlink, + f if !f.is_file() => colours.filetypes.special, + f if f.is_immediate() => colours.filetypes.immediate, + f if f.is_image() => colours.filetypes.image, + f if f.is_video() => colours.filetypes.video, + f if f.is_music() => colours.filetypes.music, + f if f.is_lossless() => colours.filetypes.lossless, + f if f.is_crypto() => colours.filetypes.crypto, + f if f.is_document() => colours.filetypes.document, + f if f.is_compressed() => colours.filetypes.compressed, + f if f.is_temp() => colours.filetypes.temp, + f if f.is_compiled() => colours.filetypes.compiled, + _ => colours.filetypes.normal, + } +}
\ No newline at end of file |