embedded-menu icon indicating copy to clipboard operation
embedded-menu copied to clipboard

add support for global `SelectValue` name

Open vic1707 opened this issue 10 months ago • 2 comments

currently doing

#[derive(embedded_menu::SelectValue, PartialEq, Eq, Clone, Copy)]
#[display_as(">")]
pub enum Page {
    Main,
    #[display_as("toto")]
    InputDebug,
    SelectInput,
    SelectOutput,
    Settings,
}

compiles but #[display_as(">")] doesn't do anything, we need to do

#[derive(embedded_menu::SelectValue, PartialEq, Eq, Clone, Copy)]
pub enum Page {
    #[display_as(">")]
    Main,
    #[display_as("toto")]
    InputDebug,
    #[display_as(">")]
    SelectInput,
    #[display_as(">")]
    SelectOutput,
    #[display_as(">")]
    Settings,
}

which can be done better.

with the current pr, a top level attribute (like shown in the first example) gives

impl embedded_menu::items::menu_item::SelectValue for Page {
    fn next(&mut self) {
        *self = match self {
            Self::Main => Self::InputDebug,
            Self::InputDebug => Self::SelectInput,
            Self::SelectInput => Self::SelectOutput,
            Self::SelectOutput => Self::Settings,
            Self::Settings => Self::Main,
        };
    }
    fn marker(&self) -> &str {
        match self {
            Self::Main => ">",
            Self::InputDebug => "toto",
            Self::SelectInput => ">",
            Self::SelectOutput => ">",
            Self::Settings => ">",
        }
    }
}

The top level attribute can be overwritten by the same attribute on each specific variant

vic1707 avatar Feb 18 '25 22:02 vic1707

I appreciate your enthusiasm but I have no energy or motivation to maintain this crate. Feel free to fork it and turn it into whatever you like it to be.

bugadani avatar Feb 18 '25 22:02 bugadani

Okay 👍 sorry for the inconveniences 🙇

vic1707 avatar Feb 19 '25 00:02 vic1707