use crate::backend::utils::CssAttribute;
use ratatui::style::Style;
#[derive(Debug, Default)]
pub enum CursorShape {
#[default]
SteadyBlock,
SteadyUnderScore,
None,
}
impl CursorShape {
pub fn hide(&self, style: Style) -> Style {
match self {
CursorShape::SteadyBlock => style.not_reversed(),
CursorShape::SteadyUnderScore => style.not_underlined(),
CursorShape::None => style,
}
}
pub fn show(&self, style: Style) -> Style {
match self {
CursorShape::SteadyBlock => style.reversed(),
CursorShape::SteadyUnderScore => style.underlined(),
CursorShape::None => style,
}
}
pub fn get_css_attribute(&self) -> CssAttribute {
match self {
CursorShape::SteadyBlock => CssAttribute {
field: "text-decoration",
value: Some("none"),
},
CursorShape::SteadyUnderScore => CssAttribute {
field: "text-decoration",
value: Some("underline"),
},
CursorShape::None => CssAttribute {
field: "text-decoration",
value: None,
},
}
}
}