diff options
-rw-r--r-- | src/filetype.rs | 26 | ||||
-rw-r--r-- | src/main.rs | 1 | ||||
-rw-r--r-- | src/options.rs | 2 | ||||
-rw-r--r-- | src/output/colours.rs (renamed from src/colours.rs) | 0 | ||||
-rw-r--r-- | src/output/details.rs | 2 | ||||
-rw-r--r-- | src/output/grid.rs | 8 | ||||
-rw-r--r-- | src/output/lines.rs | 6 | ||||
-rw-r--r-- | src/output/mod.rs | 29 |
8 files changed, 35 insertions, 39 deletions
diff --git a/src/filetype.rs b/src/filetype.rs index ed2f369..b8427d4 100644 --- a/src/filetype.rs +++ b/src/filetype.rs @@ -1,31 +1,7 @@ -use ansi_term::Style; - use file::File; -use colours::Colours; - - -pub fn file_colour(colours: &Colours, file: &File) -> Style { - 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, - } -} -trait FileTypes { +pub trait FileTypes { fn is_immediate(&self) -> bool; fn is_image(&self) -> bool; fn is_video(&self) -> bool; diff --git a/src/main.rs b/src/main.rs index 11a2fc0..e290853 100644 --- a/src/main.rs +++ b/src/main.rs @@ -26,7 +26,6 @@ use dir::Dir; use file::File; use options::{Options, View}; -mod colours; mod dir; mod feature; mod file; diff --git a/src/options.rs b/src/options.rs index adffef1..c9baa2e 100644 --- a/src/options.rs +++ b/src/options.rs @@ -7,10 +7,10 @@ use std::os::unix::fs::MetadataExt; use getopts; use natord; -use colours::Colours; use feature::xattr; use file::File; use output::{Grid, Details, GridDetails, Lines}; +use output::Colours; use output::column::{Columns, TimeTypes, SizeFormat}; use term::dimensions; diff --git a/src/colours.rs b/src/output/colours.rs index 97ccd87..97ccd87 100644 --- a/src/colours.rs +++ b/src/output/colours.rs diff --git a/src/output/details.rs b/src/output/details.rs index 0b45b7b..0a65fe6 100644 --- a/src/output/details.rs +++ b/src/output/details.rs @@ -118,12 +118,12 @@ use std::string::ToString; use std::ops::Add; use std::iter::repeat; -use colours::Colours; use dir::Dir; use feature::xattr::{Attribute, FileAttributes}; use file::fields as f; use file::File; use options::{FileFilter, RecurseOptions}; +use output::colours::Colours; use output::column::{Alignment, Column, Columns, SizeFormat}; use output::cell::{TextCell, DisplayWidth}; diff --git a/src/output/grid.rs b/src/output/grid.rs index 69001bf..f944fbb 100644 --- a/src/output/grid.rs +++ b/src/output/grid.rs @@ -1,9 +1,9 @@ -use colours::Colours; +use term_grid as grid; + use file::File; -use filetype::file_colour; use output::DisplayWidth; - -use term_grid as grid; +use output::colours::Colours; +use super::file_colour; #[derive(PartialEq, Debug, Copy, Clone)] diff --git a/src/output/lines.rs b/src/output/lines.rs index 39ef2c3..07c4351 100644 --- a/src/output/lines.rs +++ b/src/output/lines.rs @@ -1,9 +1,9 @@ -use colours::Colours; -use file::File; - use ansi_term::ANSIStrings; +use file::File; + use super::filename; +use super::colours::Colours; #[derive(Clone, Copy, Debug, PartialEq)] 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 |