2015-05-09 22:57:18 +00:00
|
|
|
use ansi_term::Style;
|
|
|
|
use ansi_term::Style::Plain;
|
2015-05-10 11:50:20 +00:00
|
|
|
use ansi_term::Colour::{Red, Green, Yellow, Blue, Cyan, Purple, Fixed};
|
2015-05-09 22:57:18 +00:00
|
|
|
|
|
|
|
use file::GREY;
|
|
|
|
|
|
|
|
use std::default::Default;
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, Debug, Default, PartialEq)]
|
|
|
|
pub struct Colours {
|
2015-05-10 11:50:20 +00:00
|
|
|
pub filetypes: FileTypes,
|
|
|
|
pub perms: Permissions,
|
|
|
|
pub size: Size,
|
|
|
|
pub users: Users,
|
|
|
|
pub links: Links,
|
|
|
|
|
|
|
|
pub punctuation: Style,
|
|
|
|
pub date: Style,
|
|
|
|
pub inode: Style,
|
|
|
|
pub blocks: Style,
|
|
|
|
pub header: Style,
|
|
|
|
|
|
|
|
pub symlink_path: Style,
|
|
|
|
pub broken_arrow: Style,
|
|
|
|
pub broken_filename: Style,
|
2015-05-09 23:22:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, Debug, Default, PartialEq)]
|
|
|
|
pub struct FileTypes {
|
2015-05-09 22:57:18 +00:00
|
|
|
pub normal: Style,
|
|
|
|
pub directory: Style,
|
|
|
|
pub symlink: Style,
|
|
|
|
pub special: Style,
|
|
|
|
pub executable: Style,
|
|
|
|
pub image: Style,
|
|
|
|
pub video: Style,
|
|
|
|
pub music: Style,
|
|
|
|
pub lossless: Style,
|
|
|
|
pub crypto: Style,
|
|
|
|
pub document: Style,
|
|
|
|
pub compressed: Style,
|
|
|
|
pub temp: Style,
|
|
|
|
pub immediate: Style,
|
|
|
|
pub compiled: Style,
|
|
|
|
}
|
|
|
|
|
2015-05-10 11:50:20 +00:00
|
|
|
#[derive(Clone, Copy, Debug, Default, PartialEq)]
|
|
|
|
pub struct Permissions {
|
|
|
|
pub user_read: Style,
|
|
|
|
pub user_write: Style,
|
|
|
|
pub user_execute_file: Style,
|
|
|
|
pub user_execute_other: Style,
|
|
|
|
|
|
|
|
pub group_read: Style,
|
|
|
|
pub group_write: Style,
|
|
|
|
pub group_execute: Style,
|
|
|
|
|
|
|
|
pub other_read: Style,
|
|
|
|
pub other_write: Style,
|
|
|
|
pub other_execute: Style,
|
|
|
|
|
|
|
|
pub attribute: Style,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, Debug, Default, PartialEq)]
|
|
|
|
pub struct Size {
|
|
|
|
pub numbers: Style,
|
|
|
|
pub unit: Style,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, Debug, Default, PartialEq)]
|
|
|
|
pub struct Users {
|
|
|
|
pub user_you: Style,
|
|
|
|
pub user_someone_else: Style,
|
|
|
|
pub group_yours: Style,
|
|
|
|
pub group_not_yours: Style,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, Debug, Default, PartialEq)]
|
|
|
|
pub struct Links {
|
|
|
|
pub normal: Style,
|
|
|
|
pub multi_link_file: Style,
|
|
|
|
}
|
|
|
|
|
2015-05-09 22:57:18 +00:00
|
|
|
impl Colours {
|
|
|
|
pub fn plain() -> Colours {
|
|
|
|
Colours::default()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn colourful() -> Colours {
|
|
|
|
Colours {
|
2015-05-09 23:22:58 +00:00
|
|
|
filetypes: FileTypes {
|
|
|
|
normal: Plain,
|
|
|
|
directory: Blue.bold(),
|
|
|
|
symlink: Cyan.normal(),
|
|
|
|
special: Yellow.normal(),
|
|
|
|
executable: Green.bold(),
|
|
|
|
image: Fixed(133).normal(),
|
|
|
|
video: Fixed(135).normal(),
|
|
|
|
music: Fixed(92).normal(),
|
|
|
|
lossless: Fixed(93).normal(),
|
|
|
|
crypto: Fixed(109).normal(),
|
|
|
|
document: Fixed(105).normal(),
|
|
|
|
compressed: Red.normal(),
|
|
|
|
temp: GREY.normal(),
|
|
|
|
immediate: Yellow.bold().underline(),
|
|
|
|
compiled: Fixed(137).normal(),
|
2015-05-10 11:50:20 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
perms: Permissions {
|
|
|
|
user_read: Yellow.bold(),
|
|
|
|
user_write: Red.bold(),
|
|
|
|
user_execute_file: Green.bold().underline(),
|
|
|
|
user_execute_other: Green.bold(),
|
|
|
|
group_read: Yellow.normal(),
|
|
|
|
group_write: Red.normal(),
|
|
|
|
group_execute: Green.normal(),
|
|
|
|
other_read: Yellow.normal(),
|
|
|
|
other_write: Red.normal(),
|
|
|
|
other_execute: Green.normal(),
|
|
|
|
attribute: Plain,
|
|
|
|
},
|
|
|
|
|
|
|
|
size: Size {
|
|
|
|
numbers: Green.bold(),
|
|
|
|
unit: Green.normal(),
|
|
|
|
},
|
|
|
|
|
|
|
|
users: Users {
|
|
|
|
user_you: Yellow.bold(),
|
|
|
|
user_someone_else: Plain,
|
|
|
|
group_yours: Yellow.bold(),
|
|
|
|
group_not_yours: Plain,
|
|
|
|
},
|
|
|
|
|
|
|
|
links: Links {
|
|
|
|
normal: Red.bold(),
|
|
|
|
multi_link_file: Red.on(Yellow),
|
|
|
|
},
|
|
|
|
|
|
|
|
punctuation: Fixed(244).normal(),
|
|
|
|
date: Blue.normal(),
|
|
|
|
inode: Purple.normal(),
|
|
|
|
blocks: Cyan.normal(),
|
|
|
|
header: Plain.underline(),
|
|
|
|
|
|
|
|
symlink_path: Cyan.normal(),
|
|
|
|
broken_arrow: Red.normal(),
|
|
|
|
broken_filename: Red.underline()
|
2015-05-09 22:57:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|