diff options
Diffstat (limited to 'helix-view/src/graphics.rs')
-rw-r--r-- | helix-view/src/graphics.rs | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/helix-view/src/graphics.rs b/helix-view/src/graphics.rs index ed530533..9a7a86c3 100644 --- a/helix-view/src/graphics.rs +++ b/helix-view/src/graphics.rs @@ -1,5 +1,8 @@ use bitflags::bitflags;
-use std::cmp::{max, min};
+use std::{
+ cmp::{max, min},
+ str::FromStr,
+};
#[derive(Debug, Clone, Copy, PartialEq)]
/// UNSTABLE
@@ -237,6 +240,25 @@ bitflags! { }
}
+impl FromStr for Modifier {
+ type Err = &'static str;
+
+ fn from_str(modifier: &str) -> Result<Self, Self::Err> {
+ match modifier {
+ "bold" => Ok(Self::BOLD),
+ "dim" => Ok(Self::DIM),
+ "italic" => Ok(Self::ITALIC),
+ "underlined" => Ok(Self::UNDERLINED),
+ "slow_blink" => Ok(Self::SLOW_BLINK),
+ "rapid_blink" => Ok(Self::RAPID_BLINK),
+ "reversed" => Ok(Self::REVERSED),
+ "hidden" => Ok(Self::HIDDEN),
+ "crossed_out" => Ok(Self::CROSSED_OUT),
+ _ => Err("Invalid modifier"),
+ }
+ }
+}
+
/// Style let you control the main characteristics of the displayed elements.
///
/// ```rust
|