提交 a542fdc9 编写于 作者: B Ben S

Highlight symlinks in cyan

上级 49d3caf0
use colours::{Plain, Style, Black, Red, Green, Yellow, Blue, Purple, Cyan};
use colours::{Plain, Style, Black, Red, Green, Yellow, Blue, Purple, Cyan, Fixed};
use std::io::{fs, IoResult};
use std::io;
......@@ -110,7 +110,7 @@ impl<'a> File<'a> {
let displayed_name = self.file_colour().paint(self.name);
if self.stat.kind == io::TypeSymlink {
match fs::readlink(self.path) {
Ok(path) => format!("{} => {}", displayed_name, path.display()),
Ok(path) => format!("{} {} {}", displayed_name, Fixed(244).paint("=>"), path.display()),
Err(e) => {
println!("{}", e);
displayed_name
......
use colours::{Plain, Style, Red, Green, Yellow, Blue, Fixed};
use colours::{Plain, Style, Red, Green, Yellow, Blue, Cyan, Fixed};
use file::File;
use std::io;
pub enum FileType {
Normal, Directory, Executable, Immediate, Compiled,
Normal, Directory, Executable, Immediate, Compiled, Symlink,
Image, Video, Music, Lossless, Compressed, Document, Temp, Crypto,
}
......@@ -45,6 +45,7 @@ impl FileType {
match *self {
Normal => Plain,
Directory => Blue.bold(),
Symlink => Cyan.normal(),
Executable => Green.bold(),
Image => Fixed(133).normal(),
Video => Fixed(135).normal(),
......@@ -69,6 +70,9 @@ impl<'a> HasType for File<'a> {
if self.stat.kind == io::TypeDirectory {
return Directory;
}
else if self.stat.kind == io::TypeSymlink {
return Symlink;
}
else if self.stat.perm.contains(io::UserExecute) {
return Executable;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册