فهرست منبع

Colour file names in grid view

Ben S 11 سال پیش
والد
کامیت
92ccf821ff
2فایلهای تغییر یافته به همراه5 افزوده شده و 3 حذف شده
  1. 4 2
      src/exa.rs
  2. 1 1
      src/file.rs

+ 4 - 2
src/exa.rs

@@ -72,8 +72,10 @@ fn grid_view(options: &Options, dir: Dir) {
     
     for y in range(0, files.len() / num_columns) {
         for x in range(0, num_columns) {
-            let file_name = files.get(y * num_columns + x).name.clone();
-            print!("{}", Left.pad_string(&file_name, max_column_length - strip_formatting(file_name.clone()).len() + 1));
+            let file = files.get(y * num_columns + x);
+            let file_name = file.name.clone();
+            let styled_name = file.file_colour().paint(file_name.as_slice());
+            print!("{}", Left.pad_string(&styled_name, max_column_length - file_name.len() + 1));
         }
         print!("\n");
     }

+ 1 - 1
src/file.rs

@@ -210,7 +210,7 @@ impl<'a> File<'a> {
         }
     }
 
-    fn file_colour(&self) -> Style {
+    pub fn file_colour(&self) -> Style {
         self.get_type().style()
     }