Struct syntastica::theme::ResolvedTheme
pub struct ResolvedTheme(/* private fields */);
Expand description
A Theme
where all internal links have been resolved.
Instead of ThemeValue
s, a ResolvedTheme
has Style
s as values. These cannot link to
other entries of the theme but completely define a style on their own.
A ResolvedTheme
can be created from a Theme
with Theme::resolve_links
or the
TryFrom<Theme>
implementation.
To get the style for a key in this theme, the preferred method is using
ResolvedTheme::find_style
, which will return the best match it finds. See the method’s docs
for more information. Alternatively, ResolvedTheme::get
can be used to only look for an
exact match.
Implementations§
§impl ResolvedTheme
impl ResolvedTheme
pub fn new(
highlights: BTreeMap<Cow<'static, str>, Style, Global>
) -> ResolvedTheme
pub fn new( highlights: BTreeMap<Cow<'static, str>, Style, Global> ) -> ResolvedTheme
Create a new ResolvedTheme
from a map of theme keys to Style
s.
pub fn into_inner(self) -> BTreeMap<Cow<'static, str>, Style, Global>
pub fn into_inner(self) -> BTreeMap<Cow<'static, str>, Style, Global>
Consume self
and return the contained theme map.
May be used to merge multiple ResolvedTheme
s together.
pub fn get<Q>(&self, key: &Q) -> Option<&Style>where
Cow<'static, str>: Borrow<Q>,
Q: Ord + ?Sized,
pub fn get<Q>(&self, key: &Q) -> Option<&Style>where Cow<'static, str>: Borrow<Q>, Q: Ord + ?Sized,
Returns a reference to the style corresponding to the key.
pub fn fg(&self) -> Option<Rgb<Srgb, u8>>
pub fn fg(&self) -> Option<Rgb<Srgb, u8>>
Get the default foreground color, if the theme defines one.
pub fn bg(&self) -> Option<Rgb<Srgb, u8>>
pub fn bg(&self) -> Option<Rgb<Srgb, u8>>
Get the default background color, if the theme defines one.
pub fn find_style(&self, key: &str) -> Option<Style>
pub fn find_style(&self, key: &str) -> Option<Style>
Try to find the best possible style supported by the given a theme key.
For example, if key
is keyword.operator
but this theme only has a style defined for
keyword
, then the style for keyword
is returned. Additionally, if no style is found,
the method tries to use the theme’s default foreground as a fallback.
Trait Implementations§
§impl Clone for ResolvedTheme
impl Clone for ResolvedTheme
§fn clone(&self) -> ResolvedTheme
fn clone(&self) -> ResolvedTheme
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more§impl Debug for ResolvedTheme
impl Debug for ResolvedTheme
§impl Hash for ResolvedTheme
impl Hash for ResolvedTheme
§impl PartialEq<ResolvedTheme> for ResolvedTheme
impl PartialEq<ResolvedTheme> for ResolvedTheme
§fn eq(&self, other: &ResolvedTheme) -> bool
fn eq(&self, other: &ResolvedTheme) -> bool
self
and other
values to be equal, and is used
by ==
.§impl TryFrom<Theme> for ResolvedTheme
impl TryFrom<Theme> for ResolvedTheme
§fn try_from(value: Theme) -> Result<ResolvedTheme, Error>
fn try_from(value: Theme) -> Result<ResolvedTheme, Error>
Try to create a ResolvedTheme
from a Theme
by calling Theme::resolve_links
.
impl Eq for ResolvedTheme
impl StructuralEq for ResolvedTheme
impl StructuralPartialEq for ResolvedTheme
Auto Trait Implementations§
impl RefUnwindSafe for ResolvedTheme
impl Send for ResolvedTheme
impl Sync for ResolvedTheme
impl Unpin for ResolvedTheme
impl UnwindSafe for ResolvedTheme
Blanket Implementations§
source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere T: Real + Zero + Arithmetics + Clone, Swp: WhitePoint<T>, Dwp: WhitePoint<T>, D: AdaptFrom<S, Swp, Dwp, T>,
source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere M: TransformMatrix<T>,
source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
source§impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
impl<T, C> ArraysFrom<C> for Twhere C: IntoArrays<T>,
source§fn arrays_from(colors: C) -> T
fn arrays_from(colors: C) -> T
source§impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
impl<T, C> ArraysInto<C> for Twhere C: FromArrays<T>,
source§fn arrays_into(self) -> C
fn arrays_into(self) -> C
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
impl<T, C> ComponentsFrom<C> for Twhere C: IntoComponents<T>,
source§fn components_from(colors: C) -> T
fn components_from(colors: C) -> T
source§impl<T> FromAngle<T> for T
impl<T> FromAngle<T> for T
source§fn from_angle(angle: T) -> T
fn from_angle(angle: T) -> T
angle
.source§impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
impl<T, U> FromStimulus<U> for Twhere U: IntoStimulus<T>,
source§fn from_stimulus(other: U) -> T
fn from_stimulus(other: U) -> T
other
into Self
, while performing the appropriate scaling,
rounding and clamping.source§impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
impl<T, U> IntoAngle<U> for Twhere U: FromAngle<T>,
source§fn into_angle(self) -> U
fn into_angle(self) -> U
T
.source§impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere U: FromColor<T>,
source§fn into_color(self) -> U
fn into_color(self) -> U
source§impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for Twhere U: FromColorUnclamped<T>,
source§fn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
source§impl<T> IntoStimulus<T> for T
impl<T> IntoStimulus<T> for T
source§fn into_stimulus(self) -> T
fn into_stimulus(self) -> T
self
into T
, while performing the appropriate scaling,
rounding and clamping.source§impl<'a, T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
impl<'a, T, C> TryComponentsInto<C> for Twhere C: TryFromComponents<T>,
§type Error = <C as TryFromComponents<T>>::Error
type Error = <C as TryFromComponents<T>>::Error
try_into_colors
fails to cast.source§fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
source§impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for Twhere U: TryFromColor<T>,
source§fn try_into_color(self) -> Result<U, OutOfBounds<U>>
fn try_into_color(self) -> Result<U, OutOfBounds<U>>
OutOfBounds
error is returned which contains
the unclamped color. Read more