Просмотр исходного кода

Rename broken_arrow to broken_symlink

Benjamin Sago 8 лет назад
Родитель
Сommit
a45bcfe058
3 измененных файлов с 18 добавлено и 11 удалено
  1. 3 1
      src/output/details.rs
  2. 14 9
      src/output/file_name.rs
  3. 1 1
      src/style/colours.rs

+ 3 - 1
src/output/details.rs

@@ -334,7 +334,9 @@ impl<'a> Render<'a> {
             None       => format!("<{}>", error),
         };
 
-        let name = TextCell::paint(self.colours.broken_arrow(), error_message);
+		// TODO: broken_symlink() doesn’t quite seem like the right name for
+		// the style that’s being used here. Maybe split it in two?
+        let name = TextCell::paint(self.colours.broken_symlink(), error_message);
         Row { cells: None, name, tree }
     }
 

+ 14 - 9
src/output/file_name.rs

@@ -121,6 +121,12 @@ impl<'a, 'dir, C: Colours> FileName<'a, 'dir, C> {
         }
 
         if !self.file.name.is_empty() {
+        	// The “missing file” colour seems like it should be used here,
+        	// but it’s not! In a grid view, where there's no space to display
+        	// link targets, the filename has to have a different style to
+        	// indicate this fact. But when showing targets, we can just
+        	// colour the path instead (see below), and leave the broken
+        	// link’s filename as the link colour.
             for bit in self.coloured_file_name() {
                 bits.push(bit);
             }
@@ -155,7 +161,7 @@ impl<'a, 'dir, C: Colours> FileName<'a, 'dir, C> {
 
                 FileTarget::Broken(ref broken_path) => {
                     bits.push(Style::default().paint(" "));
-                    bits.push(self.colours.broken_arrow().paint("->"));
+                    bits.push(self.colours.broken_symlink().paint("->"));
                     bits.push(Style::default().paint(" "));
                     escape(broken_path.display().to_string(), &mut bits, self.colours.broken_filename(), self.colours.broken_control_char());
                 },
@@ -229,15 +235,13 @@ impl<'a, 'dir, C: Colours> FileName<'a, 'dir, C> {
 
     /// Figures out which colour to paint the filename part of the output,
     /// depending on which “type” of file it appears to be -- either from the
-    /// class on the filesystem or from its name.
+    /// class on the filesystem or from its name. (Or the broken link colour,
+    /// if there’s nowhere else for that fact to be shown.)
     pub fn style(&self) -> Style {
-        // Override the style with the “broken link” style when this file is
-        // a link that we can’t follow for whatever reason. This is used when
-        // there’s no other place to show that the link doesn’t work.
         if let LinkStyle::JustFilenames = self.link_style {
             if let Some(ref target) = self.target {
                 if target.is_broken() {
-                    return self.colours.broken_arrow();
+                    return self.colours.broken_symlink();
                 }
             }
         }
@@ -273,9 +277,10 @@ pub trait Colours: FiletypeColours {
     /// The style to paint the arrow between a link and its target.
     fn normal_arrow(&self) -> Style;
 
-    /// The style to paint the arrow between a link and its target, when the
-    /// link is broken.
-    fn broken_arrow(&self) -> Style;
+	/// The style to paint the filenames of broken links in views that don’t
+	/// show link targets, and the style to paint the *arrow* between the link
+	/// and its target in views that *do* show link targets.
+    fn broken_symlink(&self) -> Style;
 
     /// The style to paint the entire filename of a broken link.
     fn broken_filename(&self) -> Style;

+ 1 - 1
src/style/colours.rs

@@ -393,7 +393,7 @@ impl render::UserColours for Colours {
 
 impl FileNameColours for Colours {
     fn normal_arrow(&self)        -> Style { self.punctuation }
-    fn broken_arrow(&self)        -> Style { self.broken_symlink }
+    fn broken_symlink(&self)      -> Style { self.broken_symlink }
     fn broken_filename(&self)     -> Style { apply_overlay(self.broken_symlink, self.broken_path_overlay) }
     fn broken_control_char(&self) -> Style { apply_overlay(self.control_char,   self.broken_path_overlay) }
     fn control_char(&self)        -> Style { self.control_char }