summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime “pep” Buquet <pep@bouah.net>2022-04-10 23:55:01 +0200
committerMaxime “pep” Buquet <pep@bouah.net>2022-08-21 21:36:16 +0200
commit80553747c29deca334aa179af012c9b11b343cb7 (patch)
treeabc01c89b048c6881bdaef78ef54c1288747dec9 /src
parent429c382f608dcf298931ce679e30ae1e6b702c37 (diff)
downloadpoezio-80553747c29deca334aa179af012c9b11b343cb7.tar.gz
poezio-80553747c29deca334aa179af012c9b11b343cb7.tar.bz2
poezio-80553747c29deca334aa179af012c9b11b343cb7.tar.xz
poezio-80553747c29deca334aa179af012c9b11b343cb7.zip
theming: add Attr::Reverse
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
Diffstat (limited to 'src')
-rw-r--r--src/theming.rs12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/theming.rs b/src/theming.rs
index a812a732..9d6c901e 100644
--- a/src/theming.rs
+++ b/src/theming.rs
@@ -1,5 +1,7 @@
use enum_set::{CLike, EnumSet};
-use ncurses::{attr_t, init_pair, A_BLINK, A_BOLD, A_ITALIC, A_UNDERLINE, COLORS, COLOR_PAIR};
+use ncurses::{
+ attr_t, init_pair, A_BLINK, A_BOLD, A_ITALIC, A_REVERSE, A_UNDERLINE, COLORS, COLOR_PAIR,
+};
use nom::{
branch::alt,
bytes::complete::tag,
@@ -18,6 +20,7 @@ pub enum Attr {
Italic,
Underline,
Blink,
+ Reverse,
}
impl Attr {
@@ -27,6 +30,7 @@ impl Attr {
Attr::Italic => A_ITALIC(),
Attr::Underline => A_UNDERLINE(),
Attr::Blink => A_BLINK(),
+ Attr::Reverse => A_REVERSE(),
}
}
}
@@ -42,7 +46,7 @@ impl CLike for Attr {
}
fn parse_attr(input: &str) -> IResult<&str, Attr> {
- let (input, attr) = alt((tag("b"), tag("i"), tag("u"), tag("a")))(input)?;
+ let (input, attr) = alt((tag("b"), tag("i"), tag("u"), tag("a"), tag("r")))(input)?;
Ok((
input,
@@ -51,6 +55,7 @@ fn parse_attr(input: &str) -> IResult<&str, Attr> {
"i" => Attr::Italic,
"u" => Attr::Underline,
"a" => Attr::Blink,
+ "r" => Attr::Reverse,
_ => {
return Err(NomErr::Error(NomError::from_error_kind(
input,
@@ -166,12 +171,13 @@ mod tests {
#[test]
fn all() {
- let attrs = "baiu";
+ let attrs = "baiur";
let mut expected = EnumSet::new();
expected.insert(Attr::Bold);
expected.insert(Attr::Blink);
expected.insert(Attr::Italic);
expected.insert(Attr::Underline);
+ expected.insert(Attr::Reverse);
let received = parse_attrs(attrs).unwrap();
assert_eq!(received, expected);
}