Skip to main content

Catalog

Trait Catalog 

Source
pub trait Catalog {
    type Class<'a>;

    // Required methods
    fn default<'a>() -> Self::Class<'a>;
    fn style(&self, class: &Self::Class<'_>) -> Style;
}
Expand description

The theme catalog of a code editor.

Implemented for iced::Theme out of the box, following the same catalog pattern Iced’s own widgets use. Implement it for a custom theme type to make this editor themable alongside the rest of an application.

§Examples

use iced_code_editor::theme::{Catalog, Style};

// `iced::Theme` implements `Catalog`, so a style comes from the theme
// itself rather than being hardcoded.
let class = <iced::Theme as Catalog>::default();
let style: Style = Catalog::style(&iced::Theme::Dracula, &class);

// A dark theme yields a dark editor background.
assert!(style.background.r < 0.5);

Required Associated Types§

Source

type Class<'a>

The item class of the Catalog.

Required Methods§

Source

fn default<'a>() -> Self::Class<'a>

The default class produced by the Catalog.

Source

fn style(&self, class: &Self::Class<'_>) -> Style

The Style of a class with the given status.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Catalog for Theme

Source§

type Class<'a> = Box<dyn Fn(&Theme) -> Style + 'a>

Source§

fn default<'a>() -> Self::Class<'a>

Source§

fn style(&self, class: &Self::Class<'_>) -> Style

Implementors§