diff --git a/src/app/style.rs b/src/app/style.rs index a839dbd..dab736c 100644 --- a/src/app/style.rs +++ b/src/app/style.rs @@ -62,6 +62,7 @@ pub fn get_colored_table_row<'a>( line.find('[').unwrap_or_default(), line.find(']').unwrap_or_default(), ); + row.push( // Colorize inside the brackets to start. if second_bracket > first_bracket + 1 { @@ -149,6 +150,55 @@ pub fn get_colored_table_row<'a>( highlight_style, )); // Colorize inside the arrows. + } else if let ( + Some(first_parenthesis), + Some(second_parenthesis), + ) = (data.rfind('('), data.rfind(')')) + { + let inner = line[first_parenthesis..].to_string(); + + log::trace!(target: "style", "inner: {inner:?}"); + let expected = [ + // expired + String::from("exp"), + // revoked + String::from("rev"), + // disabled + String::from("d"), + // invalid + String::from("i"), + ]; + if let Some((opening_parenthesis, _)) = + data.match_indices("(").next() + { + let inner = data[(opening_parenthesis + 1) + ..(opening_parenthesis + 4)] + .to_string(); + + if expected.contains(&inner) { + colored_line.push(Span::styled( + data[..first_parenthesis].to_string(), + highlight_style, + )); + colored_line.push(Span::styled( + "(", + TuiStyle::default().fg(Color::DarkGray), + )); + colored_line.push(Span::styled( + data[first_parenthesis + 1..second_parenthesis] + .to_string(), + TuiStyle::default().fg(Color::Red), + )); + colored_line.push(Span::styled( + ")", + TuiStyle::default().fg(Color::DarkGray), + )); + colored_line.push(Span::styled( + data[second_parenthesis + 1..].to_string(), + highlight_style, + )); + } + } } else if let (Some(first_arrow), Some(second_arrow)) = (data.rfind('<'), data.rfind('>')) { diff --git a/src/gpg/key.rs b/src/gpg/key.rs index 8574987..3125cf5 100644 --- a/src/gpg/key.rs +++ b/src/gpg/key.rs @@ -127,10 +127,36 @@ impl GpgKey { ) -> Vec { let mut key_info = Vec::new(); let subkeys = self.inner.subkeys().collect::>(); + let blank = String::from(""); for (i, subkey) in subkeys.iter().enumerate() { key_info.push(format!( - "[{}]{}{}/{}", + "[{}] {} {}{}/{}", handler::get_subkey_flags(*subkey), + format!( + "{}", + if i != subkeys.len() - 1 { + let last = subkeys.last(); + if let Some(key) = last { + if key.is_expired() { + String::from("(exp)") + } else if key.is_revoked() { + String::from("(rev)") + } else if key.is_disabled() { + String::from("(d)") + } else if key.is_invalid() { + String::from("(i)") + } else if key.is_qualified() { + String::from("(q)") + } else { + blank.to_string() + } + } else { + blank.to_string() + } + } else { + blank.to_string() + } + ), if default_key.map(|v| v.trim_start_matches("0x")) == subkey.id().ok() { @@ -227,7 +253,7 @@ impl GpgKey { "│ " }; user_signatures.push(format!( - " {} {}[{:x}] {} {}", + " {} {}[{:x}] {}, {} {}", padding, if i == signatures.len() - 1 { "└─" @@ -235,6 +261,7 @@ impl GpgKey { "├─" }, sig.cert_class(), + format!("REV: {}", sig.is_revocation()), if sig.signer_key_id() == self.inner.id() { String::from("selfsig") } else if truncate {