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