Skip to main content

Colors

Struct Colors 

Source
#[non_exhaustive]
pub struct Colors { pub branches: Option<Color>, pub vertical: Option<Color>, pub keywords: Option<Color>, pub members: Option<Color>, pub strings: Option<Color>, pub values: Option<Color>, pub types: Option<Color>, }
Expand description

Color configuration for tree display elements.

Each element of the tree can be individually colored, allowing you to highlight different syntactic categories like types, keywords, strings, and tree lines. Colors are optional, so you can enable only the highlighting you want.

§Example

use tree_display::Colors;

let dark = Colors::VSCODE_DARK_PLUS;
let light = Colors::VSCODE_LIGHT_PLUS;

// Customize individual colors
let custom = Colors::new()
    .types(dark.types)
    .strings(light.strings);

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§branches: Option<Color>

Color for branch lines (horizontal connectors between nodes)

§vertical: Option<Color>

Color for vertical tree lines

§keywords: Option<Color>

Color for keyword like values (e.g. None)

§members: Option<Color>

Color for struct/enum member names

§strings: Option<Color>

Color for string literals

§values: Option<Color>

Color for literal values (e.g. integers, floats, bools)

§types: Option<Color>

Color for type names (e.g., String, Vec, Option)

Implementations§

Source§

impl Colors

Source

pub const NONE: Self

No colors (all elements use default terminal color).

Source

pub const VSCODE_DARK_PLUS: Self

Visual Studio Code Dark+ theme.

Source

pub const VSCODE_LIGHT_PLUS: Self

Visual Studio Code Light+ theme.

Source

pub const SOLARIZED_DARK: Self

Solarized Dark theme.

Source

pub const SOLARIZED_LIGHT: Self

Solarized Light theme.

Source

pub const DRACULA: Self

Dracula theme.

Source

pub const MONOKAI: Self

Monokai theme.

Source

pub const NORD: Self

Nord theme.

Source

pub const GITHUB_DARK: Self

GitHub Dark theme.

Source

pub const GITHUB_LIGHT: Self

GitHub Light theme.

Source§

impl Colors

Source

pub const fn new() -> Self

Creates a new Colors instance with Visual Studio Code Dark+ colors.

Source

pub const fn branches(self, color: Option<Color>) -> Self

Sets the color for branch lines.

Branch lines are the horizontal connectors that extend from vertical lines to node labels. They form the “arms” of the tree structure.

Pass None to disable coloring for this element.

Source

pub const fn vertical(self, color: Option<Color>) -> Self

Sets the color for vertical tree lines.

Vertical lines connect parent nodes to their children, forming the main backbone of the tree hierarchy.

Pass None to disable coloring for this element.

Source

pub const fn keywords(self, color: Option<Color>) -> Self

Sets the color for language keywords.

Keywords refer to keyword-like values such as enum variant names.

Pass None to disable coloring for this element.

Source

pub const fn members(self, color: Option<Color>) -> Self

Sets the color for struct/enum member names.

Member names are the fields of structs and variants of enums. They are typically displayed alongside their containing type.

Pass None to disable coloring for this element.

Source

pub const fn strings(self, color: Option<Color>) -> Self

Sets the color for string literals.

String literals are quoted text values, such as "hello" or multi-line string blocks.

Pass None to disable coloring for this element.

Source

pub const fn values(self, color: Option<Color>) -> Self

Sets the color for literal values.

Literal values include numbers (42, 3.14), booleans (true, false), characters ('a'), and other primitive constant values.

Pass None to disable coloring for this element.

Source

pub const fn types(self, color: Option<Color>) -> Self

Sets the color for type names.

Type names are identifiers that refer to types, such as String, Vec, Option, i32, and user-defined structs and enums.

Pass None to disable coloring for this element.

Source

pub const fn all(self, color: Option<Color>) -> Self

Sets all color elements to the same value.

This is a convenience method for quickly creating a uniform theme where all elements share the same color.

Pass None to disable all coloring.

Trait Implementations§

Source§

impl Clone for Colors

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Colors

Source§

impl Debug for Colors

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Colors

Source§

fn default() -> Self

Creates a new Colors instance with Visual Studio Code Dark+ colors.

Source§

impl Eq for Colors

Source§

impl Ord for Colors

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl PartialEq for Colors

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialOrd for Colors

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StructuralPartialEq for Colors

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<T> Content for T
where T: Debug + Any,

Source§

fn to_string(&self, theme: &Theme) -> String

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<'src, T> IntoMaybe<'src, T> for T
where T: 'src,

Source§

type Proj<U: 'src> = U

Source§

fn map_maybe<R>( self, _f: impl FnOnce(&'src T) -> &'src R, g: impl FnOnce(T) -> R, ) -> <T as IntoMaybe<'src, T>>::Proj<R>
where R: 'src,

Source§

impl<T> OrderedSeq<'_, T> for T
where T: Clone,

Source§

impl<'p, T> Seq<'p, T> for T
where T: Clone,

Source§

type Item<'a> = &'a T where T: 'a

The item yielded by the iterator.
Source§

type Iter<'a> = Once<&'a T> where T: 'a

An iterator over the items within this container, by reference.
Source§

fn seq_iter(&self) -> <T as Seq<'p, T>>::Iter<'_>

Iterate over the elements of the container.
Source§

fn contains(&self, val: &T) -> bool
where T: PartialEq,

Check whether an item is contained within this sequence.
Source§

fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>
where 'p: 'b,

Convert an item of the sequence into a MaybeRef.
Source§

impl<T, S> SpanWrap<S> for T
where S: WrappingSpan<T>,

Source§

fn with_span(self, span: S) -> <S as WrappingSpan<Self>>::Spanned

Invokes WrappingSpan::make_wrapped to wrap an AST node in a span.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.