diff options
author | Ben S <ogham@bsago.me> | 2015-05-09 23:57:18 +0100 |
---|---|---|
committer | Ben S <ogham@bsago.me> | 2015-05-09 23:57:18 +0100 |
commit | 36116a142095d61ab7f601cb6efda03d2cb8d749 (patch) | |
tree | 8b4057bc23c5a92565610d9067077c87a6e1211b /src/output/lines.rs | |
parent | da49b80c3525db7f0a0aae0fe2ac3e0a9a574cd3 (diff) |
Add colours module, and disable them sometimes
Colours are now disabled when output is not to a terminal. Fixes #53!
This required some internal restructuring - colours are now in their own object that gets passed around everywhere it's needed.
Diffstat (limited to 'src/output/lines.rs')
-rw-r--r-- | src/output/lines.rs | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/output/lines.rs b/src/output/lines.rs index 6649c29..b61494f 100644 --- a/src/output/lines.rs +++ b/src/output/lines.rs @@ -1,8 +1,16 @@ +use colours::Colours; use file::File; +#[derive(Clone, Copy, Debug, PartialEq)] +pub struct Lines { + pub colours: Colours, +} + /// The lines view literally just displays each file, line-by-line. -pub fn lines_view(files: &[File]) { - for file in files { - println!("{}", file.file_name_view()); +impl Lines { + pub fn view(&self, files: &[File]) { + for file in files { + println!("{}", file.file_name_view(&self.colours)); + } } } |