diff --git a/src/info/filetype.rs b/src/info/filetype.rs index 77a9654..608aff7 100644 --- a/src/info/filetype.rs +++ b/src/info/filetype.rs @@ -7,6 +7,7 @@ use fs::File; +#[derive(Debug)] pub struct FileExtensions; impl FileExtensions { diff --git a/src/options/view.rs b/src/options/view.rs index 24b8eec..03ae3f0 100644 --- a/src/options/view.rs +++ b/src/options/view.rs @@ -2,6 +2,7 @@ use std::env::var_os; use getopts; +use info::filetype::FileExtensions; use output::Colours; use output::{grid, details}; use output::table::{TimeTypes, Environment, SizeFormat, Options as TableOptions}; @@ -373,7 +374,8 @@ impl Colours { impl FileStyle { fn deduce(matches: &getopts::Matches) -> FileStyle { let classify = Classify::deduce(matches); - FileStyle { classify } + let exts = FileExtensions; + FileStyle { classify, exts } } } diff --git a/src/output/file_name.rs b/src/output/file_name.rs index 79628ee..bfb5b31 100644 --- a/src/output/file_name.rs +++ b/src/output/file_name.rs @@ -10,22 +10,25 @@ use output::cell::TextCellContents; /// Basically a file name factory. -#[derive(PartialEq, Debug)] +#[derive(Debug)] pub struct FileStyle { /// Whether to append file class characters to file names. pub classify: Classify, + + /// Mapping of file extensions to colours, to highlight regular files. + pub exts: FileExtensions, } impl FileStyle { /// Create a new `FileName` that prints the given file’s name, painting it /// with the remaining arguments. - pub fn for_file<'a, 'dir>(&self, file: &'a File<'dir>, colours: &'a Colours) -> FileName<'a, 'dir> { + pub fn for_file<'a, 'dir>(&'a self, file: &'a File<'dir>, colours: &'a Colours) -> FileName<'a, 'dir> { FileName { file, colours, - exts: FileExtensions, link_style: LinkStyle::JustFilenames, + exts: &self.exts, classify: self.classify, target: if file.is_link() { Some(file.link_target()) } else { None } @@ -90,7 +93,7 @@ pub struct FileName<'a, 'dir: 'a> { classify: Classify, /// Mapping of file extensions to colours, to highlight regular files. - exts: FileExtensions, + exts: &'a FileExtensions, } @@ -142,7 +145,7 @@ impl<'a, 'dir> FileName<'a, 'dir> { target: None, link_style: LinkStyle::FullLinkPaths, classify: Classify::JustFilenames, - exts: FileExtensions, + exts: self.exts, }; for bit in target.coloured_file_name() {