Commit a1022c8642

a1022c86422bd9a6d0bcd7f1d9a7292711b2ee71

parent: 1799941957

Unregistered key

Ulyssa <git@ulyssa.dev> · 2026-09-12 03:04 UTC
committer: <noreply@github.com>

Use ASCII characters for encryption status indicators (#684)

Layout: unified · split

docs/iamb.5 +12
@@ -316,6 +316,18 @@ subsection allows controlling how encrypted rooms are presented.
316316.Pp
317317The available fields in this subsection are:
318318.Bl -tag -width Ds
319.It Sy icon_encrypted
320Override the encrypted room icon used in the message bar prompt or title.
321Defaults to a green
322.Sy [E] .
323.It Sy icon_unencrypted
324Override the unencrypted room icon used in the message bar prompt or title.
325Defaults to a red
326.Sy [U] .
327.It Sy icon_unknown
328Override the unknown encryption status icon used in the message bar prompt or title.
329Defaults to a yellow
330.Sy [?] .
319331.It Sy indicator
320332Defines when an encryption status indicator is shown.
321333Possible values are:
src/config.rs +43 −19
@@ -49,9 +49,13 @@ const DEFAULT_ROOM_SORT: [SortColumn<SortFieldRoom>; 5] = [
4949];
5050
5151const DEFAULT_ENABLE_TITLE: bool = true;
52const DEFAULT_ENC_INDICATOR_LOC: EncryptionIndicatorLocation = EncryptionIndicatorLocation::PROMPT;
5352const DEFAULT_REQ_TIMEOUT: u64 = 120;
5453
54const DEFAULT_ENC_INDICATOR_LOC: EncryptionIndicatorLocation = EncryptionIndicatorLocation::PROMPT;
55const DEFAULT_ICON_ENC: Cow<'static, str> = Cow::Borrowed("[E] ");
56const DEFAULT_ICON_UNENC: Cow<'static, str> = Cow::Borrowed("[U] ");
57const DEFAULT_ICON_UNKNOWN: Cow<'static, str> = Cow::Borrowed("[?] ");
58
5559const DEFAULT_LOG_LEVEL: &str = if cfg!(feature = "max_level_error") {
5660 "error"
5761} else {
@@ -558,6 +562,9 @@ impl Visitor<'_> for NotifyViaVisitor {
558562pub struct Encryption {
559563 indicator: Option<EncryptionIndicator>,
560564 indicator_location: Option<EncryptionIndicatorLocation>,
565 icon_encrypted: Option<String>,
566 icon_unencrypted: Option<String>,
567 icon_unknown: Option<String>,
561568}
562569
563570impl Encryption {
@@ -565,6 +572,9 @@ impl Encryption {
565572 Encryption {
566573 indicator: profile.indicator.or(global.indicator),
567574 indicator_location: profile.indicator_location.or(global.indicator_location),
575 icon_encrypted: profile.icon_encrypted.or(global.icon_encrypted),
576 icon_unencrypted: profile.icon_unencrypted.or(global.icon_unencrypted),
577 icon_unknown: profile.icon_unknown.or(global.icon_unknown),
568578 }
569579 }
570580
@@ -572,6 +582,9 @@ impl Encryption {
572582 EncryptionValues {
573583 indicator: self.indicator.unwrap_or_default(),
574584 indicator_location: self.indicator_location.unwrap_or(DEFAULT_ENC_INDICATOR_LOC),
585 icon_encrypted: self.icon_encrypted.map(Cow::Owned).unwrap_or(DEFAULT_ICON_ENC),
586 icon_unencrypted: self.icon_unencrypted.map(Cow::Owned).unwrap_or(DEFAULT_ICON_UNENC),
587 icon_unknown: self.icon_unknown.map(Cow::Owned).unwrap_or(DEFAULT_ICON_UNKNOWN),
575588 }
576589 }
577590}
@@ -580,6 +593,9 @@ impl Encryption {
580593pub struct EncryptionValues {
581594 pub indicator: EncryptionIndicator,
582595 pub indicator_location: EncryptionIndicatorLocation,
596 pub icon_encrypted: Cow<'static, str>,
597 pub icon_unencrypted: Cow<'static, str>,
598 pub icon_unknown: Cow<'static, str>,
583599}
584600
585601impl EncryptionValues {
@@ -603,20 +619,20 @@ impl EncryptionValues {
603619 EncryptionIndicator::Enabled | EncryptionIndicator::OnlyEncrypted,
604620 EncryptionState::Encrypted,
605621 ) => {
606 // Green lock:
607 Span::styled("\u{1F512}\u{FE0E} ", Style::new().fg(Color::LightGreen))
622 // Green encrypted icon:
623 Span::styled(self.icon_encrypted.clone(), Style::new().fg(Color::LightGreen))
608624 },
609625 (
610626 EncryptionIndicator::Enabled | EncryptionIndicator::OnlyUnencrypted,
611627 EncryptionState::NotEncrypted,
612628 ) => {
613 // Red unlocked lock:
614 Span::styled("\u{1F513}\u{FE0E} ", Style::new().fg(Color::Red))
629 // Red unencrypted icon:
630 Span::styled(self.icon_unencrypted.clone(), Style::new().fg(Color::Red))
615631 },
616632
617633 (_, EncryptionState::Unknown) => {
618 // Yellow question mark:
619 Span::styled("? ", Style::new().fg(Color::Yellow))
634 // Yellow unknown icon:
635 Span::styled(self.icon_unknown.clone(), Style::new().fg(Color::Yellow))
620636 },
621637 };
622638
@@ -1832,10 +1848,12 @@ mod tests {
18321848 fn test_encryption_indicator_enabled() {
18331849 use EncryptionState::*;
18341850
1835 let enc = EncryptionValues {
1836 indicator: EncryptionIndicator::Enabled,
1837 indicator_location: EncryptionIndicatorLocation::TITLE,
1851 let enc = Encryption {
1852 indicator: Some(EncryptionIndicator::Enabled),
1853 indicator_location: Some(EncryptionIndicatorLocation::TITLE),
1854 ..Default::default()
18381855 };
1856 let enc = enc.values();
18391857
18401858 // Always shows in the title:
18411859 assert!(enc.get_indicator(EncryptionIndicatorLocation::TITLE, Encrypted).is_some());
@@ -1858,10 +1876,12 @@ mod tests {
18581876 fn test_encryption_indicator_disabled() {
18591877 use EncryptionState::*;
18601878
1861 let enc = EncryptionValues {
1862 indicator: EncryptionIndicator::Disabled,
1863 indicator_location: EncryptionIndicatorLocation::TITLE,
1879 let enc = Encryption {
1880 indicator: Some(EncryptionIndicator::Disabled),
1881 indicator_location: Some(EncryptionIndicatorLocation::TITLE),
1882 ..Default::default()
18641883 };
1884 let enc = enc.values();
18651885
18661886 // Never shows in the title or the prompt:
18671887 assert!(enc.get_indicator(EncryptionIndicatorLocation::TITLE, Encrypted).is_none());
@@ -1882,10 +1902,12 @@ mod tests {
18821902 fn test_encryption_indicator_only_encrypted() {
18831903 use EncryptionState::*;
18841904
1885 let enc = EncryptionValues {
1886 indicator: EncryptionIndicator::OnlyEncrypted,
1887 indicator_location: EncryptionIndicatorLocation::PROMPT,
1905 let enc = Encryption {
1906 indicator: Some(EncryptionIndicator::OnlyEncrypted),
1907 indicator_location: Some(EncryptionIndicatorLocation::PROMPT),
1908 ..Default::default()
18881909 };
1910 let enc = enc.values();
18891911
18901912 // Shows in the prompt when encrypted or unknown:
18911913 assert!(enc.get_indicator(EncryptionIndicatorLocation::PROMPT, Encrypted).is_some());
@@ -1909,10 +1931,12 @@ mod tests {
19091931 fn test_encryption_indicator_only_unencrypted() {
19101932 use EncryptionState::*;
19111933
1912 let enc = EncryptionValues {
1913 indicator: EncryptionIndicator::OnlyUnencrypted,
1914 indicator_location: EncryptionIndicatorLocation::all(),
1934 let enc = Encryption {
1935 indicator: Some(EncryptionIndicator::OnlyUnencrypted),
1936 indicator_location: Some(EncryptionIndicatorLocation::all()),
1937 ..Default::default()
19151938 };
1939 let enc = enc.values();
19161940
19171941 // Shows in both the prompt and title when unencrypted or unknown:
19181942 assert!(
src/windows/room/chat.rs +15 −4
@@ -1111,10 +1111,21 @@ impl StatefulWidget for Chat<'_> {
11111111 .get_indicator(EncryptionIndicatorLocation::PROMPT, state.room().encryption_state());
11121112 let input_prompt = settings.tunables.input_prompt.as_deref();
11131113 let prompt = match (self.focused, encryption_indicator, input_prompt) {
1114 (false, _, _) => Span::raw(" "),
1115 (true, Some(i), _) => i,
1116 (true, None, None) => Span::raw("> "),
1117 (true, None, Some(s)) => Span::raw(s),
1114 // User has both encryption indicator and custom prompt, combine them:
1115 (false, Some(i), Some(p)) => Line::from(crate::util::space(i.width() + p.width())),
1116 (true, Some(i), Some(p)) => Line::from(vec![i, Span::from(p)]),
1117
1118 // User has custom prompt, use that:
1119 (false, None, Some(p)) => Line::from(crate::util::space(p.width())),
1120 (true, None, Some(p)) => Line::from(p),
1121
1122 // User has encryption indicator, use that as prompt:
1123 (false, Some(i), None) => Line::from(crate::util::space(i.width())),
1124 (true, Some(i), None) => Line::from(i),
1125
1126 // User has no encryption indicator, no custom prompt, so show "> ":
1127 (false, None, None) => Line::from(crate::util::space(2)),
1128 (true, None, None) => Line::from("> "),
11181129 };
11191130
11201131 let tbox = TextBox::new().prompt(prompt);
src/windows/room/mod.rs +8 −7
@@ -808,6 +808,14 @@ impl RoomState {
808808 let style = Style::default().add_modifier(StyleModifier::BOLD);
809809 let mut spans = vec![];
810810
811 if let Some(room) = room {
812 let encryption_settings = &store.application.settings.tunables.encryption;
813 let encryption_indicator = encryption_settings
814 .get_indicator(EncryptionIndicatorLocation::TITLE, room.encryption_state());
815 spans.extend(encryption_indicator);
816 spans.push(Span::raw(" "));
817 }
818
811819 if let RoomState::Chat(chat) = self &&
812820 chat.thread().is_some()
813821 {
@@ -816,13 +824,6 @@ impl RoomState {
816824
817825 spans.push(Span::styled(title, style));
818826
819 if let Some(room) = room {
820 let encryption_settings = &store.application.settings.tunables.encryption;
821 let encryption_indicator = encryption_settings
822 .get_indicator(EncryptionIndicatorLocation::TITLE, room.encryption_state());
823 spans.extend(encryption_indicator);
824 }
825
826827 match self.room().topic() {
827828 Some(desc) if !desc.is_empty() => {
828829 spans.push(" (".into());