mirror of
https://github.com/Llewellynvdm/exa.git
synced 2024-11-25 21:37:33 +00:00
Rename Style to Styles to avoid a name clash
This commit is contained in:
parent
28b4b672d4
commit
b86074d63b
@ -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 })
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 })
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user