aboutsummaryrefslogtreecommitdiff
path: root/helix-view/src/graphics.rs
diff options
context:
space:
mode:
authorGokul Soumya2021-08-12 01:00:19 +0000
committerGitHub2021-08-12 01:00:19 +0000
commit25a8a475c53a90fed9ad40db7c327a3cdf481cd7 (patch)
treec48d03b9582bba524a9b5639f82745df6d5fc644 /helix-view/src/graphics.rs
parent6d52424303bf92a9abcfe8daa45cff145966f820 (diff)
Refactor theme parsing (#570)
Diffstat (limited to 'helix-view/src/graphics.rs')
-rw-r--r--helix-view/src/graphics.rs24
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