use std::fmt::{Display, Formatter};
pub struct MouseButtonMarkdown(pub egui::PointerButton);
impl Display for MouseButtonMarkdown {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self.0 {
egui::PointerButton::Primary => write!(f, "`left` mouse button"),
egui::PointerButton::Secondary => write!(f, "`right` mouse button"),
egui::PointerButton::Middle => write!(f, "`middle` mouse button"),
egui::PointerButton::Extra1 => write!(f, "`extra 1` mouse button"),
egui::PointerButton::Extra2 => write!(f, "`extra 2` mouse button"),
}
}
}
pub struct ModifiersMarkdown<'a>(pub egui::Modifiers, pub &'a egui::Context);
impl Display for ModifiersMarkdown<'_> {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
let is_mac = matches!(
self.1.os(),
egui::os::OperatingSystem::Mac | egui::os::OperatingSystem::IOS
);
write!(
f,
"`{}`",
egui::ModifierNames::NAMES.format(&self.0, is_mac)
)
}
}
pub struct KeyMarkdown(pub egui::Key);
impl Display for KeyMarkdown {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "`{}`", self.0.name())
}
}