From 88fecb7b269274c7874bbe8064fe2c6ad10cdd3a Mon Sep 17 00:00:00 2001 From: Benjamin Sago Date: Sun, 7 May 2017 10:44:09 +0100 Subject: [PATCH 1/5] Make the link target a field --- src/output/file_name.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/output/file_name.rs b/src/output/file_name.rs index 63b5a80..d2432ae 100644 --- a/src/output/file_name.rs +++ b/src/output/file_name.rs @@ -11,13 +11,17 @@ use output::cell::TextCellContents; pub struct FileName<'a, 'dir: 'a> { file: &'a File<'dir>, colours: &'a Colours, + target: Option>, } impl<'a, 'dir> FileName<'a, 'dir> { pub fn new(file: &'a File<'dir>, colours: &'a Colours) -> FileName<'a, 'dir> { + let target = if file.is_link() { Some(file.link_target()) } + else { None }; FileName { file: file, colours: colours, + target: target, } } @@ -36,9 +40,9 @@ impl<'a, 'dir> FileName<'a, 'dir> { } } - if links && self.file.is_link() { - match self.file.link_target() { - FileTarget::Ok(target) => { + if links && self.target.is_some() { + match self.target.as_ref().unwrap() { + &FileTarget::Ok(ref target) => { bits.push(Style::default().paint(" ")); bits.push(self.colours.punctuation.paint("->")); bits.push(Style::default().paint(" ")); @@ -55,16 +59,16 @@ impl<'a, 'dir> FileName<'a, 'dir> { } }, - FileTarget::Broken(broken_path) => { + &FileTarget::Broken(ref broken_path) => { bits.push(Style::default().paint(" ")); bits.push(self.colours.broken_arrow.paint("->")); bits.push(Style::default().paint(" ")); escape(broken_path.display().to_string(), &mut bits, self.colours.broken_filename, self.colours.control_char.underline()); }, - FileTarget::Err(_) => { + &FileTarget::Err(_) => { // Do nothing -- the error gets displayed on the next line - } + }, } } else if classify { From ccf8d44058fc607370492cb3ca2d43af8936ecc4 Mon Sep 17 00:00:00 2001 From: Benjamin Sago Date: Sun, 7 May 2017 14:08:36 +0100 Subject: [PATCH 2/5] Replace the links boolean with an enum field --- src/output/details.rs | 8 ++++---- src/output/file_name.rs | 24 ++++++++++++++++-------- src/output/grid.rs | 6 +++--- src/output/grid_details.rs | 4 +++- src/output/lines.rs | 4 ++-- 5 files changed, 28 insertions(+), 18 deletions(-) diff --git a/src/output/details.rs b/src/output/details.rs index 5e6688c..e79a8a2 100644 --- a/src/output/details.rs +++ b/src/output/details.rs @@ -101,7 +101,7 @@ use output::colours::Colours; use output::column::{Alignment, Column, Columns, SizeFormat}; use output::cell::{TextCell, TextCellContents, DisplayWidth}; use output::tree::TreeTrunk; -use output::file_name::FileName; +use output::file_name::{FileName, LinkStyle}; /// With the **Details** view, the output gets formatted into columns, with @@ -310,7 +310,7 @@ impl Details { let row = Row { depth: depth, cells: Some(egg.cells), - name: FileName::new(&egg.file, &self.colours).paint(true, self.classify).promote(), + name: FileName::new(&egg.file, LinkStyle::FullLinkPaths, &self.colours).paint(self.classify).promote(), last: index == num_eggs - 1, }; @@ -443,8 +443,8 @@ impl<'a, U: Users+Groups+'a> Table<'a, U> { self.rows.push(row); } - pub fn filename(&self, file: File, links: bool) -> TextCellContents { - FileName::new(&file, &self.opts.colours).paint(links, self.opts.classify) + pub fn filename(&self, file: File, links: LinkStyle) -> TextCellContents { + FileName::new(&file, links, &self.opts.colours).paint(self.opts.classify) } pub fn add_file_with_cells(&mut self, cells: Vec, name_cell: TextCell, depth: usize, last: bool) { diff --git a/src/output/file_name.rs b/src/output/file_name.rs index d2432ae..007c7ac 100644 --- a/src/output/file_name.rs +++ b/src/output/file_name.rs @@ -8,24 +8,32 @@ use output::escape; use output::cell::TextCellContents; +pub enum LinkStyle { + JustFilenames, + FullLinkPaths, +} + + pub struct FileName<'a, 'dir: 'a> { file: &'a File<'dir>, colours: &'a Colours, target: Option>, + link_style: LinkStyle, } impl<'a, 'dir> FileName<'a, 'dir> { - pub fn new(file: &'a File<'dir>, colours: &'a Colours) -> FileName<'a, 'dir> { + pub fn new(file: &'a File<'dir>, link_style: LinkStyle, colours: &'a Colours) -> FileName<'a, 'dir> { let target = if file.is_link() { Some(file.link_target()) } else { None }; FileName { file: file, colours: colours, target: target, + link_style: link_style, } } - pub fn paint(&self, links: bool, classify: bool) -> TextCellContents { + pub fn paint(&self, classify: bool) -> TextCellContents { let mut bits = Vec::new(); if self.file.dir.is_none() { @@ -40,9 +48,9 @@ impl<'a, 'dir> FileName<'a, 'dir> { } } - if links && self.target.is_some() { - match self.target.as_ref().unwrap() { - &FileTarget::Ok(ref target) => { + if let (&LinkStyle::FullLinkPaths, Some(ref target)) = (&self.link_style, self.target.as_ref()) { + match **target { + FileTarget::Ok(ref target) => { bits.push(Style::default().paint(" ")); bits.push(self.colours.punctuation.paint("->")); bits.push(Style::default().paint(" ")); @@ -52,21 +60,21 @@ impl<'a, 'dir> FileName<'a, 'dir> { } if !target.name.is_empty() { - let target = FileName::new(&target, self.colours); + let target = FileName::new(&target, LinkStyle::FullLinkPaths, self.colours); for bit in target.coloured_file_name() { bits.push(bit); } } }, - &FileTarget::Broken(ref broken_path) => { + FileTarget::Broken(ref broken_path) => { bits.push(Style::default().paint(" ")); bits.push(self.colours.broken_arrow.paint("->")); bits.push(Style::default().paint(" ")); escape(broken_path.display().to_string(), &mut bits, self.colours.broken_filename, self.colours.control_char.underline()); }, - &FileTarget::Err(_) => { + FileTarget::Err(_) => { // Do nothing -- the error gets displayed on the next line }, } diff --git a/src/output/grid.rs b/src/output/grid.rs index bddebae..89f56a3 100644 --- a/src/output/grid.rs +++ b/src/output/grid.rs @@ -4,7 +4,7 @@ use term_grid as grid; use fs::File; use output::colours::Colours; -use output::file_name::FileName; +use output::file_name::{FileName, LinkStyle}; #[derive(PartialEq, Debug, Copy, Clone)] @@ -28,7 +28,7 @@ impl Grid { grid.reserve(files.len()); for file in files.iter() { - let filename = FileName::new(file, &self.colours).paint(false, self.classify); + let filename = FileName::new(file, LinkStyle::JustFilenames, &self.colours).paint(self.classify); let width = filename.width(); grid.add(grid::Cell { @@ -43,7 +43,7 @@ impl Grid { else { // File names too long for a grid - drop down to just listing them! for file in files.iter() { - let name_cell = FileName::new(file, &self.colours).paint(false, self.classify); + let name_cell = FileName::new(file, LinkStyle::JustFilenames, &self.colours).paint(self.classify); writeln!(w, "{}", name_cell.strings())?; } Ok(()) diff --git a/src/output/grid_details.rs b/src/output/grid_details.rs index 48cb9a5..a32336b 100644 --- a/src/output/grid_details.rs +++ b/src/output/grid_details.rs @@ -12,6 +12,8 @@ use output::cell::TextCell; use output::column::Column; use output::details::{Details, Table, Environment}; use output::grid::Grid; +use output::file_name::LinkStyle; + #[derive(PartialEq, Debug, Clone)] pub struct GridDetails { @@ -45,7 +47,7 @@ impl GridDetails { .collect::>(); let file_names = files.into_iter() - .map(|file| first_table.filename(file, false).promote()) + .map(|file| first_table.filename(file, LinkStyle::JustFilenames).promote()) .collect::>(); (cells, file_names) diff --git a/src/output/lines.rs b/src/output/lines.rs index dfe8d47..ef978b4 100644 --- a/src/output/lines.rs +++ b/src/output/lines.rs @@ -4,7 +4,7 @@ use ansi_term::ANSIStrings; use fs::File; -use output::file_name::FileName; +use output::file_name::{FileName, LinkStyle}; use super::colours::Colours; @@ -18,7 +18,7 @@ pub struct Lines { impl Lines { pub fn view(&self, files: Vec, w: &mut W) -> IOResult<()> { for file in files { - let name_cell = FileName::new(&file, &self.colours).paint(true, self.classify); + let name_cell = FileName::new(&file, LinkStyle::FullLinkPaths, &self.colours).paint(self.classify); writeln!(w, "{}", ANSIStrings(&name_cell))?; } Ok(()) From 9f6376a560df56c40b7f3753bebec8c52410432c Mon Sep 17 00:00:00 2001 From: Benjamin Sago Date: Sun, 7 May 2017 14:45:04 +0100 Subject: [PATCH 3/5] Give broken links a different style in grid view Because the link style and status are now both available to the function that picks the colour style, we can have it highlight broken links differently. Fixes #131. --- src/fs/file.rs | 10 ++++++++++ src/output/file_name.rs | 11 ++++++++++- xtests/file_names_R | 2 +- xtests/links | 4 ++-- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/fs/file.rs b/src/fs/file.rs index 2966d96..921e7e1 100644 --- a/src/fs/file.rs +++ b/src/fs/file.rs @@ -412,6 +412,16 @@ pub enum FileTarget<'dir> { Err(IOError), } +impl<'dir> FileTarget<'dir> { + pub fn is_broken(&self) -> bool { + match self { + &FileTarget::Ok(_) => false, + &FileTarget::Broken(_) => true, + &FileTarget::Err(_) => true, + } + } +} + #[cfg(test)] mod test { diff --git a/src/output/file_name.rs b/src/output/file_name.rs index 007c7ac..c39f166 100644 --- a/src/output/file_name.rs +++ b/src/output/file_name.rs @@ -8,6 +8,7 @@ use output::escape; use output::cell::TextCellContents; +#[derive(PartialEq, Debug, Copy, Clone)] pub enum LinkStyle { JustFilenames, FullLinkPaths, @@ -48,7 +49,7 @@ impl<'a, 'dir> FileName<'a, 'dir> { } } - if let (&LinkStyle::FullLinkPaths, Some(ref target)) = (&self.link_style, self.target.as_ref()) { + if let (LinkStyle::FullLinkPaths, Some(ref target)) = (self.link_style, self.target.as_ref()) { match **target { FileTarget::Ok(ref target) => { bits.push(Style::default().paint(" ")); @@ -138,6 +139,14 @@ impl<'a, 'dir> FileName<'a, 'dir> { } pub fn style(&self) -> Style { + if let LinkStyle::JustFilenames = self.link_style { + if let Some(ref target) = self.target { + if target.is_broken() { + return self.colours.broken_arrow; + } + } + } + match self.file { f if f.is_directory() => self.colours.filetypes.directory, f if f.is_executable_file() => self.colours.filetypes.executable, diff --git a/xtests/file_names_R b/xtests/file_names_R index 7b7c9fe..be489cb 100644 --- a/xtests/file_names_R +++ b/xtests/file_names_R @@ -6,7 +6,7 @@ emoji: [🆒] invalid-utf8-4: [�(�(] utf-8: pâté escape: [\u{1b}] links vertical-tab: [\u{b}] /testcases/file-names/links: -another: [\n] broken subfile +another: [\n] broken subfile /testcases/file-names/new-line-dir: [\n]: another: [\n] subfile diff --git a/xtests/links b/xtests/links index 38dfcfc..fa5c79d 100644 --- a/xtests/links +++ b/xtests/links @@ -1,2 +1,2 @@ -broken forbidden parent_dir some_file some_file_relative -current_dir itself root some_file_absolute usr +broken forbidden parent_dir some_file some_file_relative +current_dir itself root some_file_absolute usr From 39381bfb49002fd1db3f5060c1287df679d50bb9 Mon Sep 17 00:00:00 2001 From: Benjamin Sago Date: Sun, 7 May 2017 15:14:06 +0100 Subject: [PATCH 4/5] Document the recent changes --- src/fs/file.rs | 5 +++- src/output/file_name.rs | 61 +++++++++++++++++++++++++++++++++++------ 2 files changed, 56 insertions(+), 10 deletions(-) diff --git a/src/fs/file.rs b/src/fs/file.rs index 921e7e1..2448962 100644 --- a/src/fs/file.rs +++ b/src/fs/file.rs @@ -407,12 +407,15 @@ pub enum FileTarget<'dir> { Broken(PathBuf), /// There was an IO error when following the link. This can happen if the - /// file isn't a link to begin with, but also if, say, we don't have + /// file isn’t a link to begin with, but also if, say, we don’t have /// permission to follow it. Err(IOError), } impl<'dir> FileTarget<'dir> { + + /// Whether this link doesn’t lead to a file, for whatever reason. This + /// gets used to determine how to highlight the link in grid views. pub fn is_broken(&self) -> bool { match self { &FileTarget::Ok(_) => false, diff --git a/src/output/file_name.rs b/src/output/file_name.rs index c39f166..e994060 100644 --- a/src/output/file_name.rs +++ b/src/output/file_name.rs @@ -8,21 +8,28 @@ use output::escape; use output::cell::TextCellContents; -#[derive(PartialEq, Debug, Copy, Clone)] -pub enum LinkStyle { - JustFilenames, - FullLinkPaths, -} - - +/// A **file name** holds all the information necessary to display the name +/// of the given file. This is used in all of the views. pub struct FileName<'a, 'dir: 'a> { - file: &'a File<'dir>, + + /// A reference to the file that we're getting the name of. + file: &'a File<'dir>, + + /// The colours used to paint the file name and its surrounding text. colours: &'a Colours, - target: Option>, + + /// The file that this file points to if it's a link. + target: Option>, + + /// How to handle displaying links. link_style: LinkStyle, } + impl<'a, 'dir> FileName<'a, 'dir> { + + /// Create a new `FileName` that prints the given file’s name, painting it + /// with the remaining arguments. pub fn new(file: &'a File<'dir>, link_style: LinkStyle, colours: &'a Colours) -> FileName<'a, 'dir> { let target = if file.is_link() { Some(file.link_target()) } else { None }; @@ -34,6 +41,13 @@ impl<'a, 'dir> FileName<'a, 'dir> { } } + + /// Paints the name of the file using the colours, resulting in a vector + /// of coloured cells that can be printed to the terminal. + /// + /// This method returns some `TextCellContents`, rather than a `TextCell`, + /// because for the last cell in a table, it doesn’t need to have its + /// width calculated. pub fn paint(&self, classify: bool) -> TextCellContents { let mut bits = Vec::new(); @@ -89,6 +103,7 @@ impl<'a, 'dir> FileName<'a, 'dir> { bits.into() } + /// Adds the bits of the parent path to the given bits vector. /// The path gets its characters escaped based on the colours. fn add_parent_bits(&self, bits: &mut Vec, parent: &Path) { @@ -103,6 +118,7 @@ impl<'a, 'dir> FileName<'a, 'dir> { } } + /// The character to be displayed after a file when classifying is on, if /// the file’s type has one associated with it. fn classify_char(&self) -> Option<&'static str> { @@ -121,6 +137,7 @@ impl<'a, 'dir> FileName<'a, 'dir> { } } + /// Returns at least one ANSI-highlighted string representing this file’s /// name using the given set of colours. /// @@ -138,7 +155,15 @@ impl<'a, 'dir> FileName<'a, 'dir> { bits } + + /// Figures out which colour to paint the filename part of the output, + /// depending on which “type” of file it appears to be -- either from the + /// class on the filesystem or from its name. pub fn style(&self) -> Style { + + // Override the style with the “broken link” style when this file is + // a link that we can’t follow for whatever reason. This is used when + // there’s no other place to show that the link doesn’t work. if let LinkStyle::JustFilenames = self.link_style { if let Some(ref target) = self.target { if target.is_broken() { @@ -147,6 +172,8 @@ impl<'a, 'dir> FileName<'a, 'dir> { } } + // Otherwise, just apply a bunch of rules in order. For example, + // executable image files should be executable rather than images. match self.file { f if f.is_directory() => self.colours.filetypes.directory, f if f.is_executable_file() => self.colours.filetypes.executable, @@ -170,3 +197,19 @@ impl<'a, 'dir> FileName<'a, 'dir> { } } } + + +/// When displaying a file name, there needs to be some way to handle broken +/// links, depending on how long the resulting Cell can be. +#[derive(PartialEq, Debug, Copy, Clone)] +pub enum LinkStyle { + + /// Just display the file names, but colour them differently if they’re + /// a broken link or can’t be followed. + JustFilenames, + + /// Display all files in their usual style, but follow each link with an + /// arrow pointing to their path, colouring the path differently if it’s + /// a broken link, and doing nothing if it can’t be followed. + FullLinkPaths, +} From e916097e0e395ff18ed763da27f288be7939e6a7 Mon Sep 17 00:00:00 2001 From: Benjamin Sago Date: Sun, 7 May 2017 15:31:00 +0100 Subject: [PATCH 5/5] Similarly, turn Classify into an enum --- src/options/view.rs | 17 +++++++++++++---- src/output/details.rs | 8 ++++---- src/output/file_name.rs | 31 +++++++++++++++++++++++++++---- src/output/grid.rs | 8 ++++---- src/output/lines.rs | 6 +++--- 5 files changed, 51 insertions(+), 19 deletions(-) diff --git a/src/options/view.rs b/src/options/view.rs index f848c63..e3dfceb 100644 --- a/src/options/view.rs +++ b/src/options/view.rs @@ -4,8 +4,9 @@ use getopts; use output::Colours; use output::{Grid, Details, GridDetails, Lines}; -use options::{FileFilter, DirAction, Misfire}; use output::column::{Columns, TimeTypes, SizeFormat}; +use output::file_name::Classify; +use options::{FileFilter, DirAction, Misfire}; use term::dimensions; use fs::feature::xattr; @@ -58,7 +59,7 @@ impl View { filter: filter.clone(), xattr: xattr::ENABLED && matches.opt_present("extended"), colours: colours, - classify: matches.opt_present("classify"), + classify: Classify::deduce(matches), }; Ok(details) @@ -87,8 +88,7 @@ impl View { }; let other_options_scan = || { - let classify = matches.opt_present("classify"); - + let classify = Classify::deduce(matches); let term_colours = TerminalColours::deduce(matches)?; let term_width = TerminalWidth::deduce()?; @@ -366,3 +366,12 @@ impl TerminalColours { } } } + + + +impl Classify { + fn deduce(matches: &getopts::Matches) -> Classify { + if matches.opt_present("classify") { Classify::AddFileIndicators } + else { Classify::JustFilenames } + } +} diff --git a/src/output/details.rs b/src/output/details.rs index e79a8a2..4277374 100644 --- a/src/output/details.rs +++ b/src/output/details.rs @@ -101,7 +101,7 @@ use output::colours::Colours; use output::column::{Alignment, Column, Columns, SizeFormat}; use output::cell::{TextCell, TextCellContents, DisplayWidth}; use output::tree::TreeTrunk; -use output::file_name::{FileName, LinkStyle}; +use output::file_name::{FileName, LinkStyle, Classify}; /// With the **Details** view, the output gets formatted into columns, with @@ -142,7 +142,7 @@ pub struct Details { pub colours: Colours, /// Whether to show a file type indiccator. - pub classify: bool, + pub classify: Classify, } /// The **environment** struct contains any data that could change between @@ -310,7 +310,7 @@ impl Details { let row = Row { depth: depth, cells: Some(egg.cells), - name: FileName::new(&egg.file, LinkStyle::FullLinkPaths, &self.colours).paint(self.classify).promote(), + name: FileName::new(&egg.file, LinkStyle::FullLinkPaths, self.classify, &self.colours).paint().promote(), last: index == num_eggs - 1, }; @@ -444,7 +444,7 @@ impl<'a, U: Users+Groups+'a> Table<'a, U> { } pub fn filename(&self, file: File, links: LinkStyle) -> TextCellContents { - FileName::new(&file, links, &self.opts.colours).paint(self.opts.classify) + FileName::new(&file, links, self.opts.classify, &self.opts.colours).paint() } pub fn add_file_with_cells(&mut self, cells: Vec, name_cell: TextCell, depth: usize, last: bool) { diff --git a/src/output/file_name.rs b/src/output/file_name.rs index e994060..43618c9 100644 --- a/src/output/file_name.rs +++ b/src/output/file_name.rs @@ -23,6 +23,9 @@ pub struct FileName<'a, 'dir: 'a> { /// How to handle displaying links. link_style: LinkStyle, + + /// Whether to append file class characters to file names. + classify: Classify, } @@ -30,7 +33,7 @@ impl<'a, 'dir> FileName<'a, 'dir> { /// Create a new `FileName` that prints the given file’s name, painting it /// with the remaining arguments. - pub fn new(file: &'a File<'dir>, link_style: LinkStyle, colours: &'a Colours) -> FileName<'a, 'dir> { + pub fn new(file: &'a File<'dir>, link_style: LinkStyle, classify: Classify, colours: &'a Colours) -> FileName<'a, 'dir> { let target = if file.is_link() { Some(file.link_target()) } else { None }; FileName { @@ -38,6 +41,7 @@ impl<'a, 'dir> FileName<'a, 'dir> { colours: colours, target: target, link_style: link_style, + classify: classify, } } @@ -48,7 +52,7 @@ impl<'a, 'dir> FileName<'a, 'dir> { /// This method returns some `TextCellContents`, rather than a `TextCell`, /// because for the last cell in a table, it doesn’t need to have its /// width calculated. - pub fn paint(&self, classify: bool) -> TextCellContents { + pub fn paint(&self) -> TextCellContents { let mut bits = Vec::new(); if self.file.dir.is_none() { @@ -75,7 +79,7 @@ impl<'a, 'dir> FileName<'a, 'dir> { } if !target.name.is_empty() { - let target = FileName::new(&target, LinkStyle::FullLinkPaths, self.colours); + let target = FileName::new(&target, LinkStyle::FullLinkPaths, Classify::JustFilenames, self.colours); for bit in target.coloured_file_name() { bits.push(bit); } @@ -94,7 +98,7 @@ impl<'a, 'dir> FileName<'a, 'dir> { }, } } - else if classify { + else if let Classify::AddFileIndicators = self.classify { if let Some(class) = self.classify_char() { bits.push(Style::default().paint(class)); } @@ -213,3 +217,22 @@ pub enum LinkStyle { /// a broken link, and doing nothing if it can’t be followed. FullLinkPaths, } + + +/// Whether to append file class characters to the file names. +#[derive(PartialEq, Debug, Copy, Clone)] +pub enum Classify { + + /// Just display the file names, without any characters. + JustFilenames, + + /// Add a character after the file name depending on what class of file + /// it is. + AddFileIndicators, +} + +impl Default for Classify { + fn default() -> Classify { + Classify::JustFilenames + } +} diff --git a/src/output/grid.rs b/src/output/grid.rs index 89f56a3..5cdd4df 100644 --- a/src/output/grid.rs +++ b/src/output/grid.rs @@ -4,7 +4,7 @@ use term_grid as grid; use fs::File; use output::colours::Colours; -use output::file_name::{FileName, LinkStyle}; +use output::file_name::{FileName, LinkStyle, Classify}; #[derive(PartialEq, Debug, Copy, Clone)] @@ -12,7 +12,7 @@ pub struct Grid { pub across: bool, pub console_width: usize, pub colours: Colours, - pub classify: bool, + pub classify: Classify, } impl Grid { @@ -28,7 +28,7 @@ impl Grid { grid.reserve(files.len()); for file in files.iter() { - let filename = FileName::new(file, LinkStyle::JustFilenames, &self.colours).paint(self.classify); + let filename = FileName::new(file, LinkStyle::JustFilenames, self.classify, &self.colours).paint(); let width = filename.width(); grid.add(grid::Cell { @@ -43,7 +43,7 @@ impl Grid { else { // File names too long for a grid - drop down to just listing them! for file in files.iter() { - let name_cell = FileName::new(file, LinkStyle::JustFilenames, &self.colours).paint(self.classify); + let name_cell = FileName::new(file, LinkStyle::JustFilenames, self.classify, &self.colours).paint(); writeln!(w, "{}", name_cell.strings())?; } Ok(()) diff --git a/src/output/lines.rs b/src/output/lines.rs index ef978b4..ad3c489 100644 --- a/src/output/lines.rs +++ b/src/output/lines.rs @@ -4,21 +4,21 @@ use ansi_term::ANSIStrings; use fs::File; -use output::file_name::{FileName, LinkStyle}; +use output::file_name::{FileName, LinkStyle, Classify}; use super::colours::Colours; #[derive(Clone, Copy, Debug, PartialEq)] pub struct Lines { pub colours: Colours, - pub classify: bool, + pub classify: Classify, } /// The lines view literally just displays each file, line-by-line. impl Lines { pub fn view(&self, files: Vec, w: &mut W) -> IOResult<()> { for file in files { - let name_cell = FileName::new(&file, LinkStyle::FullLinkPaths, &self.colours).paint(self.classify); + let name_cell = FileName::new(&file, LinkStyle::FullLinkPaths, self.classify, &self.colours).paint(); writeln!(w, "{}", ANSIStrings(&name_cell))?; } Ok(())