use std::fmt;
use crate::mm::{BufferId, WindowId};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
pub enum OptionScope {
#[default]
Global,
Buffer,
Window,
}
impl OptionScope {
#[must_use]
pub const fn display_name(self) -> &'static str {
match self {
Self::Global => "global",
Self::Buffer => "buffer",
Self::Window => "window",
}
}
}
impl fmt::Display for OptionScope {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.display_name())
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
pub enum OptionScopeId {
#[default]
Global,
Buffer(BufferId),
Window(WindowId),
}
impl fmt::Display for OptionScopeId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Global => write!(f, "global"),
Self::Buffer(id) => write!(f, "buffer({id:?})"),
Self::Window(id) => write!(f, "window({id:?})"),
}
}
}