Skip to main content

freya_core/style/
cursor.rs

1#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2#[derive(Default, Debug, Copy, Clone, Hash, PartialEq, Eq)]
3pub enum CursorStyle {
4    #[default]
5    Line = 0,
6    Block = 1,
7    Underline = 2,
8}
9
10impl CursorStyle {
11    pub fn pretty(&self) -> String {
12        match self {
13            Self::Line => "line".to_string(),
14            Self::Block => "block".to_string(),
15            Self::Underline => "underline".to_string(),
16        }
17    }
18}
19
20/// Determines how the cursor and highlights are positioned within a Paragraph.
21#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
22#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, Default)]
23pub enum CursorMode {
24    /// Cursor and highlights use the paragraph's visible_area.
25    /// VerticalAlign affects cursor/highlight positions.
26    #[default]
27    Fit,
28    /// Cursor and highlights use the paragraph's inner_area.
29    /// VerticalAlign does NOT affect cursor/highlight positions.
30    Expanded,
31}
32
33impl CursorMode {
34    pub fn pretty(&self) -> String {
35        match self {
36            Self::Fit => "fit".to_string(),
37            Self::Expanded => "expanded".to_string(),
38        }
39    }
40}