| @@ -655,6 +655,7 @@ impl SortOverrides { |
| 655 | 655 | |
| 656 | 656 | #[derive(Clone, Debug, Default, Deserialize)] |
| 657 | 657 | pub struct Terminal { |
| 658 | pub cursor_shape: Option<CursorShape>, |
| 658 | 659 | pub enable_extended_keys: Option<bool>, |
| 659 | 660 | pub enable_title: Option<bool>, |
| 660 | 661 | } |
| @@ -662,6 +663,7 @@ pub struct Terminal { |
| 662 | 663 | impl Terminal { |
| 663 | 664 | fn merge(profile: Self, global: Self) -> Self { |
| 664 | 665 | Self { |
| 666 | cursor_shape: profile.cursor_shape.or(global.cursor_shape), |
| 665 | 667 | enable_extended_keys: profile.enable_extended_keys.or(global.enable_extended_keys), |
| 666 | 668 | enable_title: profile.enable_title.or(global.enable_title), |
| 667 | 669 | } |
| @@ -669,6 +671,7 @@ impl Terminal { |
| 669 | 671 | |
| 670 | 672 | pub fn values(self) -> TerminalValues { |
| 671 | 673 | TerminalValues { |
| 674 | cursor_shape: self.cursor_shape.unwrap_or_default(), |
| 672 | 675 | enable_extended_keys: self.enable_extended_keys, |
| 673 | 676 | enable_title: self.enable_title.unwrap_or(DEFAULT_ENABLE_TITLE), |
| 674 | 677 | } |
| @@ -677,6 +680,7 @@ impl Terminal { |
| 677 | 680 | |
| 678 | 681 | #[derive(Clone, Debug)] |
| 679 | 682 | pub struct TerminalValues { |
| 683 | pub cursor_shape: CursorShape, |
| 680 | 684 | pub enable_extended_keys: Option<bool>, |
| 681 | 685 | pub enable_title: bool, |
| 682 | 686 | } |
| @@ -830,6 +834,28 @@ impl Tunables { |
| 830 | 834 | } |
| 831 | 835 | } |
| 832 | 836 | |
| 837 | #[derive(Copy, Clone, Debug, Default, Deserialize, Eq, PartialEq)] |
| 838 | #[serde(rename_all = "kebab-case")] |
| 839 | #[repr(u8)] |
| 840 | pub enum CursorShape { |
| 841 | #[default] |
| 842 | Default, |
| 843 | Block, |
| 844 | Line, |
| 845 | Underline, |
| 846 | } |
| 847 | |
| 848 | impl From<CursorShape> for modalkit::crossterm::cursor::SetCursorStyle { |
| 849 | fn from(shape: CursorShape) -> Self { |
| 850 | match shape { |
| 851 | CursorShape::Default => Self::DefaultUserShape, |
| 852 | CursorShape::Block => Self::SteadyBlock, |
| 853 | CursorShape::Line => Self::SteadyBar, |
| 854 | CursorShape::Underline => Self::SteadyUnderScore, |
| 855 | } |
| 856 | } |
| 857 | } |
| 858 | |
| 833 | 859 | #[derive(Clone)] |
| 834 | 860 | pub struct DirectoryValues { |
| 835 | 861 | pub cache: PathBuf, |
| @@ -1499,6 +1525,16 @@ mod tests { |
| 1499 | 1525 | assert!(serde_json::from_str::<NotifyVia>(r#""""#).is_err()); |
| 1500 | 1526 | } |
| 1501 | 1527 | |
| 1528 | #[test] |
| 1529 | fn test_parse_cursor_shape() { |
| 1530 | assert_eq!(CursorShape::Default, CursorShape::default()); |
| 1531 | assert_eq!(CursorShape::Default, serde_json::from_str(r#""default""#).unwrap()); |
| 1532 | assert_eq!(CursorShape::Block, serde_json::from_str(r#""block""#).unwrap()); |
| 1533 | assert_eq!(CursorShape::Line, serde_json::from_str(r#""line""#).unwrap()); |
| 1534 | assert_eq!(CursorShape::Underline, serde_json::from_str(r#""underline""#).unwrap()); |
| 1535 | assert!(serde_json::from_str::<CursorShape>(r#""beam""#).is_err()); |
| 1536 | } |
| 1537 | |
| 1502 | 1538 | #[test] |
| 1503 | 1539 | fn test_load_example_config_toml() { |
| 1504 | 1540 | let path = PathBuf::from("config.example.toml"); |