mirror of
https://github.com/Llewellynvdm/exa.git
synced 2024-11-26 22:06:26 +00:00
Get the list of file extensions from the Options
The FileExtensions in the FileName is now a reference to the one in the original FileStyle, which gets put there in the options module. This allows the extensions to be derived from the user, somehow, in the future when that part’s done.
This commit is contained in:
parent
0d8d723408
commit
c29170e345
@ -7,6 +7,7 @@
|
|||||||
use fs::File;
|
use fs::File;
|
||||||
|
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct FileExtensions;
|
pub struct FileExtensions;
|
||||||
|
|
||||||
impl FileExtensions {
|
impl FileExtensions {
|
||||||
|
@ -2,6 +2,7 @@ use std::env::var_os;
|
|||||||
|
|
||||||
use getopts;
|
use getopts;
|
||||||
|
|
||||||
|
use info::filetype::FileExtensions;
|
||||||
use output::Colours;
|
use output::Colours;
|
||||||
use output::{grid, details};
|
use output::{grid, details};
|
||||||
use output::table::{TimeTypes, Environment, SizeFormat, Options as TableOptions};
|
use output::table::{TimeTypes, Environment, SizeFormat, Options as TableOptions};
|
||||||
@ -373,7 +374,8 @@ impl Colours {
|
|||||||
impl FileStyle {
|
impl FileStyle {
|
||||||
fn deduce(matches: &getopts::Matches) -> FileStyle {
|
fn deduce(matches: &getopts::Matches) -> FileStyle {
|
||||||
let classify = Classify::deduce(matches);
|
let classify = Classify::deduce(matches);
|
||||||
FileStyle { classify }
|
let exts = FileExtensions;
|
||||||
|
FileStyle { classify, exts }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,22 +10,25 @@ use output::cell::TextCellContents;
|
|||||||
|
|
||||||
|
|
||||||
/// Basically a file name factory.
|
/// Basically a file name factory.
|
||||||
#[derive(PartialEq, Debug)]
|
#[derive(Debug)]
|
||||||
pub struct FileStyle {
|
pub struct FileStyle {
|
||||||
|
|
||||||
/// Whether to append file class characters to file names.
|
/// Whether to append file class characters to file names.
|
||||||
pub classify: Classify,
|
pub classify: Classify,
|
||||||
|
|
||||||
|
/// Mapping of file extensions to colours, to highlight regular files.
|
||||||
|
pub exts: FileExtensions,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FileStyle {
|
impl FileStyle {
|
||||||
|
|
||||||
/// Create a new `FileName` that prints the given file’s name, painting it
|
/// Create a new `FileName` that prints the given file’s name, painting it
|
||||||
/// with the remaining arguments.
|
/// 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 {
|
FileName {
|
||||||
file, colours,
|
file, colours,
|
||||||
exts: FileExtensions,
|
|
||||||
link_style: LinkStyle::JustFilenames,
|
link_style: LinkStyle::JustFilenames,
|
||||||
|
exts: &self.exts,
|
||||||
classify: self.classify,
|
classify: self.classify,
|
||||||
target: if file.is_link() { Some(file.link_target()) }
|
target: if file.is_link() { Some(file.link_target()) }
|
||||||
else { None }
|
else { None }
|
||||||
@ -90,7 +93,7 @@ pub struct FileName<'a, 'dir: 'a> {
|
|||||||
classify: Classify,
|
classify: Classify,
|
||||||
|
|
||||||
/// Mapping of file extensions to colours, to highlight regular files.
|
/// 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,
|
target: None,
|
||||||
link_style: LinkStyle::FullLinkPaths,
|
link_style: LinkStyle::FullLinkPaths,
|
||||||
classify: Classify::JustFilenames,
|
classify: Classify::JustFilenames,
|
||||||
exts: FileExtensions,
|
exts: self.exts,
|
||||||
};
|
};
|
||||||
|
|
||||||
for bit in target.coloured_file_name() {
|
for bit in target.coloured_file_name() {
|
||||||
|
Loading…
Reference in New Issue
Block a user