2015-06-08 20:33:39 +00:00
|
|
|
use ansi_term::ANSIStrings;
|
2015-02-05 14:39:56 +00:00
|
|
|
|
2015-05-11 22:28:01 +00:00
|
|
|
use colours::Colours;
|
|
|
|
use file::File;
|
|
|
|
use filetype::file_colour;
|
|
|
|
|
2015-02-05 14:39:56 +00:00
|
|
|
pub use self::details::Details;
|
2015-06-08 20:33:39 +00:00
|
|
|
pub use self::grid::Grid;
|
2015-05-09 22:57:18 +00:00
|
|
|
pub use self::lines::Lines;
|
2015-06-28 12:21:21 +00:00
|
|
|
pub use self::grid_details::GridDetails;
|
2015-05-11 22:28:01 +00:00
|
|
|
|
2015-06-08 20:33:39 +00:00
|
|
|
mod grid;
|
|
|
|
pub mod details;
|
|
|
|
mod lines;
|
2015-06-28 12:21:21 +00:00
|
|
|
mod grid_details;
|
2015-06-08 20:33:39 +00:00
|
|
|
|
2015-06-28 12:21:21 +00:00
|
|
|
pub fn filename(file: &File, colours: &Colours, links: bool) -> String {
|
|
|
|
if links && file.is_link() {
|
2015-05-11 22:28:01 +00:00
|
|
|
symlink_filename(file, colours)
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
let style = file_colour(colours, file);
|
|
|
|
style.paint(&file.name).to_string()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn symlink_filename(file: &File, colours: &Colours) -> String {
|
|
|
|
match file.link_target() {
|
|
|
|
Ok(target) => format!("{} {} {}",
|
|
|
|
file_colour(colours, file).paint(&file.name),
|
2015-08-03 09:22:24 +00:00
|
|
|
colours.punctuation.paint("->"),
|
2015-05-11 22:28:01 +00:00
|
|
|
ANSIStrings(&[ colours.symlink_path.paint(&target.path_prefix()),
|
|
|
|
file_colour(colours, &target).paint(&target.name) ])),
|
|
|
|
|
|
|
|
Err(filename) => format!("{} {} {}",
|
|
|
|
file_colour(colours, file).paint(&file.name),
|
2015-08-03 09:22:24 +00:00
|
|
|
colours.broken_arrow.paint("->"),
|
2015-05-11 22:28:01 +00:00
|
|
|
colours.broken_filename.paint(&filename)),
|
|
|
|
}
|
|
|
|
}
|