Lines
100 %
Functions
Branches
/// Declares [`Role`] with its theme-file names from one list, so `ALL`, `name` and
/// `index` cannot disagree with the variants.
macro_rules! roles {
($($variant:ident => $name:literal),+ $(,)?) => {
/// What a styled cell is for; the theme file assigns a style to each.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Role {
$($variant),+
}
impl Role {
pub const ALL: [Role; [$(Role::$variant),+].len()] = [$(Role::$variant),+];
#[must_use]
pub const fn name(self) -> &'static str {
match self {
$(Role::$variant => $name),+
};
roles! {
Menu => "menu",
MenuSelected => "menu-selected",
MenuHotkey => "menu-hotkey",
MenuSelectedHotkey => "menu-selected-hotkey",
MenuDisabled => "menu-disabled",
MenuSelectedDisabled => "menu-selected-disabled",
Panel => "panel",
PanelFrame => "panel-frame",
PanelFramePassive => "panel-frame-passive",
PanelTitle => "panel-title",
PanelHeader => "panel-header",
PanelCursor => "panel-cursor",
PanelDim => "panel-dim",
FrameIcon => "frame-icon",
Desktop => "desktop",
Scrollbar => "scrollbar",
ScrollbarThumb => "scrollbar-thumb",
Status => "status",
StatusHotkey => "status-hotkey",
Dialog => "dialog",
DialogFrame => "dialog-frame",
DialogTitle => "dialog-title",
DialogIcon => "dialog-icon",
DialogFocus => "dialog-focus",
Label => "label",
LabelLit => "label-lit",
Button => "button",
ButtonDefault => "button-default",
ButtonHotkey => "button-hotkey",
ButtonFocus => "button-focus",
ButtonShadow => "button-shadow",
InputCursor => "input-cursor",
Input => "input",
InputFocused => "input-focused",
InputArrow => "input-arrow",
History => "history",
HistoryArrow => "history-arrow",
Prompt => "prompt",
List => "list",
ListSelected => "list-selected",
Shadow => "shadow",
pub(super) const fn index(self) -> usize {
self as usize
pub(crate) fn from_name(name: &str) -> Option<Role> {
Self::ALL.into_iter().find(|role| role.name() == name)