1
0
Эх сурвалжийг харах

Highlight symlinks in cyan

Ben S 11 жил өмнө
parent
commit
a542fdc9f9
2 өөрчлөгдсөн 8 нэмэгдсэн , 4 устгасан
  1. 2 2
      file.rs
  2. 6 2
      filetype.rs

+ 2 - 2
file.rs

@@ -1,4 +1,4 @@
-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

+ 6 - 2
filetype.rs

@@ -1,9 +1,9 @@
-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;
         }