summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Sago <ogham@bsago.me>2017-09-13 08:44:59 +0100
committerBenjamin Sago <ogham@bsago.me>2017-09-13 08:44:59 +0100
commitb86074d63b183eda8f5cd26d339864bac4328084 (patch)
tree9a1180e6018961b89702028a9f2f461a6c548418
parent28b4b672d48a0714608d50777f469055b4bedb4a (diff)
Rename Style to Styles to avoid a name clash
-rw-r--r--src/options/style.rs20
-rw-r--r--src/options/view.rs4
2 files changed, 17 insertions, 7 deletions
diff --git a/src/options/style.rs b/src/options/style.rs
index 2aede03..061fef2 100644
--- a/src/options/style.rs
+++ b/src/options/style.rs
@@ -60,12 +60,22 @@ impl TerminalColours {
}
-pub struct Style {
+/// **Styles**, which is already an overloaded term, is a pair of view option
+/// sets that happen to both be affected by `LS_COLORS` and `EXA_COLORS`.
+/// Because it’s better to only iterate through that once, the two are deduced
+/// together.
+pub struct Styles {
+
+ /// The colours to paint user interface elements, like the date column,
+ /// and file kinds, such as directories.
pub colours: Colours,
+
+ /// The colours to paint the names of files that match glob patterns
+ /// (and the classify option).
pub style: FileStyle,
}
-impl Style {
+impl Styles {
#[allow(trivial_casts)] // the "as Box<_>" stuff below warns about this for some reason
pub fn deduce<V, TW>(matches: &MatchedFlags, vars: &V, widther: TW) -> Result<Self, Misfire>
@@ -80,7 +90,7 @@ impl Style {
let tc = TerminalColours::deduce(matches)?;
if tc == Never || (tc == Automatic && widther().is_none()) {
- return Ok(Style {
+ return Ok(Styles {
colours: Colours::plain(),
style: FileStyle { classify, exts: Box::new(NoFileColours) },
});
@@ -101,14 +111,14 @@ impl Style {
LSColors(exa.as_ref()).each_pair(|pair| {
colours.set_exa(&pair);
});
+ let style = FileStyle { classify, exts };
+ Ok(Styles { colours, style })
}
let classify = Classify::deduce(matches)?;
let exts = if colours.colourful { Box::new(FileExtensions) as Box<_> }
else { Box::new(NoFileColours) as Box<_> };
- let style = FileStyle { classify, exts };
- Ok(Style { colours, style })
}
}
diff --git a/src/options/view.rs b/src/options/view.rs
index 8d4520d..deff114 100644
--- a/src/options/view.rs
+++ b/src/options/view.rs
@@ -13,10 +13,10 @@ impl View {
/// Determine which view to use and all of that view’s arguments.
pub fn deduce<V: Vars>(matches: &MatchedFlags, vars: &V) -> Result<View, Misfire> {
- use options::style::Style;
+ use options::style::Styles;
let mode = Mode::deduce(matches, vars)?;
- let Style { colours, style } = Style::deduce(matches, vars, || *TERM_WIDTH)?;
+ let Styles { colours, style } = Styles::deduce(matches, vars, || *TERM_WIDTH)?;
Ok(View { mode, colours, style })
}
}