From 976db01b3e93aa537e1a682e61a8e02febfa6cad Mon Sep 17 00:00:00 2001 From: Benjamin Sago Date: Sat, 24 Oct 2020 18:29:28 +0100 Subject: [PATCH] Prefer background colour when painting icons The rationale here is that there's more of a background colour than the foreground colour when painting text, and having a gap of no background colour in between the icon and the file name looks weird. Fixes GH-561. --- src/output/icons.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/output/icons.rs b/src/output/icons.rs index 7b9676d..09b285a 100644 --- a/src/output/icons.rs +++ b/src/output/icons.rs @@ -27,8 +27,16 @@ impl Icons { } +/// Converts the style used to paint a file name into the style that should be +/// used to paint an icon. +/// +/// - The background colour should be preferred to the foreground colour, as +/// if one is set, it’s the more “obvious” colour choice. +/// - If neither is set, just use the default style. +/// - Attributes such as bold or underline should not be used to paint the +/// icon, as they can make it look weird. pub fn iconify_style<'a>(style: Style) -> Style { - style.foreground + style.background.or(style.foreground) .map(Style::from) .unwrap_or_default() }