|
|
@@ -133,13 +133,6 @@ pub struct Details {
|
|
|
|
|
|
/// Whether to show each file's extended attributes.
|
|
|
pub xattr: bool,
|
|
|
-
|
|
|
- /// The colours to use to display information in the table, including the
|
|
|
- /// colour of the tree view symbols.
|
|
|
- pub colours: Colours,
|
|
|
-
|
|
|
- /// Whether to show a file type indiccator.
|
|
|
- pub classify: Classify,
|
|
|
}
|
|
|
|
|
|
/// The **environment** struct contains any data that could change between
|
|
|
@@ -228,7 +221,7 @@ impl Details {
|
|
|
|
|
|
/// Print the details of the given vector of files -- all of which will
|
|
|
/// have been read from the given directory, if present -- to stdout.
|
|
|
- pub fn view<W: Write>(&self, dir: Option<&Dir>, files: Vec<File>, w: &mut W) -> IOResult<()> {
|
|
|
+ pub fn view<W: Write>(&self, dir: Option<&Dir>, files: Vec<File>, w: &mut W, colours: &Colours, classify: Classify) -> IOResult<()> {
|
|
|
|
|
|
// First, transform the Columns object into a vector of columns for
|
|
|
// the current directory.
|
|
|
@@ -243,7 +236,9 @@ impl Details {
|
|
|
// Build the table to put rows in.
|
|
|
let mut table = Table {
|
|
|
columns: &*columns_for_dir,
|
|
|
- opts: self,
|
|
|
+ colours: colours,
|
|
|
+ classify: classify,
|
|
|
+ xattr: self.xattr,
|
|
|
env: env,
|
|
|
rows: Vec::new(),
|
|
|
};
|
|
|
@@ -306,7 +301,7 @@ impl Details {
|
|
|
|
|
|
let cells = table.cells_for_file(&file, !xattrs.is_empty());
|
|
|
|
|
|
- if !table.opts.xattr {
|
|
|
+ if !table.xattr {
|
|
|
xattrs.clear();
|
|
|
}
|
|
|
|
|
|
@@ -336,7 +331,7 @@ impl Details {
|
|
|
let row = Row {
|
|
|
depth: depth,
|
|
|
cells: Some(egg.cells),
|
|
|
- name: FileName::new(&egg.file, LinkStyle::FullLinkPaths, self.classify, &self.colours).paint().promote(),
|
|
|
+ name: FileName::new(&egg.file, LinkStyle::FullLinkPaths, table.classify, table.colours).paint().promote(),
|
|
|
last: index == num_eggs - 1,
|
|
|
};
|
|
|
|
|
|
@@ -420,9 +415,10 @@ impl Row {
|
|
|
/// directories.
|
|
|
pub struct Table<'a, U: 'a> { // where U: Users+Groups
|
|
|
pub rows: Vec<Row>,
|
|
|
-
|
|
|
pub columns: &'a [Column],
|
|
|
- pub opts: &'a Details,
|
|
|
+ pub colours: &'a Colours,
|
|
|
+ pub xattr: bool,
|
|
|
+ pub classify: Classify,
|
|
|
pub env: Arc<Environment<U>>,
|
|
|
}
|
|
|
|
|
|
@@ -434,8 +430,8 @@ impl<'a, U: Users+Groups+'a> Table<'a, U> {
|
|
|
pub fn add_header(&mut self) {
|
|
|
let row = Row {
|
|
|
depth: 0,
|
|
|
- cells: Some(self.columns.iter().map(|c| TextCell::paint_str(self.opts.colours.header, c.header())).collect()),
|
|
|
- name: TextCell::paint_str(self.opts.colours.header, "Name"),
|
|
|
+ cells: Some(self.columns.iter().map(|c| TextCell::paint_str(self.colours.header, c.header())).collect()),
|
|
|
+ name: TextCell::paint_str(self.colours.header, "Name"),
|
|
|
last: false,
|
|
|
};
|
|
|
|
|
|
@@ -451,7 +447,7 @@ impl<'a, U: Users+Groups+'a> Table<'a, U> {
|
|
|
let row = Row {
|
|
|
depth: depth,
|
|
|
cells: None,
|
|
|
- name: TextCell::paint(self.opts.colours.broken_arrow, error_message),
|
|
|
+ name: TextCell::paint(self.colours.broken_arrow, error_message),
|
|
|
last: last,
|
|
|
};
|
|
|
|
|
|
@@ -462,7 +458,7 @@ impl<'a, U: Users+Groups+'a> Table<'a, U> {
|
|
|
let row = Row {
|
|
|
depth: depth,
|
|
|
cells: None,
|
|
|
- name: TextCell::paint(self.opts.colours.perms.attribute, format!("{} (len {})", xattr.name, xattr.size)),
|
|
|
+ name: TextCell::paint(self.colours.perms.attribute, format!("{} (len {})", xattr.name, xattr.size)),
|
|
|
last: last,
|
|
|
};
|
|
|
|
|
|
@@ -470,7 +466,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.classify, &self.opts.colours).paint()
|
|
|
+ FileName::new(&file, links, self.classify, &self.colours).paint()
|
|
|
}
|
|
|
|
|
|
pub fn add_file_with_cells(&mut self, cells: Vec<TextCell>, name_cell: TextCell, depth: usize, last: bool) {
|
|
|
@@ -504,17 +500,17 @@ impl<'a, U: Users+Groups+'a> Table<'a, U> {
|
|
|
use output::column::TimeType::*;
|
|
|
|
|
|
match *column {
|
|
|
- Column::Permissions => self.permissions_plus(file, xattrs).render(&self.opts.colours),
|
|
|
- Column::FileSize(fmt) => file.size().render(&self.opts.colours, fmt, &self.env.numeric),
|
|
|
- Column::Timestamp(Modified) => file.modified_time().render(&self.opts.colours, &self.env.tz, &self.env.date_and_time, &self.env.date_and_year, &self.env.time, self.env.current_year),
|
|
|
- Column::Timestamp(Created) => file.created_time().render( &self.opts.colours, &self.env.tz, &self.env.date_and_time, &self.env.date_and_year, &self.env.time, self.env.current_year),
|
|
|
- Column::Timestamp(Accessed) => file.accessed_time().render(&self.opts.colours, &self.env.tz, &self.env.date_and_time, &self.env.date_and_year, &self.env.time, self.env.current_year),
|
|
|
- Column::HardLinks => file.links().render(&self.opts.colours, &self.env.numeric),
|
|
|
- Column::Inode => file.inode().render(&self.opts.colours),
|
|
|
- Column::Blocks => file.blocks().render(&self.opts.colours),
|
|
|
- Column::User => file.user().render(&self.opts.colours, &*self.env.lock_users()),
|
|
|
- Column::Group => file.group().render(&self.opts.colours, &*self.env.lock_users()),
|
|
|
- Column::GitStatus => file.git_status().render(&self.opts.colours),
|
|
|
+ Column::Permissions => self.permissions_plus(file, xattrs).render(&self.colours),
|
|
|
+ Column::FileSize(fmt) => file.size().render(&self.colours, fmt, &self.env.numeric),
|
|
|
+ Column::Timestamp(Modified) => file.modified_time().render(&self.colours, &self.env.tz, &self.env.date_and_time, &self.env.date_and_year, &self.env.time, self.env.current_year),
|
|
|
+ Column::Timestamp(Created) => file.created_time().render( &self.colours, &self.env.tz, &self.env.date_and_time, &self.env.date_and_year, &self.env.time, self.env.current_year),
|
|
|
+ Column::Timestamp(Accessed) => file.accessed_time().render(&self.colours, &self.env.tz, &self.env.date_and_time, &self.env.date_and_year, &self.env.time, self.env.current_year),
|
|
|
+ Column::HardLinks => file.links().render(&self.colours, &self.env.numeric),
|
|
|
+ Column::Inode => file.inode().render(&self.colours),
|
|
|
+ Column::Blocks => file.blocks().render(&self.colours),
|
|
|
+ Column::User => file.user().render(&self.colours, &*self.env.lock_users()),
|
|
|
+ Column::Group => file.group().render(&self.colours, &*self.env.lock_users()),
|
|
|
+ Column::GitStatus => file.git_status().render(&self.colours),
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -554,7 +550,7 @@ impl<'a, U: Users+Groups+'a> Table<'a, U> {
|
|
|
let mut filename = TextCell::default();
|
|
|
|
|
|
for tree_part in tree_trunk.new_row(row.depth, row.last) {
|
|
|
- filename.push(self.opts.colours.punctuation.paint(tree_part.ascii_art()), 4);
|
|
|
+ filename.push(self.colours.punctuation.paint(tree_part.ascii_art()), 4);
|
|
|
}
|
|
|
|
|
|
// If any tree characters have been printed, then add an extra
|